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

   ### Is your feature request related to a problem or challenge?
   
   When a projection wraps columns into a struct via `named_struct` (e.g., 
`named_struct('ticker', ticker, ...) AS details`), the optimizer loses track of 
the input column's ordering because `ProjectionMapping` maps the entire 
`named_struct(...)` expression to `col("details")`.
   
   Notably, there is no field-level decomposition, so it can't prove that 
`get_field(details, "ticker")` actually preserves the ordering of the input 
ticker column. This means `ORDER BY details['ticker']` will require a 
`SortExec`, even when the input is already sorted by `ticker`.
   
   ### Describe the solution you'd like
   
   Add `ScalarUDFImpl::struct_field_mapping` that struct-producing UDFs can 
implement to declare their field-to-input-arg relationships, which 
`ProjectionMapping` then uses to add field-level entries so 
`EquivalenceProperties` can propagate orderings through the struct boundary.
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### Additional context
   
   _No response_


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