Skip to content

Commit

Permalink
compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Dec 5, 2024
1 parent 4f8fa7a commit 90c45e0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
35 changes: 21 additions & 14 deletions parquet/src/arrow/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,16 @@ pub(crate) fn add_encoded_arrow_schema_to_metadata(schema: &Schema, props: &mut

/// Converter for arrow schema to parquet schema
///
/// Notes:
/// Example:
/// ```
/// todo!()
/// ```
#[derive(Debug)]
pub struct ArrowToParquetSchemaConverter<'a> {
/// The schema to convert
schema: &'a Schema
schema: &'a Schema,
/// Name of the root schema in Parquet
root_schema_name: &str,
root_schema_name: &'a str,
/// Should we Coerce arrow types to compatible Parquet types?
///
/// See docs on [Self::with_coerce_types]`
Expand Down Expand Up @@ -275,14 +278,21 @@ impl <'a> ArrowToParquetSchemaConverter<'a> {
}

/// Set the root schema element name (defaults to `"arrow_schema"`).
pub fn with_root_schema_name<'b>(mut self, root_schema_name: &'b str) -> Self<'b> {
pub fn with_root_schema_name(mut self, root_schema_name: &'a str) -> Self {
self.root_schema_name = root_schema_name;
self
}

/// Build the parquet schema according
pub fn convert(self) -> Result<SchemaDescriptor> {

/// Build the desired parquet [`SchemaDescriptor`]
pub fn build(self) -> Result<SchemaDescriptor> {
let Self { schema, root_schema_name, coerce_types } = self;
let fields = schema
.fields()
.iter()
.map(|field| arrow_to_parquet_type(field, coerce_types).map(Arc::new))
.collect::<Result<_>>()?;
let group = Type::group_type_builder(root_schema_name).with_fields(fields).build()?;
Ok(SchemaDescriptor::new(Arc::new(group)))
}
}

Expand All @@ -300,13 +310,10 @@ pub fn arrow_to_parquet_schema_with_root(
root: &str,
coerce_types: bool,
) -> Result<SchemaDescriptor> {
let fields = schema
.fields()
.iter()
.map(|field| arrow_to_parquet_type(field, coerce_types).map(Arc::new))
.collect::<Result<_>>()?;
let group = Type::group_type_builder(root).with_fields(fields).build()?;
Ok(SchemaDescriptor::new(Arc::new(group)))
ArrowToParquetSchemaConverter::new(schema)
.with_root_schema_name(root)
.with_coerce_types(coerce_types)
.build()
}

fn parse_key_value_metadata(
Expand Down
5 changes: 2 additions & 3 deletions parquet/src/file/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
// under the License.

//! Configuration via [`WriterProperties`] and [`ReaderProperties`]
use std::str::FromStr;
use std::{collections::HashMap, sync::Arc};
use arrow_schema::DataType;
use crate::basic::{Compression, Encoding};
use crate::compression::{CodecOptions, CodecOptionsBuilder};
use crate::file::metadata::KeyValue;
use crate::format::SortingColumn;
use crate::schema::types::ColumnPath;
use std::str::FromStr;
use std::{collections::HashMap, sync::Arc};

/// Default value for [`WriterProperties::data_page_size_limit`]
pub const DEFAULT_PAGE_SIZE: usize = 1024 * 1024;
Expand Down

0 comments on commit 90c45e0

Please sign in to comment.