You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 34834dc
Browse filesBrowse the repository at this point in the historyBrowse files
refactor: wrap HigherOrderUDFImpl in a concrete HigherOrderUDF struct (apache#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
`Closesapache#123` indicates that this PR will close issue apache#123.
-->
Part of apache#21172
## 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
MyHOF` needs to write i`mpl HigherOrderUDFImpl for MyType`. Constructing
a HigherOrderUDF from an impl is HigherOrderUDF::new_from_impl(my_impl)
(or my_impl.into()).
0 commit comments