@@ -228,7 +228,7 @@ impl OptimizerRule for PushDownProjection {
228228 // Gather all columns needed for expressions in this Aggregate
229229 let mut new_aggr_expr = vec ! [ ] ;
230230 for e in agg. aggr_expr . iter ( ) {
231- let column = Column :: from ( e. display_name ( ) ?) ;
231+ let column = Column :: from_name ( e. display_name ( ) ?) ;
232232 if required_columns. contains ( & column) {
233233 new_aggr_expr. push ( e. clone ( ) ) ;
234234 }
@@ -605,6 +605,31 @@ mod tests {
605605 assert_optimized_plan_eq ( & plan, expected)
606606 }
607607
608+ #[ test]
609+ fn aggregate_with_periods ( ) -> Result < ( ) > {
610+ let schema = Schema :: new ( vec ! [ Field :: new( "tag.one" , DataType :: Utf8 , false ) ] ) ;
611+
612+ // Build a plan that looks as follows (note "tag.one" is a column named
613+ // "tag.one", not a column named "one" in a table named "tag"):
614+ //
615+ // Projection: tag.one
616+ // Aggregate: groupBy=[], aggr=[MAX("tag.one") AS "tag.one"]
617+ // TableScan
618+ let plan = table_scan ( Some ( "m4" ) , & schema, None ) ?
619+ . aggregate (
620+ Vec :: < Expr > :: new ( ) ,
621+ vec ! [ max( col( Column :: new_unqualified( "tag.one" ) ) ) . alias( "tag.one" ) ] ,
622+ ) ?
623+ . project ( [ col ( Column :: new_unqualified ( "tag.one" ) ) ] ) ?
624+ . build ( ) ?;
625+
626+ let expected = "\
627+ Aggregate: groupBy=[[]], aggr=[[MAX(m4.tag.one) AS tag.one]]\
628+ \n TableScan: m4 projection=[tag.one]";
629+
630+ assert_optimized_plan_eq ( & plan, expected)
631+ }
632+
608633 #[ test]
609634 fn redundant_project ( ) -> Result < ( ) > {
610635 let table_scan = test_table_scan ( ) ?;
0 commit comments