paleolimbot opened a new issue, #27156:
URL: https://github.com/apache/datafusion/issues/27156

   ### Describe the bug
   
   When a (non literal) logical alias gets converted to a physical expression, 
its PhysicalExpr equivalent doesn't have the same return field. I'm not sure if 
aliases are special cased in such a way that this matters in practice.
   
   ### To Reproduce
   
   ```rust
   #[test]
   fn non_literal_alias_metadata_differs_between_logical_and_physical() -> 
Result<()> {
       let schema = Schema::new(vec![Field::new("value", DataType::Int64, 
false)]);
       let df_schema = DFSchema::try_from(schema.clone())?;
   
       let metadata = FieldMetadata::from(HashMap::from([(
           "source".to_string(),
           "alias".to_string(),
       )]));
   
       let expr = col("value").alias_with_metadata("aliased_value", 
Some(metadata));
   
       let logical_field = expr.to_field(&df_schema)?.1;
       let physical_expr = create_physical_expr(
           &expr,
           &df_schema,
           &ExecutionProps::new(),
           &PhysicalPlanningContext::default(),
       )?;
       let physical_field = physical_expr.return_field(&schema)?;
   
       // Logical Alias applies its supplied metadata.
       assert_eq!(
           logical_field.metadata().get("source").map(String::as_str),
           Some("alias")
       );
   
       // Physical lowering removes a non-literal Alias and its metadata.
       assert_eq!(physical_field.metadata().get("source"), None);
   
       Ok(())
   }
   ```
   
   ### Expected behavior
   
   I believe a property we want to hold is that an expr and its 
create_physical_expr equivalent should always give the same return field.
   
   ### Additional context
   
   _No response_
   
   ### Willingness to contribute
   
   None


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to