Skip to content

Commit f7b512f

Browse files
committed
fix(cubesql): Pass null_equals_null through egraph
1 parent 9482807 commit f7b512f

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

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

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,20 @@ use crate::{
1616
DimensionName, EmptyRelationDerivedSourceTableName, EmptyRelationIsWrappable,
1717
EmptyRelationProduceOneRow, FilterMemberMember, FilterMemberOp, FilterMemberValues,
1818
FilterOpOp, GroupingSetExprType, GroupingSetType, InListExprNegated,
19-
InSubqueryExprNegated, JoinJoinConstraint, JoinJoinType, JoinLeftOn, JoinRightOn,
20-
LikeExprEscapeChar, LikeExprLikeType, LikeExprNegated, LikeType, LimitFetch, LimitSkip,
21-
LiteralExprValue, LiteralMemberRelation, LiteralMemberValue, LogicalPlanLanguage,
22-
MeasureName, MemberErrorError, OrderAsc, OrderMember, OuterColumnExprColumn,
23-
OuterColumnExprDataType, ProjectionAlias, ProjectionSplit, QueryParamIndex,
24-
ScalarFunctionExprFun, ScalarUDFExprFun, ScalarVariableExprDataType,
25-
ScalarVariableExprVariable, SegmentMemberMember, SortExprAsc, SortExprNullsFirst,
26-
SubqueryTypes, TableScanFetch, TableScanProjection, TableScanSourceTableName,
27-
TableScanTableName, TableUDFExprFun, TimeDimensionDateRange, TimeDimensionGranularity,
28-
TimeDimensionName, TryCastExprDataType, UnionAlias, WindowFunctionExprFun,
29-
WindowFunctionExprWindowFrame, WrappedSelectAlias, WrappedSelectDistinct,
30-
WrappedSelectJoinJoinType, WrappedSelectLimit, WrappedSelectOffset,
31-
WrappedSelectSelectType, WrappedSelectType, WrappedSelectUngrouped,
19+
InSubqueryExprNegated, JoinJoinConstraint, JoinJoinType, JoinLeftOn,
20+
JoinNullEqualsNull, JoinRightOn, LikeExprEscapeChar, LikeExprLikeType, LikeExprNegated,
21+
LikeType, LimitFetch, LimitSkip, LiteralExprValue, LiteralMemberRelation,
22+
LiteralMemberValue, LogicalPlanLanguage, MeasureName, MemberErrorError, OrderAsc,
23+
OrderMember, OuterColumnExprColumn, OuterColumnExprDataType, ProjectionAlias,
24+
ProjectionSplit, QueryParamIndex, ScalarFunctionExprFun, ScalarUDFExprFun,
25+
ScalarVariableExprDataType, ScalarVariableExprVariable, SegmentMemberMember,
26+
SortExprAsc, SortExprNullsFirst, SubqueryTypes, TableScanFetch, TableScanProjection,
27+
TableScanSourceTableName, TableScanTableName, TableUDFExprFun, TimeDimensionDateRange,
28+
TimeDimensionGranularity, TimeDimensionName, TryCastExprDataType, UnionAlias,
29+
WindowFunctionExprFun, WindowFunctionExprWindowFrame, WrappedSelectAlias,
30+
WrappedSelectDistinct, WrappedSelectJoinJoinType, WrappedSelectLimit,
31+
WrappedSelectOffset, WrappedSelectSelectType, WrappedSelectType,
32+
WrappedSelectUngrouped,
3233
},
3334
CubeContext,
3435
},
@@ -654,13 +655,16 @@ impl LogicalPlanToLanguageConverter {
654655
let join_type = add_data_node!(self, node.join_type, JoinJoinType);
655656
let join_constraint =
656657
add_data_node!(self, node.join_constraint, JoinJoinConstraint);
658+
let null_equals_null =
659+
add_data_node!(self, node.null_equals_null, JoinNullEqualsNull);
657660
self.graph.add(LogicalPlanLanguage::Join([
658661
left,
659662
right,
660663
left_on,
661664
right_on,
662665
join_type,
663666
join_constraint,
667+
null_equals_null,
664668
]))
665669
}
666670
LogicalPlan::CrossJoin(node) => {
@@ -1382,15 +1386,16 @@ impl LanguageToLogicalPlanConverter {
13821386
&join_type,
13831387
)?);
13841388

1389+
let null_equals_null = match_data_node!(node_by_id, params[6], JoinNullEqualsNull);
1390+
13851391
LogicalPlan::Join(Join {
13861392
left,
13871393
right,
13881394
on: left_on.into_iter().zip_eq(right_on.into_iter()).collect(),
13891395
join_type,
13901396
join_constraint,
13911397
schema,
1392-
// TODO: Pass to Graph
1393-
null_equals_null: true,
1398+
null_equals_null,
13941399
})
13951400
}
13961401
LogicalPlanLanguage::CrossJoin(params) => {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ crate::plan_to_language! {
106106
join_type: JoinType,
107107
join_constraint: JoinConstraint,
108108
schema: DFSchemaRef,
109+
null_equals_null: bool,
109110
},
110111
CrossJoin {
111112
left: Arc<LogicalPlan>,
@@ -1728,6 +1729,7 @@ fn join(
17281729
right_on: impl Display,
17291730
join_type: impl Display,
17301731
join_constraint: impl Display,
1732+
null_equals_null: impl Display,
17311733
) -> String {
17321734
let join_type_prefix = if join_type.to_string().starts_with("?") {
17331735
""
@@ -1740,7 +1742,7 @@ fn join(
17401742
"JoinJoinConstraint:"
17411743
};
17421744
format!(
1743-
"(Join {} {} {} {} {}{} {}{})",
1745+
"(Join {} {} {} {} {}{} {}{} {})",
17441746
left,
17451747
right,
17461748
left_on,
@@ -1749,6 +1751,7 @@ fn join(
17491751
join_type,
17501752
join_constraint_prefix,
17511753
join_constraint,
1754+
null_equals_null,
17521755
)
17531756
}
17541757

rust/cubesql/cubesql/src/compile/rewrite/rules/members.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ impl RewriteRules for MemberRules {
382382
"?right_on",
383383
"?join_type",
384384
"?join_constraint",
385+
"?null_equals_null",
385386
),
386387
cross_join(
387388
cube_scan(

0 commit comments

Comments
 (0)