11use crate :: {
22 compile:: rewrite:: {
3- aggregate, cube_scan, flatten_pushdown_replacer, projection,
3+ aggregate, cube_scan, filter , flatten_pushdown_replacer, projection,
44 rewriter:: { CubeEGraph , CubeRewrite } ,
55 rules:: { flatten:: FlattenRules , replacer_flat_push_down_node, replacer_push_down_node} ,
66 transforming_chain_rewrite_with_root, FlattenPushdownReplacerInnerAlias , ListType ,
@@ -159,6 +159,90 @@ impl FlattenRules {
159159 ) ,
160160 ) ] ) ;
161161
162+ rules. extend ( vec ! [ transforming_chain_rewrite_with_root(
163+ "flatten-filter-pushdown" ,
164+ aggregate(
165+ "?filter_node" ,
166+ "?outer_group_expr" ,
167+ "?outer_aggregate_expr" ,
168+ "AggregateSplit:false" ,
169+ ) ,
170+ vec![
171+ ( "?filter_node" , filter( "?filter_expr" , "?inner_projection" ) ) ,
172+ (
173+ "?inner_projection" ,
174+ projection(
175+ "?inner_projection_expr" ,
176+ "?cube_scan" ,
177+ "?inner_projection_alias" ,
178+ "ProjectionSplit:false" ,
179+ ) ,
180+ ) ,
181+ (
182+ "?cube_scan" ,
183+ cube_scan(
184+ "?alias_to_cube" ,
185+ "?members" ,
186+ "?filters" ,
187+ "?orders" ,
188+ "?limit" ,
189+ "?offset" ,
190+ "CubeScanSplit:false" ,
191+ "?can_pushdown_join" ,
192+ "CubeScanWrapped:false" ,
193+ "?ungrouped" ,
194+ "?join_hints" ,
195+ ) ,
196+ ) ,
197+ ] ,
198+ aggregate(
199+ filter(
200+ flatten_pushdown_replacer(
201+ "?filter_expr" ,
202+ "?inner_projection_expr" ,
203+ "?inner_alias" ,
204+ "FlattenPushdownReplacerTopLevel:false" ,
205+ ) ,
206+ cube_scan(
207+ "?alias_to_cube" ,
208+ "?members" ,
209+ "?filters" ,
210+ "?orders" ,
211+ "?limit" ,
212+ "?offset" ,
213+ "CubeScanSplit:false" ,
214+ "?can_pushdown_join" ,
215+ "CubeScanWrapped:false" ,
216+ "?ungrouped" ,
217+ "?join_hints" ,
218+ ) ,
219+ ) ,
220+ flatten_pushdown_replacer(
221+ "?outer_group_expr" ,
222+ "?inner_projection_expr" ,
223+ "?inner_alias" ,
224+ "FlattenPushdownReplacerTopLevel:false" ,
225+ ) ,
226+ flatten_pushdown_replacer(
227+ "?outer_aggregate_expr" ,
228+ "?inner_projection_expr" ,
229+ "?inner_alias" ,
230+ "FlattenPushdownReplacerTopLevel:false" ,
231+ ) ,
232+ "AggregateSplit:false" ,
233+ ) ,
234+ self . flatten_aggregate(
235+ "?inner_projection" ,
236+ "?cube_scan" ,
237+ "?members" ,
238+ "?inner_projection_expr" ,
239+ "?outer_group_expr" ,
240+ "?outer_aggregate_expr" ,
241+ "?inner_projection_alias" ,
242+ "?inner_alias" ,
243+ ) ,
244+ ) ] ) ;
245+
162246 if self . config_obj . push_down_pull_up_split ( ) {
163247 Self :: flat_list_pushdown_rules (
164248 "flatten-projection-expr" ,
@@ -175,10 +259,34 @@ impl FlattenRules {
175259 ListType :: AggregateGroupExpr ,
176260 rules,
177261 ) ;
262+ Self :: flat_list_pushdown_rules (
263+ "flatten-scalar-fun-args" ,
264+ ListType :: ScalarFunctionExprArgs ,
265+ rules,
266+ ) ;
267+ Self :: flat_list_pushdown_rules (
268+ "flatten-udf-fun-args" ,
269+ ListType :: ScalarUDFExprArgs ,
270+ rules,
271+ ) ;
272+ Self :: flat_list_pushdown_rules (
273+ "flatten-agg-fun-args" ,
274+ ListType :: AggregateFunctionExprArgs ,
275+ rules,
276+ ) ;
277+ Self :: flat_list_pushdown_rules (
278+ "flatten-udaf-fun-args" ,
279+ ListType :: AggregateUDFExprArgs ,
280+ rules,
281+ ) ;
178282 } else {
179283 Self :: list_pushdown_rules ( "flatten-projection-expr" , "ProjectionExpr" , rules) ;
180284 Self :: list_pushdown_rules ( "flatten-aggregate-expr" , "AggregateAggrExpr" , rules) ;
181285 Self :: list_pushdown_rules ( "flatten-group-expr" , "AggregateGroupExpr" , rules) ;
286+ Self :: list_pushdown_rules ( "flatten-scalar-fun-args" , "ScalarFunctionExprArgs" , rules) ;
287+ Self :: list_pushdown_rules ( "flatten-udf-fun-args" , "ScalarUDFExprArgs" , rules) ;
288+ Self :: list_pushdown_rules ( "flatten-agg-fun-args" , "AggregateFunctionExprArgs" , rules) ;
289+ Self :: list_pushdown_rules ( "flatten-udaf-fun-args" , "AggregateUDFExprArgs" , rules) ;
182290 }
183291 }
184292
0 commit comments