Skip to content
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

Eagerly construct PagePruningPredicate #4713

Merged

Conversation

tustvold
Copy link
Contributor

Which issue does this PR close?

Part of #4693

Rationale for this change

Eagerly constructing the PagePruningPredicate not only saves cycles, but allows it to occur when ExecutionProps is in scope. A future PR will update PruningPredicate to require this to resolve #4693

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the core Core DataFusion crate label Dec 22, 2022
}

let groups = file_metadata.row_groups();
/// Returns a [`RowSelection`] for the given file
pub fn prune(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -203,35 +220,6 @@ fn combine_multi_col_selection(row_selections: Vec<Vec<RowSelector>>) -> RowSele
.unwrap()
}

// Extract single col pruningPredicate from input predicate for evaluating page Index.
fn extract_page_index_push_down_predicates(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is reworked into PagePruningPredicate::try_new

.filter_map(|predicate| match predicate.to_columns() {
Ok(columns) if columns.len() == 1 => {
match PruningPredicate::try_new(predicate.clone(), schema.clone()) {
Ok(p) if !p.allways_true() => Some(Ok(p)),
Copy link
Contributor Author

@tustvold tustvold Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is important we filter these out as they cause issues for the pruning logic below as they no longer refer to a single column. Previously this was being as a side-effect of the filtering when constructing the row group pruning predicate

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't they refer to a single column? isn't this branch protected by a match guard if columns.len() == 1?

Copy link
Contributor Author

@tustvold tustvold Dec 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the expression gets simplified down to true and therefore now refers to no columns 😅

I suspect there may be a bug here, but this at least preserves the existing behaviour

@tustvold tustvold requested a review from alamb December 23, 2022 11:01
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me -- thanks @tustvold

cc @Ted-Jiang @thinkharderdev

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: {}", e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be worth including the predicate_expr in this message too

Suggested change
debug!("Could not create page pruning predicate for: {}", e);
debug!("Could not create page pruning predicate for '{}': {}", predicate_expr, e);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proposed change in #4736

.filter_map(|predicate| match predicate.to_columns() {
Ok(columns) if columns.len() == 1 => {
match PruningPredicate::try_new(predicate.clone(), schema.clone()) {
Ok(p) if !p.allways_true() => Some(Ok(p)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't they refer to a single column? isn't this branch protected by a match guard if columns.len() == 1?

@alamb alamb merged commit fe3f018 into apache:master Dec 26, 2022
@ursabot
Copy link

ursabot commented Dec 26, 2022

Benchmark runs are scheduled for baseline = 2f5b25d and contender = fe3f018. fe3f018 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PruningPredicate Different Evaluation Context from Query
4 participants