Skip to content

Commit

Permalink
fix(cubesql): Pass null_equals_null through egraph (#8776)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcheshkov authored Nov 11, 2024
1 parent 9482807 commit e02f612
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
35 changes: 20 additions & 15 deletions rust/cubesql/cubesql/src/compile/rewrite/converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ use crate::{
DimensionName, EmptyRelationDerivedSourceTableName, EmptyRelationIsWrappable,
EmptyRelationProduceOneRow, FilterMemberMember, FilterMemberOp, FilterMemberValues,
FilterOpOp, GroupingSetExprType, GroupingSetType, InListExprNegated,
InSubqueryExprNegated, JoinJoinConstraint, JoinJoinType, JoinLeftOn, JoinRightOn,
LikeExprEscapeChar, LikeExprLikeType, LikeExprNegated, LikeType, LimitFetch, LimitSkip,
LiteralExprValue, LiteralMemberRelation, LiteralMemberValue, LogicalPlanLanguage,
MeasureName, MemberErrorError, OrderAsc, OrderMember, OuterColumnExprColumn,
OuterColumnExprDataType, ProjectionAlias, ProjectionSplit, QueryParamIndex,
ScalarFunctionExprFun, ScalarUDFExprFun, ScalarVariableExprDataType,
ScalarVariableExprVariable, SegmentMemberMember, SortExprAsc, SortExprNullsFirst,
SubqueryTypes, TableScanFetch, TableScanProjection, TableScanSourceTableName,
TableScanTableName, TableUDFExprFun, TimeDimensionDateRange, TimeDimensionGranularity,
TimeDimensionName, TryCastExprDataType, UnionAlias, WindowFunctionExprFun,
WindowFunctionExprWindowFrame, WrappedSelectAlias, WrappedSelectDistinct,
WrappedSelectJoinJoinType, WrappedSelectLimit, WrappedSelectOffset,
WrappedSelectSelectType, WrappedSelectType, WrappedSelectUngrouped,
InSubqueryExprNegated, JoinJoinConstraint, JoinJoinType, JoinLeftOn,
JoinNullEqualsNull, JoinRightOn, LikeExprEscapeChar, LikeExprLikeType, LikeExprNegated,
LikeType, LimitFetch, LimitSkip, LiteralExprValue, LiteralMemberRelation,
LiteralMemberValue, LogicalPlanLanguage, MeasureName, MemberErrorError, OrderAsc,
OrderMember, OuterColumnExprColumn, OuterColumnExprDataType, ProjectionAlias,
ProjectionSplit, QueryParamIndex, ScalarFunctionExprFun, ScalarUDFExprFun,
ScalarVariableExprDataType, ScalarVariableExprVariable, SegmentMemberMember,
SortExprAsc, SortExprNullsFirst, SubqueryTypes, TableScanFetch, TableScanProjection,
TableScanSourceTableName, TableScanTableName, TableUDFExprFun, TimeDimensionDateRange,
TimeDimensionGranularity, TimeDimensionName, TryCastExprDataType, UnionAlias,
WindowFunctionExprFun, WindowFunctionExprWindowFrame, WrappedSelectAlias,
WrappedSelectDistinct, WrappedSelectJoinJoinType, WrappedSelectLimit,
WrappedSelectOffset, WrappedSelectSelectType, WrappedSelectType,
WrappedSelectUngrouped,
},
CubeContext,
},
Expand Down Expand Up @@ -654,13 +655,16 @@ impl LogicalPlanToLanguageConverter {
let join_type = add_data_node!(self, node.join_type, JoinJoinType);
let join_constraint =
add_data_node!(self, node.join_constraint, JoinJoinConstraint);
let null_equals_null =
add_data_node!(self, node.null_equals_null, JoinNullEqualsNull);
self.graph.add(LogicalPlanLanguage::Join([
left,
right,
left_on,
right_on,
join_type,
join_constraint,
null_equals_null,
]))
}
LogicalPlan::CrossJoin(node) => {
Expand Down Expand Up @@ -1382,15 +1386,16 @@ impl LanguageToLogicalPlanConverter {
&join_type,
)?);

let null_equals_null = match_data_node!(node_by_id, params[6], JoinNullEqualsNull);

LogicalPlan::Join(Join {
left,
right,
on: left_on.into_iter().zip_eq(right_on.into_iter()).collect(),
join_type,
join_constraint,
schema,
// TODO: Pass to Graph
null_equals_null: true,
null_equals_null,
})
}
LogicalPlanLanguage::CrossJoin(params) => {
Expand Down
5 changes: 4 additions & 1 deletion rust/cubesql/cubesql/src/compile/rewrite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ crate::plan_to_language! {
join_type: JoinType,
join_constraint: JoinConstraint,
schema: DFSchemaRef,
null_equals_null: bool,
},
CrossJoin {
left: Arc<LogicalPlan>,
Expand Down Expand Up @@ -1728,6 +1729,7 @@ fn join(
right_on: impl Display,
join_type: impl Display,
join_constraint: impl Display,
null_equals_null: impl Display,
) -> String {
let join_type_prefix = if join_type.to_string().starts_with("?") {
""
Expand All @@ -1740,7 +1742,7 @@ fn join(
"JoinJoinConstraint:"
};
format!(
"(Join {} {} {} {} {}{} {}{})",
"(Join {} {} {} {} {}{} {}{} {})",
left,
right,
left_on,
Expand All @@ -1749,6 +1751,7 @@ fn join(
join_type,
join_constraint_prefix,
join_constraint,
null_equals_null,
)
}

Expand Down
1 change: 1 addition & 0 deletions rust/cubesql/cubesql/src/compile/rewrite/rules/members.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ impl RewriteRules for MemberRules {
"?right_on",
"?join_type",
"?join_constraint",
"?null_equals_null",
),
cross_join(
cube_scan(
Expand Down

0 comments on commit e02f612

Please sign in to comment.