-
Notifications
You must be signed in to change notification settings - Fork 850
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
Simplify parquet statistics generation #5183
Merged
Merged
Changes from all commits
Commits
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -329,28 +329,11 @@ impl<'a, E: ColumnValueEncoder> GenericColumnWriter<'a, E> { | |
None => values.len(), | ||
}; | ||
|
||
// If only computing chunk-level statistics compute them here, page-level statistics | ||
// are computed in [`Self::write_mini_batch`] and used to update chunk statistics in | ||
// [`Self::add_data_page`] | ||
if self.statistics_enabled == EnabledStatistics::Chunk | ||
// INTERVAL has undefined sort order, so don't write min/max stats for it | ||
&& self.descr.converted_type() != ConvertedType::INTERVAL | ||
{ | ||
match (min, max) { | ||
(Some(min), Some(max)) => { | ||
update_min(&self.descr, min, &mut self.column_metrics.min_column_value); | ||
update_max(&self.descr, max, &mut self.column_metrics.max_column_value); | ||
} | ||
(None, Some(_)) | (Some(_), None) => { | ||
panic!("min/max should be both set or both None") | ||
} | ||
(None, None) => { | ||
if let Some((min, max)) = self.encoder.min_max(values, value_indices) { | ||
update_min(&self.descr, &min, &mut self.column_metrics.min_column_value); | ||
update_max(&self.descr, &max, &mut self.column_metrics.max_column_value); | ||
} | ||
} | ||
}; | ||
if let Some(min) = min { | ||
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. This min is only passed in when precomputed statistics are used ( |
||
update_min(&self.descr, min, &mut self.column_metrics.min_column_value); | ||
} | ||
if let Some(max) = max { | ||
update_max(&self.descr, max, &mut self.column_metrics.max_column_value); | ||
} | ||
|
||
// We can only set the distinct count if there are no other writes | ||
|
@@ -764,22 +747,23 @@ impl<'a, E: ColumnValueEncoder> GenericColumnWriter<'a, E> { | |
|
||
self.column_metrics.num_column_nulls += self.page_metrics.num_page_nulls; | ||
|
||
let page_statistics = if let (Some(min), Some(max)) = | ||
(values_data.min_value, values_data.max_value) | ||
{ | ||
// Update chunk level statistics | ||
update_min(&self.descr, &min, &mut self.column_metrics.min_column_value); | ||
update_max(&self.descr, &max, &mut self.column_metrics.max_column_value); | ||
|
||
(self.statistics_enabled == EnabledStatistics::Page).then_some(ValueStatistics::new( | ||
Some(min), | ||
Some(max), | ||
None, | ||
self.page_metrics.num_page_nulls, | ||
false, | ||
)) | ||
} else { | ||
None | ||
let page_statistics = match (values_data.min_value, values_data.max_value) { | ||
(Some(min), Some(max)) => { | ||
// Update chunk level statistics | ||
update_min(&self.descr, &min, &mut self.column_metrics.min_column_value); | ||
update_max(&self.descr, &max, &mut self.column_metrics.max_column_value); | ||
|
||
(self.statistics_enabled == EnabledStatistics::Page).then_some( | ||
ValueStatistics::new( | ||
Some(min), | ||
Some(max), | ||
None, | ||
self.page_metrics.num_page_nulls, | ||
false, | ||
), | ||
) | ||
} | ||
_ => None, | ||
}; | ||
|
||
// update column and offset index | ||
|
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.
This is the major change, rather than computing the chunk statistics here, we always compute statistics per-page, unless completely disabled, and just skip writing them to the page as per the change in #5181.
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.
Defiantly simpler than #5181 IMO. Having less places that do
update_min/update_max(...)
on the column's stats makes it much easier to follow.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.
Are there any performance implications of always computing the statistics even when they aren't written to the page?
Though it seems like if we are writing column chunk level statistics anyways we would have to calculate the min/max across all values anyways, so tracking per page shouldn't be any more expensive
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.
Potentially for byte arrays you will have additional allocations per page, where previously you would have them per chunk. In practice this is extremely unlikely to matter.