@@ -978,14 +978,7 @@ impl OptimizerRule for PushDownFilter {
978978 }
979979 LogicalPlan :: Aggregate ( mut agg) => {
980980 // We can push down Predicate which in groupby_expr.
981- let group_expr_columns: HashSet < Column > = agg
982- . group_expr
983- . iter ( )
984- . map ( |expr| {
985- let ( relation, name) = expr. qualified_name ( ) ;
986- Column :: new ( relation, name)
987- } )
988- . collect ( ) ;
981+ let group_expr_columns = expr_columns ( & agg. group_expr ) ;
989982
990983 // As for plan Filter: Column(a+b) > 0 -- Agg: groupby:[Column(a)+Column(b)]
991984 // After push, we need to replace `a+b` with Column(a)+Column(b)
@@ -1037,14 +1030,7 @@ impl OptimizerRule for PushDownFilter {
10371030 // Therefore, we need to ensure that any potential partition key returned is used in
10381031 // ALL window functions. Otherwise, filters cannot be pushed by through that column.
10391032 fn extract_partition_keys ( func : & WindowFunction ) -> HashSet < Column > {
1040- func. params
1041- . partition_by
1042- . iter ( )
1043- . map ( |expr| {
1044- let ( relation, name) = expr. qualified_name ( ) ;
1045- Column :: new ( relation, name)
1046- } )
1047- . collect ( )
1033+ expr_columns ( & func. params . partition_by )
10481034 }
10491035
10501036 let potential_partition_keys = window
@@ -1399,6 +1385,16 @@ fn with_filters(predicates: Vec<Expr>, plan: LogicalPlan) -> LogicalPlan {
13991385 }
14001386}
14011387
1388+ fn expr_columns ( exprs : & [ Expr ] ) -> HashSet < Column > {
1389+ exprs
1390+ . iter ( )
1391+ . map ( |expr| {
1392+ let ( relation, name) = expr. qualified_name ( ) ;
1393+ Column :: new ( relation, name)
1394+ } )
1395+ . collect ( )
1396+ }
1397+
14021398#[ cfg( test) ]
14031399mod tests {
14041400 use std:: cmp:: Ordering ;
0 commit comments