Skip to content

Conversation

@jackwener
Copy link
Member

@jackwener jackwener commented Nov 18, 2022

Which issue does this PR close?

Closes #4270
Part of #4267

reimplement eliminate_outer_join to avoid to use global-state.

In new implementation, we just depends only on the shape of the subtree.

Rationale for this change

We don't have to worry about the filter not being above the Join.

Because this rule will cooperate with filter_push_down. If a predicate which can eliminate outer exist, it will be pushdown and stop above an outer-join.

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added logical-expr Logical plan and expressions optimizer Optimizer rules labels Nov 18, 2022
}
}

/// Attempt to eliminate outer joins to inner joins.
Copy link
Contributor

Choose a reason for hiding this comment

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

Question from a beginner:

Can a JOIN be always optimized to the INNER JOIN?
For example:
for a query

select ... from a full join b where a.xx = 100

we could only optimize it to a RIGHT JOIN.

Copy link
Member Author

Choose a reason for hiding this comment

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

You can see fn eliminate_outer()
Your example, this rule can do.
We can eliminate Full -> ROJ/LOJ/Inner

_optimizer_config,
)?),
)?))
pub fn eliminate_outer(
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for eliminating the duplication

@alamb alamb merged commit 502b7e3 into apache:master Nov 23, 2022
@ursabot
Copy link

ursabot commented Nov 23, 2022

Benchmark runs are scheduled for baseline = e817d75 and contender = 502b7e3. 502b7e3 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

@alamb
Copy link
Contributor

alamb commented Nov 23, 2022

Filed a follow on PR to add some docstrings: #4343

@alamb
Copy link
Contributor

alamb commented Nov 23, 2022

Sorry for the delay in reviewing @jackwener -- the PRs are flowing fast an furious this week

@jackwener jackwener deleted the eliminate_outer branch November 24, 2022 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logical-expr Logical plan and expressions optimizer Optimizer rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

reimplement reduce_outer_join

4 participants