LiaCastaneda opened a new pull request, #22593:
URL: https://github.com/apache/datafusion/pull/22593

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements and this helps us generate change logs for our releases. You can 
link an issue to this PR using the GitHub syntax. For example `Closes #123` 
indicates that this PR will close issue #123.
   -->
   
   - Closes #.
   
   ## Rationale for this change
   
   `HigherOrderUDF` was the only UDF kind defined as a trait that callers used 
directly via `Arc<dyn HigherOrderUDF>`. The other UDFs:  `ScalarUDF`, 
`AggregateUDF`, `WindowUDF` — are concrete structs that wrap their respective 
*Impl trait, which makes inherent methods like with_aliases ergonomic to call 
on the function object. With the trait-only setup, adding aliases to an 
existing higher-order function required an extension trait import or a free 
helper function.
   
   This PR brings higher order functions in line with the other UDFs so the 
same with_aliases pattern works.
   
   ## What changes are included in this PR?
   
   Rename the `HigherOrderUDF` trait to `HigherOrderUDFImpl`, matching 
`ScalarUDFImpl`/`AggregateUDFImpl`.
   Add a concrete `HigherOrderUDF` struct wrapping `Arc<dyn 
HigherOrderUDFImpl>`, with the same shape as `ScalarUDF`: new_from_impl, 
new_from_shared_impl, inner, with_aliases, From<F: HigherOrderUDFImpl>, and 
delegate methods for every trait method.
   `with_aliases` is backed by a private `AliasedHigherOrderUDFImpl` decorator 
(same pattern as `AliasedScalarUDFImpl`).
   Update `Expr::HigherOrderFunction`, `FunctionRegistry`, the 
create_higher_order! singleton macro, and all consumer files ( across several 
crates) to use `Arc<HigherOrderUDF>` instead of `Arc<dyn HigherOrderUDF>`.
   Existing impls (`ArrayFilter`, `ArrayTransform`, `ArrayAnyMatch`) now 
implement `HigherOrderUDFImpl`; their public constructors continue to return 
`Arc<HigherOrderUDF>` so external call sites need no changes.
   
   Callers can now write:
   
   `array_filter_higher_order_function().with_aliases(["filter"])
   `
   
   exactly like the existing scalar pattern:
   
   `make_array_udf().as_ref().clone().with_aliases(["array_construct"])
   `
   
   ## Are these changes tested?
   
   Covered by existing tests 
   
   ## Are there any user-facing changes?
   
   Yes, any code referring to Arc<dyn HigherOrderUDF> needs to become 
Arc<HigherOrderUDF>, and any code that wrote impl HigherOrderUDF for MyType 
needs to write impl HigherOrderUDFImpl for MyType. Constructing a 
HigherOrderUDF from an impl is HigherOrderUDF::new_from_impl(my_impl) (or 
my_impl.into()).
   


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