-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement nested Parquet writing for High-Precision Decimals (#…
- Loading branch information
1 parent
687811d
commit 40c7072
Showing
6 changed files
with
157 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
crates/polars-parquet/src/arrow/write/fixed_size_binary/basic.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use arrow::array::{Array, FixedSizeBinaryArray}; | ||
use polars_error::PolarsResult; | ||
|
||
use super::encode_plain; | ||
use crate::parquet::page::DataPage; | ||
use crate::parquet::schema::types::PrimitiveType; | ||
use crate::parquet::statistics::FixedLenStatistics; | ||
use crate::read::schema::is_nullable; | ||
use crate::write::{utils, EncodeNullability, Encoding, WriteOptions}; | ||
|
||
pub fn array_to_page( | ||
array: &FixedSizeBinaryArray, | ||
options: WriteOptions, | ||
type_: PrimitiveType, | ||
statistics: Option<FixedLenStatistics>, | ||
) -> PolarsResult<DataPage> { | ||
let is_optional = is_nullable(&type_.field_info); | ||
let encode_options = EncodeNullability::new(is_optional); | ||
|
||
let validity = array.validity(); | ||
|
||
let mut buffer = vec![]; | ||
utils::write_def_levels( | ||
&mut buffer, | ||
is_optional, | ||
validity, | ||
array.len(), | ||
options.version, | ||
)?; | ||
|
||
let definition_levels_byte_length = buffer.len(); | ||
|
||
encode_plain(array, encode_options, &mut buffer); | ||
|
||
utils::build_plain_page( | ||
buffer, | ||
array.len(), | ||
array.len(), | ||
array.null_count(), | ||
0, | ||
definition_levels_byte_length, | ||
statistics.map(|x| x.serialize()), | ||
type_, | ||
options, | ||
Encoding::Plain, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
crates/polars-parquet/src/arrow/write/fixed_size_binary/nested.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use arrow::array::{Array, FixedSizeBinaryArray}; | ||
use polars_error::PolarsResult; | ||
|
||
use super::encode_plain; | ||
use crate::parquet::page::DataPage; | ||
use crate::parquet::schema::types::PrimitiveType; | ||
use crate::parquet::statistics::FixedLenStatistics; | ||
use crate::read::schema::is_nullable; | ||
use crate::write::{nested, utils, EncodeNullability, Encoding, Nested, WriteOptions}; | ||
|
||
pub fn array_to_page( | ||
array: &FixedSizeBinaryArray, | ||
options: WriteOptions, | ||
type_: PrimitiveType, | ||
nested: &[Nested], | ||
statistics: Option<FixedLenStatistics>, | ||
) -> PolarsResult<DataPage> { | ||
let is_optional = is_nullable(&type_.field_info); | ||
let encode_options = EncodeNullability::new(is_optional); | ||
|
||
let mut buffer = vec![]; | ||
let (repetition_levels_byte_length, definition_levels_byte_length) = | ||
nested::write_rep_and_def(options.version, nested, &mut buffer)?; | ||
|
||
encode_plain(array, encode_options, &mut buffer); | ||
|
||
utils::build_plain_page( | ||
buffer, | ||
nested::num_values(nested), | ||
nested[0].len(), | ||
array.null_count(), | ||
repetition_levels_byte_length, | ||
definition_levels_byte_length, | ||
statistics.map(|x| x.serialize()), | ||
type_, | ||
options, | ||
Encoding::Plain, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters