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

refactor: parquet pruning simplifications #5386

Merged
merged 2 commits into from
Feb 24, 2023

Conversation

crepererum
Copy link
Contributor

Which issue does this PR close?

Prep work for #4695.

Rationale for this change

Makes the actual change in #4695 easier.

What changes are included in this PR?

Internal improvements.

Are these changes tested?

Existing tests pass, no function changes.

Are there any user-facing changes?

-

@github-actions github-actions bot added the core Core DataFusion crate label Feb 24, 2023
@crepererum
Copy link
Contributor Author

crepererum commented Feb 24, 2023

I am pretty sure that this test breakage is unrelated, seems flaky to me:

[window.slt] Running query: "select 1 - lag(amount, 1) over (order by idx) as column1 from (values ('a', 1, 100), ('a', 2, 150)) as t (col1, idx, amount)
---"
Error: query result mismatch:
[SQL] select 1 - lag(amount, 1) over (order by idx) as column1 from (values ('a', 1, 100), ('a', 2, 150)) as t (col1, idx, amount)
---
[Diff] (-expected|+actual)
-   NULL
-   -99
+   -99
+   NULL
at tests/sqllogictests/test_files/window.slt:414

error: test failed, to rerun pass `-p datafusion --test sqllogictests`

Copy link
Member

@waynexia waynexia left a comment

Choose a reason for hiding this comment

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

Nice simplification, LGTM 👍

/// Returns number of unique columns.
pub(crate) fn n_columns(&self) -> usize {
self.iter()
.map(|(c, _s, _f)| c)
Copy link
Contributor

Choose a reason for hiding this comment

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

More descriptive variable names would help readability here.

.unwrap_or(unhandled);
return Ok(expr);
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, so this was always returning Ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

match PruningPredicate::try_new(predicate.clone(), schema.clone()) {
Ok(p)
if (!p.allways_true())
&& (p.required_columns().n_columns() < 2) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a behavior change for n_columns() == 0. Based on:

    pub fn allways_true(&self) -> bool {
        self.predicate_expr
            .as_any()
            .downcast_ref::<Literal>()
            .map(|l| matches!(l.value(), ScalarValue::Boolean(Some(true))))
            .unwrap_or_default()
    }

I ran the test suite, panicing if n_columns() == 0 and I can't get it to happen, so I guess it LGTM.
I assume that would default to false, in which case I think we'd want to return a None here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we skip the predicate if we don't refer to any column. However you might be right (at least this is how I read your comment) that we need additional test coverage for a "constant" predicate (i.e. one that doesn't reference any column). I'll check next week if such a test exists and if not, add one.

@avantgardnerio avantgardnerio merged commit 1841736 into apache:main Feb 24, 2023
@ursabot
Copy link

ursabot commented Feb 24, 2023

Benchmark runs are scheduled for baseline = 7224901 and contender = 1841736. 1841736 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.

4 participants