-
Notifications
You must be signed in to change notification settings - Fork 787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not write ColumnIndex
for null columns when not writing page statistics
#6011
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -260,6 +260,12 @@ impl<'a, E: ColumnValueEncoder> GenericColumnWriter<'a, E> { | |
// Used for level information | ||
encodings.insert(Encoding::RLE); | ||
|
||
// Disable column_index_builder if not collecting page statistics. | ||
let mut column_index_builder = ColumnIndexBuilder::new(); | ||
if statistics_enabled != EnabledStatistics::Page { | ||
column_index_builder.to_invalid() | ||
} | ||
|
||
Self { | ||
descr, | ||
props, | ||
|
@@ -289,7 +295,7 @@ impl<'a, E: ColumnValueEncoder> GenericColumnWriter<'a, E> { | |
num_column_nulls: 0, | ||
column_distinct_count: None, | ||
}, | ||
column_index_builder: ColumnIndexBuilder::new(), | ||
column_index_builder, | ||
offset_index_builder: OffsetIndexBuilder::new(), | ||
encodings, | ||
data_page_boundary_ascending: true, | ||
|
@@ -3020,6 +3026,30 @@ mod tests { | |
assert!(incremented.is_none()) | ||
} | ||
|
||
#[test] | ||
fn test_no_column_index_when_stats_disabled() { | ||
// https://github.com/apache/arrow-rs/issues/6010 | ||
// Test that column index is not created/written for all-nulls column when page | ||
// statistics are disabled. | ||
let descr = Arc::new(get_test_column_descr::<Int32Type>(1, 0)); | ||
let props = Arc::new( | ||
WriterProperties::builder() | ||
.set_statistics_enabled(EnabledStatistics::None) | ||
.build(), | ||
); | ||
let column_writer = get_column_writer(descr, props, get_test_page_writer()); | ||
let mut writer = get_typed_column_writer::<Int32Type>(column_writer); | ||
|
||
let data = Vec::new(); | ||
let def_levels = vec![0; 10]; | ||
writer.write_batch(&data, Some(&def_levels), None).unwrap(); | ||
writer.flush_data_pages().unwrap(); | ||
|
||
let column_close_result = writer.close().unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I verified that this test covers the code by removing the change and verifying the test fails like
|
||
assert!(column_close_result.offset_index.is_some()); | ||
assert!(column_close_result.column_index.is_none()); | ||
} | ||
|
||
#[test] | ||
fn test_boundary_order() -> Result<()> { | ||
let descr = Arc::new(get_test_column_descr::<Int32Type>(1, 0)); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the reason this works currently for columns without null is that the ColumnIndex builder is marked as invalid if there are no page statistics at the end of the page. However, when the column has no data this code is not run
arrow-rs/parquet/src/column/writer/mod.rs
Line 661 in 9b34950
So TLDR is I think this change looks good to me