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

Support semi join #470

Merged
merged 10 commits into from
Jun 2, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions datafusion/src/optimizer/hash_build_probe_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ fn should_swap_join_order(left: &LogicalPlan, right: &LogicalPlan) -> bool {
}
}

fn supports_swap(join_type: JoinType) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

match join_type {
JoinType::Inner | JoinType::Left | JoinType::Right | JoinType::Full => true,
JoinType::Semi => false,
}
}

impl OptimizerRule for HashBuildProbeOrder {
fn name(&self) -> &str {
"hash_build_probe_order"
Expand All @@ -125,10 +132,10 @@ impl OptimizerRule for HashBuildProbeOrder {
on,
join_type,
schema,
} if *join_type != JoinType::Semi => {
} => {
let left = self.optimize(left, execution_props)?;
let right = self.optimize(right, execution_props)?;
if should_swap_join_order(&left, &right) {
if should_swap_join_order(&left, &right) && supports_swap(*join_type) {
// Swap left and right, change join type and (equi-)join key order
Ok(LogicalPlan::Join {
left: Arc::new(right),
Expand Down Expand Up @@ -187,7 +194,6 @@ impl OptimizerRule for HashBuildProbeOrder {
| LogicalPlan::CreateExternalTable { .. }
| LogicalPlan::Explain { .. }
| LogicalPlan::Union { .. }
| LogicalPlan::Join { .. }
| LogicalPlan::Extension { .. } => {
let expr = plan.expressions();

Expand Down