Skip to content

Commit da2c747

Browse files
committed
feat(cubesql): Support complex join conditions for grouped joins
* Support COALESCE + IS NOT NULL join condition * Support IS NOT DISTINCT join condition * Support expression on top of columns, like CAST
1 parent dabbc7f commit da2c747

File tree

4 files changed

+857
-11
lines changed

4 files changed

+857
-11
lines changed

rust/cubesql/cubesql/src/compile/rewrite/cost.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ impl BestCubePlan {
122122
LogicalPlanLanguage::ProjectionSplitPushDownReplacer(_) => 1,
123123
LogicalPlanLanguage::ProjectionSplitPullUpReplacer(_) => 1,
124124
LogicalPlanLanguage::QueryParam(_) => 1,
125+
LogicalPlanLanguage::JoinCheckStage(_) => 1,
126+
LogicalPlanLanguage::JoinCheckPushDown(_) => 1,
127+
LogicalPlanLanguage::JoinCheckPullUp(_) => 1,
125128
// Not really replacers but those should be deemed as mandatory rewrites and as soon as
126129
// there's always rewrite rule it's fine to have replacer cost.
127130
// Needs to be added as alias rewrite always more expensive than original function.

rust/cubesql/cubesql/src/compile/rewrite/mod.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,19 @@ crate::plan_to_language! {
514514
QueryParam {
515515
index: usize,
516516
},
517+
JoinCheckStage {
518+
expr: Arc<Expr>,
519+
},
520+
JoinCheckPushDown {
521+
expr: Arc<Expr>,
522+
left_input: Arc<LogicalPlan>,
523+
right_input: Arc<LogicalPlan>,
524+
},
525+
JoinCheckPullUp {
526+
expr: Arc<Expr>,
527+
left_input: Arc<LogicalPlan>,
528+
right_input: Arc<LogicalPlan>,
529+
},
517530
}
518531
}
519532

@@ -2152,6 +2165,18 @@ fn distinct(input: impl Display) -> String {
21522165
format!("(Distinct {})", input)
21532166
}
21542167

2168+
fn join_check_stage(expr: impl Display) -> String {
2169+
format!("(JoinCheckStage {expr})")
2170+
}
2171+
2172+
fn join_check_push_down(expr: impl Display, left: impl Display, right: impl Display) -> String {
2173+
format!("(JoinCheckPushDown {expr} {left} {right})")
2174+
}
2175+
2176+
fn join_check_pull_up(expr: impl Display, left: impl Display, right: impl Display) -> String {
2177+
format!("(JoinCheckPullUp {expr} {left} {right})")
2178+
}
2179+
21552180
pub fn original_expr_name(egraph: &CubeEGraph, id: Id) -> Option<String> {
21562181
egraph[id]
21572182
.data

0 commit comments

Comments
 (0)