alamb commented on issue #8008:
URL: 
https://github.com/apache/arrow-datafusion/issues/8008#issuecomment-1793417608

   
   > there in lies the problem—all logical plans with a schema use 
exprlist_to_fields to generate the initial schema, however this function will 
always 
[result](https://github.com/apache/arrow-datafusion/blob/656c6a93fadcec7bc43a8a881dfaf55388b0b5c6/datafusion/expr/src/expr_schema.rs#L285-L305)
 in a unqualified field for Expr::Alias unlike for Expr::Column, hence the 
schemas can never match
   
   Somehow,  
[Projection](https://docs.rs/datafusion/latest/datafusion/logical_expr/struct.Projection.html)
 doesn't seem to have this problem.
   
   Is the problem in your example that the original schema is `test.b` (not 
`b`) so when you alias `MAX(test.b)` to `b` you are in fact changing the schema.
   
   Shouldn't it be something more like this (I can't remember if you have to 
explicitly build qualified identifiers specially):
   
   ```rust
       // Attempt to rename columns to original
       let projection_plan = LogicalPlanBuilder::from(new_plan)
           .project(vec![
               col("a"),
               col("MAX(test.b)").alias("test.b"),
               col("MIN(test.c)").alias("test.c"),
           ])?
           .build()?;
   ```


-- 
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