Skip to content

Commit

Permalink
add distribution optimization for merge into join
Browse files Browse the repository at this point in the history
  • Loading branch information
JackTan25 committed Oct 13, 2023
1 parent 46a8d89 commit b2c4e34
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/query/sql/src/planner/optimizer/optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use crate::optimizer::SExpr;
use crate::optimizer::DEFAULT_REWRITE_RULES;
use crate::optimizer::RESIDUAL_RULES;
use crate::plans::CopyIntoLocationPlan;
use crate::plans::MergeInto;
use crate::plans::Plan;
use crate::IndexType;
use crate::MetadataRef;
Expand Down Expand Up @@ -123,6 +124,24 @@ pub fn optimize(
);
Ok(Plan::CopyIntoTable(plan))
}
Plan::MergeInto(plan) => {
// try to optimize distributed join
if opt_ctx.config.enable_distributed_optimization
&& ctx.get_settings().get_enable_distributed_merge_into()?
{
// Todo(JackTan25): We should use optimizer to make a decision to use
// left join and right join
// input is a Join_SExpr
let optimized_distributed_join_sexpr =
optimize_distributed_query(ctx.clone(), &*plan.input)?;
Ok(Plan::MergeInto(Box::new(MergeInto {
input: Box::new(optimized_distributed_join_sexpr),
..*plan
})))
} else {
Ok(Plan::MergeInto(plan))
}
}
// Passthrough statements.
_ => Ok(plan),
}
Expand Down

0 comments on commit b2c4e34

Please sign in to comment.