Skip to content

Conversation

@kmitchener
Copy link
Contributor

Which issue does this PR close?

Closes #3402 .

Rationale for this change

Allows the plan to be further optimized and simplified, resulting in better plans.

What changes are included in this PR?

Are there any user-facing changes?

@github-actions github-actions bot added core Core DataFusion crate optimizer Optimizer rules labels Sep 8, 2022
" CrossJoin: [l_partkey:Int64, l_quantity:Float64, p_partkey:Int64, p_brand:Utf8, p_size:Int32]",
" TableScan: lineitem projection=[l_partkey, l_quantity] [l_partkey:Int64, l_quantity:Float64]",
" TableScan: part projection=[p_partkey, p_brand, p_size] [p_partkey:Int64, p_brand:Utf8, p_size:Int32]",
" Filter: #part.p_size >= Int32(1) [p_partkey:Int64, p_brand:Utf8, p_size:Int32]",
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 great optimization. Next goal is to get it to see that part.p_size <= 15 as well :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oof, that would be excellent. For another PR if someone doesn't beat me to it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or maybe sooner .. looks like the order of the projections changes between runs, which is causing the test failure here.

@codecov-commenter
Copy link

Codecov Report

Merging #3404 (82bdb61) into master (e6378f4) will decrease coverage by 0.09%.
The diff coverage is 83.33%.

@@            Coverage Diff             @@
##           master    #3404      +/-   ##
==========================================
- Coverage   85.58%   85.49%   -0.10%     
==========================================
  Files         296      296              
  Lines       54252    54328      +76     
==========================================
+ Hits        46432    46446      +14     
- Misses       7820     7882      +62     
Impacted Files Coverage Δ
datafusion/core/tests/sql/predicates.rs 100.00% <ø> (ø)
datafusion/optimizer/src/simplify_expressions.rs 82.83% <82.85%> (-0.24%) ⬇️
datafusion/core/tests/sql/select.rs 99.77% <100.00%> (ø)
benchmarks/src/bin/tpch.rs 37.59% <0.00%> (-3.56%) ⬇️
datafusion/physical-expr/src/planner.rs 93.54% <0.00%> (-0.65%) ⬇️
datafusion/proto/src/to_proto.rs 48.25% <0.00%> (-0.64%) ⬇️
datafusion/core/src/physical_plan/planner.rs 76.87% <0.00%> (-0.58%) ⬇️
datafusion/proto/src/logical_plan.rs 17.46% <0.00%> (-0.24%) ⬇️
datafusion/expr/src/logical_plan/plan.rs 77.02% <0.00%> (-0.17%) ⬇️
... and 8 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@kmitchener
Copy link
Contributor Author

Putting in draft until I can figure out this bug that's triggered by this change. :/

@kmitchener kmitchener marked this pull request as draft September 8, 2022 21:56
@Dandandan
Copy link
Contributor

Putting in draft until I can figure out this bug that's triggered by this change. :/

Commonly, a hash table or hash set generates these kind of random results. Maybe an optimization rule uses this, where this could be fixed (I e. producing in order of appearance or sorting the results).
You could explain verbose to see which rule this is?

@kmitchener
Copy link
Contributor Author

@Dandandan good advice, thank you :)

@kmitchener kmitchener marked this pull request as ready for review September 9, 2022 11:59
Copy link
Contributor

@Dandandan Dandandan left a comment

Choose a reason for hiding this comment

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

Looks great!

Copy link
Member

@xudong963 xudong963 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @kmitchener . I believe the optimization can bring more potential benefits 👍

@xudong963 xudong963 merged commit 73447b5 into apache:master Sep 9, 2022
@ursabot
Copy link

ursabot commented Sep 9, 2022

Benchmark runs are scheduled for baseline = eaf1d46 and contender = 73447b5. 73447b5 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

@kmitchener kmitchener deleted the simplify-between-expr branch September 9, 2022 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate optimizer Optimizer rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add simplification for between expression during logical plan optimization

5 participants