Skip to content

Commit cb2c386

Browse files
committed
fix(cubesql): Allow only MEASURE UDAF in members rewrites
1 parent 869ca98 commit cb2c386

File tree

1 file changed

+34
-30
lines changed
  • rust/cubesql/cubesql/src/compile/rewrite/rules

1 file changed

+34
-30
lines changed

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

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
use crate::{
2-
compile::rewrite::{
3-
agg_fun_expr, aggregate, alias_expr, all_members,
4-
analysis::{ConstantFolding, LogicalPlanData, Member, MemberNamesToExpr, OriginalExpr},
5-
binary_expr, cast_expr, change_user_expr, column_expr, cross_join, cube_scan,
6-
cube_scan_filters_empty_tail, cube_scan_members, cube_scan_members_empty_tail,
7-
cube_scan_order_empty_tail, dimension_expr, distinct, expr_column_name, fun_expr, join,
8-
like_expr, limit, list_concat_pushdown_replacer, list_concat_pushup_replacer, literal_expr,
9-
literal_member, measure_expr, member_pushdown_replacer, member_replacer,
10-
merged_members_replacer, original_expr_name, projection, referenced_columns, rewrite,
11-
rewriter::{CubeEGraph, CubeRewrite, RewriteRules},
12-
rules::{
13-
replacer_flat_push_down_node_substitute_rules, replacer_push_down_node,
14-
replacer_push_down_node_substitute_rules, utils,
2+
compile::{
3+
engine::udf::MEASURE_UDAF_NAME,
4+
rewrite::{
5+
agg_fun_expr, aggregate, alias_expr, all_members,
6+
analysis::{ConstantFolding, LogicalPlanData, Member, MemberNamesToExpr, OriginalExpr},
7+
binary_expr, cast_expr, change_user_expr, column_expr, cross_join, cube_scan,
8+
cube_scan_filters_empty_tail, cube_scan_members, cube_scan_members_empty_tail,
9+
cube_scan_order_empty_tail, dimension_expr, distinct, expr_column_name, fun_expr, join,
10+
like_expr, limit, list_concat_pushdown_replacer, list_concat_pushup_replacer,
11+
literal_expr, literal_member, measure_expr, member_pushdown_replacer, member_replacer,
12+
merged_members_replacer, original_expr_name, projection, referenced_columns, rewrite,
13+
rewriter::{CubeEGraph, CubeRewrite, RewriteRules},
14+
rules::{
15+
replacer_flat_push_down_node_substitute_rules, replacer_push_down_node,
16+
replacer_push_down_node_substitute_rules, utils,
17+
},
18+
segment_expr, table_scan, time_dimension_expr, transform_original_expr_to_alias,
19+
transforming_chain_rewrite, transforming_rewrite, transforming_rewrite_with_root,
20+
udaf_expr, udf_expr, virtual_field_expr, AggregateFunctionExprDistinct,
21+
AggregateFunctionExprFun, AliasExprAlias, AllMembersAlias, AllMembersCube,
22+
BinaryExprOp, CastExprDataType, ChangeUserCube, ColumnExprColumn, CubeScanAliasToCube,
23+
CubeScanCanPushdownJoin, CubeScanLimit, CubeScanOffset, CubeScanUngrouped,
24+
DimensionName, JoinLeftOn, JoinRightOn, LikeExprEscapeChar, LikeExprLikeType,
25+
LikeExprNegated, LikeType, LimitFetch, LimitSkip, ListType, LiteralExprValue,
26+
LiteralMemberRelation, LiteralMemberValue, LogicalPlanLanguage, MeasureName,
27+
MemberErrorAliasToCube, MemberErrorError, MemberErrorPriority,
28+
MemberPushdownReplacerAliasToCube, MemberReplacerAliasToCube, ProjectionAlias,
29+
SegmentName, TableScanFetch, TableScanProjection, TableScanSourceTableName,
30+
TableScanTableName, TimeDimensionDateRange, TimeDimensionGranularity,
31+
TimeDimensionName, VirtualFieldCube, VirtualFieldName,
1532
},
16-
segment_expr, table_scan, time_dimension_expr, transform_original_expr_to_alias,
17-
transforming_chain_rewrite, transforming_rewrite, transforming_rewrite_with_root,
18-
udaf_expr, udf_expr, virtual_field_expr, AggregateFunctionExprDistinct,
19-
AggregateFunctionExprFun, AliasExprAlias, AllMembersAlias, AllMembersCube, BinaryExprOp,
20-
CastExprDataType, ChangeUserCube, ColumnExprColumn, CubeScanAliasToCube,
21-
CubeScanCanPushdownJoin, CubeScanLimit, CubeScanOffset, CubeScanUngrouped, DimensionName,
22-
JoinLeftOn, JoinRightOn, LikeExprEscapeChar, LikeExprLikeType, LikeExprNegated, LikeType,
23-
LimitFetch, LimitSkip, ListType, LiteralExprValue, LiteralMemberRelation,
24-
LiteralMemberValue, LogicalPlanLanguage, MeasureName, MemberErrorAliasToCube,
25-
MemberErrorError, MemberErrorPriority, MemberPushdownReplacerAliasToCube,
26-
MemberReplacerAliasToCube, ProjectionAlias, SegmentName, TableScanFetch,
27-
TableScanProjection, TableScanSourceTableName, TableScanTableName, TimeDimensionDateRange,
28-
TimeDimensionGranularity, TimeDimensionName, VirtualFieldCube, VirtualFieldName,
2933
},
3034
config::ConfigObj,
3135
transport::{MetaContext, V1CubeMetaDimensionExt, V1CubeMetaExt, V1CubeMetaMeasureExt},
@@ -123,7 +127,7 @@ impl RewriteRules for MemberRules {
123127
),
124128
self.measure_rewrite(
125129
"measure-fun",
126-
udaf_expr("?aggr_fun", vec![column_expr("?column")]),
130+
udaf_expr(MEASURE_UDAF_NAME, vec![column_expr("?column")]),
127131
Some("?column"),
128132
None,
129133
None,
@@ -646,7 +650,7 @@ impl MemberRules {
646650
));
647651
rules.extend(find_matching_old_member(
648652
"udaf-fun",
649-
udaf_expr("?fun_name", vec![column_expr("?column")]),
653+
udaf_expr(MEASURE_UDAF_NAME, vec![column_expr("?column")]),
650654
));
651655
rules.extend(find_matching_old_member_with_count(
652656
"agg-fun-default-count",
@@ -1099,7 +1103,7 @@ impl MemberRules {
10991103
));
11001104
rules.push(pushdown_measure_rewrite(
11011105
"member-pushdown-replacer-udaf-fun",
1102-
udaf_expr("?fun_name", vec![column_expr("?column")]),
1106+
udaf_expr(MEASURE_UDAF_NAME, vec![column_expr("?column")]),
11031107
measure_expr("?name", "?old_alias"),
11041108
None,
11051109
None,
@@ -1108,7 +1112,7 @@ impl MemberRules {
11081112
));
11091113
rules.push(pushdown_measure_rewrite(
11101114
"member-pushdown-replacer-udaf-fun-on-dimension",
1111-
udaf_expr("?fun_name", vec![column_expr("?column")]),
1115+
udaf_expr(MEASURE_UDAF_NAME, vec![column_expr("?column")]),
11121116
dimension_expr("?name", "?old_alias"),
11131117
None,
11141118
None,

0 commit comments

Comments
 (0)