@@ -100,7 +100,7 @@ fn test_pushdown_volatile_functions_not_allowed() {
100100 let scan = TestScanBuilder :: new ( schema ( ) ) . with_support ( true ) . build ( ) ;
101101 let cfg = Arc :: new ( ConfigOptions :: default ( ) ) ;
102102 let predicate = Arc :: new ( BinaryExpr :: new (
103- Arc :: new ( Column :: new_with_schema ( "a " , & schema ( ) ) . unwrap ( ) ) ,
103+ Arc :: new ( Column :: new_with_schema ( "c " , & schema ( ) ) . unwrap ( ) ) ,
104104 Operator :: Eq ,
105105 Arc :: new (
106106 ScalarFunctionExpr :: try_new (
@@ -119,11 +119,11 @@ fn test_pushdown_volatile_functions_not_allowed() {
119119 @r"
120120 OptimizationTest:
121121 input:
122- - FilterExec: a@0 = random()
122+ - FilterExec: c@2 = random()
123123 - DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true
124124 output:
125125 Ok:
126- - FilterExec: a@0 = random()
126+ - FilterExec: c@2 = random()
127127 - DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true
128128 " ,
129129 ) ;
@@ -3095,11 +3095,13 @@ fn test_pushdown_grouping_sets_filter_on_common_column() {
30953095
30963096#[ test]
30973097fn test_pushdown_with_empty_group_by ( ) {
3098- // Test that filters can be pushed down when GROUP BY is empty (no grouping columns)
3099- // SELECT count(*) as cnt FROM table WHERE a = 'foo'
3100- // There are no grouping columns, so the filter should still push down
3098+ // Test that filters can be pushed down through an aggregate with empty
3099+ // GROUP BY: SELECT count(*) FROM table WHERE a = 'foo'
31013100 let scan = TestScanBuilder :: new ( schema ( ) ) . with_support ( true ) . build ( ) ;
31023101
3102+ let predicate = col_lit_predicate ( "a" , "foo" , & schema ( ) ) ;
3103+ let filter = Arc :: new ( FilterExec :: try_new ( predicate, scan) . unwrap ( ) ) ;
3104+
31033105 let aggregate_expr = vec ! [
31043106 AggregateExprBuilder :: new( count_udaf( ) , vec![ col( "c" , & schema( ) ) . unwrap( ) ] )
31053107 . schema( schema( ) )
@@ -3109,33 +3111,28 @@ fn test_pushdown_with_empty_group_by() {
31093111 . unwrap( ) ,
31103112 ] ;
31113113
3112- // Empty GROUP BY - no grouping columns
31133114 let group_by = PhysicalGroupBy :: new_single ( vec ! [ ] ) ;
31143115
3115- let aggregate = Arc :: new (
3116+ let plan : Arc < dyn ExecutionPlan > = Arc :: new (
31163117 AggregateExec :: try_new (
31173118 AggregateMode :: Final ,
31183119 group_by,
31193120 aggregate_expr. clone ( ) ,
31203121 vec ! [ None ] ,
3121- scan ,
3122+ filter ,
31223123 schema ( ) ,
31233124 )
31243125 . unwrap ( ) ,
31253126 ) ;
31263127
3127- // Filter on 'a'
3128- let predicate = col_lit_predicate ( "a" , "foo" , & schema ( ) ) ;
3129- let plan = Arc :: new ( FilterExec :: try_new ( predicate, aggregate) . unwrap ( ) ) ;
3130-
3131- // The filter should be pushed down even with empty GROUP BY
3128+ // The filter should be pushed down to the scan
31323129 insta:: assert_snapshot!(
31333130 OptimizationTest :: new( plan, FilterPushdown :: new( ) , true ) ,
31343131 @r"
31353132 OptimizationTest:
31363133 input:
3137- - FilterExec: a@0 = foo
3138- - AggregateExec: mode=Final, gby=[], aggr=[cnt]
3134+ - AggregateExec: mode=Final, gby=[], aggr=[cnt]
3135+ - FilterExec: a@0 = foo
31393136 - DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true
31403137 output:
31413138 Ok:
0 commit comments