Skip to content

Commit 60aba1c

Browse files
committed
fix(cubesql): Pass null_equals_null through egraph
1 parent 7ac7a5b commit 60aba1c

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
@@ -13,19 +13,20 @@ use crate::{
1313
DimensionName, EmptyRelationDerivedSourceTableName, EmptyRelationIsWrappable,
1414
EmptyRelationProduceOneRow, FilterMemberMember, FilterMemberOp, FilterMemberValues,
1515
FilterOpOp, GroupingSetExprType, GroupingSetType, InListExprNegated,
16-
InSubqueryExprNegated, JoinJoinConstraint, JoinJoinType, JoinLeftOn, JoinRightOn,
17-
LikeExprEscapeChar, LikeExprLikeType, LikeExprNegated, LikeType, LimitFetch, LimitSkip,
18-
LiteralExprValue, LiteralMemberRelation, LiteralMemberValue, LogicalPlanLanguage,
19-
MeasureName, MemberErrorError, OrderAsc, OrderMember, OuterColumnExprColumn,
20-
OuterColumnExprDataType, ProjectionAlias, ProjectionSplit, QueryParamIndex,
21-
ScalarFunctionExprFun, ScalarUDFExprFun, ScalarVariableExprDataType,
22-
ScalarVariableExprVariable, SegmentMemberMember, SortExprAsc, SortExprNullsFirst,
23-
SubqueryTypes, TableScanFetch, TableScanProjection, TableScanSourceTableName,
24-
TableScanTableName, TableUDFExprFun, TimeDimensionDateRange, TimeDimensionGranularity,
25-
TimeDimensionName, TryCastExprDataType, UnionAlias, WindowFunctionExprFun,
26-
WindowFunctionExprWindowFrame, WrappedSelectAlias, WrappedSelectDistinct,
27-
WrappedSelectJoinJoinType, WrappedSelectLimit, WrappedSelectOffset,
28-
WrappedSelectSelectType, WrappedSelectType, WrappedSelectUngrouped,
16+
InSubqueryExprNegated, JoinJoinConstraint, JoinJoinType, JoinLeftOn,
17+
JoinNullEqualsNull, JoinRightOn, LikeExprEscapeChar, LikeExprLikeType, LikeExprNegated,
18+
LikeType, LimitFetch, LimitSkip, LiteralExprValue, LiteralMemberRelation,
19+
LiteralMemberValue, LogicalPlanLanguage, MeasureName, MemberErrorError, OrderAsc,
20+
OrderMember, OuterColumnExprColumn, OuterColumnExprDataType, ProjectionAlias,
21+
ProjectionSplit, QueryParamIndex, ScalarFunctionExprFun, ScalarUDFExprFun,
22+
ScalarVariableExprDataType, ScalarVariableExprVariable, SegmentMemberMember,
23+
SortExprAsc, SortExprNullsFirst, SubqueryTypes, TableScanFetch, TableScanProjection,
24+
TableScanSourceTableName, TableScanTableName, TableUDFExprFun, TimeDimensionDateRange,
25+
TimeDimensionGranularity, TimeDimensionName, TryCastExprDataType, UnionAlias,
26+
WindowFunctionExprFun, WindowFunctionExprWindowFrame, WrappedSelectAlias,
27+
WrappedSelectDistinct, WrappedSelectJoinJoinType, WrappedSelectLimit,
28+
WrappedSelectOffset, WrappedSelectSelectType, WrappedSelectType,
29+
WrappedSelectUngrouped,
2930
},
3031
CubeContext,
3132
},
@@ -662,13 +663,16 @@ impl LogicalPlanToLanguageConverter {
662663
let join_type = add_data_node!(self, node.join_type, JoinJoinType);
663664
let join_constraint =
664665
add_data_node!(self, node.join_constraint, JoinJoinConstraint);
666+
let null_equals_null =
667+
add_data_node!(self, node.null_equals_null, JoinNullEqualsNull);
665668
self.graph.add(LogicalPlanLanguage::Join([
666669
left,
667670
right,
668671
left_on,
669672
right_on,
670673
join_type,
671674
join_constraint,
675+
null_equals_null,
672676
]))
673677
}
674678
LogicalPlan::CrossJoin(node) => {
@@ -1390,15 +1394,16 @@ impl LanguageToLogicalPlanConverter {
13901394
&join_type,
13911395
)?);
13921396

1397+
let null_equals_null = match_data_node!(node_by_id, params[6], JoinNullEqualsNull);
1398+
13931399
LogicalPlan::Join(Join {
13941400
left,
13951401
right,
13961402
on: left_on.into_iter().zip_eq(right_on.into_iter()).collect(),
13971403
join_type,
13981404
join_constraint,
13991405
schema,
1400-
// TODO: Pass to Graph
1401-
null_equals_null: true,
1406+
null_equals_null,
14021407
})
14031408
}
14041409
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
@@ -105,6 +105,7 @@ crate::plan_to_language! {
105105
join_type: JoinType,
106106
join_constraint: JoinConstraint,
107107
schema: DFSchemaRef,
108+
null_equals_null: bool,
108109
},
109110
CrossJoin {
110111
left: Arc<LogicalPlan>,
@@ -1743,6 +1744,7 @@ fn join(
17431744
right_on: impl Display,
17441745
join_type: impl Display,
17451746
join_constraint: impl Display,
1747+
null_equals_null: impl Display,
17461748
) -> String {
17471749
let join_type_prefix = if join_type.to_string().starts_with("?") {
17481750
""
@@ -1755,7 +1757,7 @@ fn join(
17551757
"JoinJoinConstraint:"
17561758
};
17571759
format!(
1758-
"(Join {} {} {} {} {}{} {}{})",
1760+
"(Join {} {} {} {} {}{} {}{} {})",
17591761
left,
17601762
right,
17611763
left_on,
@@ -1764,6 +1766,7 @@ fn join(
17641766
join_type,
17651767
join_constraint_prefix,
17661768
join_constraint,
1769+
null_equals_null,
17671770
)
17681771
}
17691772

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ impl RewriteRules for MemberRules {
384384
"?right_on",
385385
"?join_type",
386386
"?join_constraint",
387+
"?null_equals_null",
387388
),
388389
cross_join(
389390
cube_scan(

0 commit comments

Comments
 (0)