Skip to content

Commit

Permalink
fix(cubesql): Pass null_equals_null through egraph
Browse files Browse the repository at this point in the history
  • Loading branch information
mcheshkov committed Oct 3, 2024
1 parent f40062b commit dd07de5
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 @@ -13,19 +13,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 @@ -662,13 +663,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 @@ -1390,15 +1394,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 @@ -105,6 +105,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 @@ -1743,6 +1744,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 @@ -1755,7 +1757,7 @@ fn join(
"JoinJoinConstraint:"
};
format!(
"(Join {} {} {} {} {}{} {}{})",
"(Join {} {} {} {} {}{} {}{} {})",
left,
right,
left_on,
Expand All @@ -1764,6 +1766,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 @@ -384,6 +384,7 @@ impl RewriteRules for MemberRules {
"?right_on",
"?join_type",
"?join_constraint",
"?null_equals_null",
),
cross_join(
cube_scan(
Expand Down

0 comments on commit dd07de5

Please sign in to comment.