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

Add alias check for equijoin in from_plan #4755

Merged
merged 4 commits into from
Dec 29, 2022
Merged

Conversation

ygf11
Copy link
Contributor

@ygf11 ygf11 commented Dec 28, 2022

Which issue does this PR close?

Closes #4754.

Rationale for this change

The SimplifyExpressions will give an alias to the result if the new name and old name is not same. For the rebuild of equijoin in from_plan, we assume the simplified result of a binary equality expression is still a binary equality expression, this is not correct and may result in the failure of SimplifyExpressions rule.

What changes are included in this PR?

Add alias check for equijoin in from_plan.

Are these changes tested?

Yes.

Are there any user-facing changes?

@github-actions github-actions bot added core Core DataFusion crate logical-expr Logical plan and expressions optimizer Optimizer rules labels Dec 28, 2022
" RepartitionExec: partitioning=Hash([Column { name: \"t2.t2_id + Int64(1)\", index: 1 }], 2)",
" ProjectionExec: expr=[t2_id@0 as t2_id, t2_id@0 + CAST(1 AS UInt32) as t2.t2_id + Int64(1)]",
" RepartitionExec: partitioning=Hash([Column { name: \"t2.t2_id + UInt32(1)\", index: 1 }], 2)",
" ProjectionExec: expr=[t2_id@0 as t2_id, t2_id@0 + 1 as t2.t2_id + UInt32(1)]",
" RepartitionExec: partitioning=RoundRobinBatch(2)",
" MemoryExec: partitions=1, partition_sizes=[1]",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The SimplifyExpressions rule failed in this test case before, take effect now.

Other test cases modified in this pr also take effect.

@ygf11 ygf11 marked this pull request as ready for review December 28, 2022 09:06
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 like an improvement to me

@@ -586,6 +586,12 @@ pub fn from_plan(
// The preceding part of expr is equi-exprs,
// and the struct of each equi-expr is like `left-expr = right-expr`.
let new_on:Vec<(Expr,Expr)> = expr.iter().take(equi_expr_count).map(|equi_expr| {
// SimplifyExpression rule may add alias to the equi_expr.
let equi_expr = match equi_expr {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can not call the above unalias, because it is in the optimizer crate and from_plan is in the expr crate.

I found another unalias in the expr crate, and it seems enough to this pr.
https://github.com/apache/arrow-datafusion/blob/41c72cf515389e90c20433dbcc4116a59016a15b/datafusion/expr/src/expr.rs#L711-L717

@alamb
Copy link
Contributor

alamb commented Dec 28, 2022

Thank you @ygf11

@ursabot
Copy link

ursabot commented Dec 29, 2022

Benchmark runs are scheduled for baseline = d4934e8 and contender = 310e871. 310e871 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

@ygf11 ygf11 deleted the simplify-alias branch December 30, 2022 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate logical-expr Logical plan and expressions optimizer Optimizer rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SimplifyExpressions will fail when rebuild equijoin with alias
3 participants