-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Update parquet page pruning code to use the StatisticsExtractor
#11483
Merged
alamb
merged 7 commits into
apache:main
from
alamb:alamb/prune_pages_statistics_converter
Jul 18, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
62bacdd
Update the parquet code prune_pages_in_one_row_group to use the `Stat…
alamb cc6fe99
fix doc
alamb 8be0e10
Merge remote-tracking branch 'apache/main' into alamb/prune_pages_sta…
alamb 93fd08c
Merge remote-tracking branch 'apache/main' into alamb/prune_pages_sta…
alamb 79ecd80
Increase evaluation error counter if error determining data page row …
alamb 3024a8a
Merge remote-tracking branch 'apache/main' into alamb/prune_pages_sta…
alamb 7886e29
Optimize `single_column`
alamb 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 |
---|---|---|
|
@@ -24,7 +24,7 @@ use std::sync::Arc; | |
use crate::datasource::listing::PartitionedFile; | ||
use crate::datasource::physical_plan::file_stream::FileStream; | ||
use crate::datasource::physical_plan::{ | ||
parquet::page_filter::PagePruningPredicate, DisplayAs, FileGroupPartitioner, | ||
parquet::page_filter::PagePruningAccessPlanFilter, DisplayAs, FileGroupPartitioner, | ||
FileScanConfig, | ||
}; | ||
use crate::{ | ||
|
@@ -39,13 +39,11 @@ use crate::{ | |
}, | ||
}; | ||
|
||
use arrow::datatypes::{DataType, SchemaRef}; | ||
use arrow::datatypes::SchemaRef; | ||
use datafusion_physical_expr::{EquivalenceProperties, LexOrdering, PhysicalExpr}; | ||
|
||
use itertools::Itertools; | ||
use log::debug; | ||
use parquet::basic::{ConvertedType, LogicalType}; | ||
use parquet::schema::types::ColumnDescriptor; | ||
|
||
mod access_plan; | ||
mod metrics; | ||
|
@@ -225,7 +223,7 @@ pub struct ParquetExec { | |
/// Optional predicate for pruning row groups (derived from `predicate`) | ||
pruning_predicate: Option<Arc<PruningPredicate>>, | ||
/// Optional predicate for pruning pages (derived from `predicate`) | ||
page_pruning_predicate: Option<Arc<PagePruningPredicate>>, | ||
page_pruning_predicate: Option<Arc<PagePruningAccessPlanFilter>>, | ||
/// Optional hint for the size of the parquet metadata | ||
metadata_size_hint: Option<usize>, | ||
/// Optional user defined parquet file reader factory | ||
|
@@ -381,19 +379,12 @@ impl ParquetExecBuilder { | |
}) | ||
.filter(|p| !p.always_true()); | ||
|
||
let page_pruning_predicate = predicate.as_ref().and_then(|predicate_expr| { | ||
match PagePruningPredicate::try_new(predicate_expr, file_schema.clone()) { | ||
Ok(pruning_predicate) => Some(Arc::new(pruning_predicate)), | ||
Err(e) => { | ||
debug!( | ||
"Could not create page pruning predicate for '{:?}': {}", | ||
pruning_predicate, e | ||
); | ||
predicate_creation_errors.add(1); | ||
None | ||
} | ||
} | ||
}); | ||
let page_pruning_predicate = predicate | ||
.as_ref() | ||
.map(|predicate_expr| { | ||
PagePruningAccessPlanFilter::new(predicate_expr, file_schema.clone()) | ||
}) | ||
.map(Arc::new); | ||
|
||
let (projected_schema, projected_statistics, projected_output_ordering) = | ||
base_config.project(); | ||
|
@@ -739,7 +730,7 @@ impl ExecutionPlan for ParquetExec { | |
|
||
fn should_enable_page_index( | ||
enable_page_index: bool, | ||
page_pruning_predicate: &Option<Arc<PagePruningPredicate>>, | ||
page_pruning_predicate: &Option<Arc<PagePruningAccessPlanFilter>>, | ||
) -> bool { | ||
enable_page_index | ||
&& page_pruning_predicate.is_some() | ||
|
@@ -749,26 +740,6 @@ fn should_enable_page_index( | |
.unwrap_or(false) | ||
} | ||
|
||
// Convert parquet column schema to arrow data type, and just consider the | ||
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 is now handled entirely in the StatisticsConverter |
||
// decimal data type. | ||
pub(crate) fn parquet_to_arrow_decimal_type( | ||
parquet_column: &ColumnDescriptor, | ||
) -> Option<DataType> { | ||
let type_ptr = parquet_column.self_type_ptr(); | ||
match type_ptr.get_basic_info().logical_type() { | ||
Some(LogicalType::Decimal { scale, precision }) => { | ||
Some(DataType::Decimal128(precision as u8, scale as i8)) | ||
} | ||
_ => match type_ptr.get_basic_info().converted_type() { | ||
ConvertedType::DECIMAL => Some(DataType::Decimal128( | ||
type_ptr.get_precision() as u8, | ||
type_ptr.get_scale() as i8, | ||
)), | ||
_ => None, | ||
}, | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
// See also `parquet_exec` integration test | ||
|
@@ -798,7 +769,7 @@ mod tests { | |
}; | ||
use arrow::datatypes::{Field, Schema, SchemaBuilder}; | ||
use arrow::record_batch::RecordBatch; | ||
use arrow_schema::Fields; | ||
use arrow_schema::{DataType, Fields}; | ||
use datafusion_common::{assert_contains, ScalarValue}; | ||
use datafusion_expr::{col, lit, when, Expr}; | ||
use datafusion_physical_expr::planner::logical2physical; | ||
|
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
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 renamed this to be consistent with what this is -- it isn't a pruning predicate per se