ic4y opened a new issue #1312:
URL: https://github.com/apache/arrow-datafusion/issues/1312


   **Describe the bug**
   why gather all columns needed for expressions in this Aggregate by using 
aggr_expr, rather than schema.
   An error occurs when the schema is generated by a custom optimizer and does 
not match the column name in aggr_expr.
   
   
https://github.com/apache/arrow-datafusion/blob/0b6db52435c7c955b51e44de8a3eae58e53716d0/datafusion/src/optimizer/projection_push_down.rs#L292-L305
   
   Nothing will go wrong like this
   ```
               schema
                   .fields()[group_expr.len()..].to_vec()
                   .iter()
                   .enumerate()
                   .try_for_each(|(i, field)| {
                       if required_columns.contains(&field.qualified_column()) {
                           new_aggr_expr.push(aggr_expr[i].clone());
                           utils::expr_to_columns(&aggr_expr[i], &mut 
new_required_columns)
                       } else {
                           Ok(())
                       }
                   })?;
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to