Skip to content

Remove as_any from scalar UDF trait definition#20812

Open
timsaucer wants to merge 5 commits intoapache:mainfrom
timsaucer:chore/update-any-usage-udf
Open

Remove as_any from scalar UDF trait definition#20812
timsaucer wants to merge 5 commits intoapache:mainfrom
timsaucer:chore/update-any-usage-udf

Conversation

@timsaucer
Copy link
Member

Which issue does this PR close?

None.

Rationale for this change

This PR reduces the amount of boilerplate code that users need to write for scalar UDFs. I didn't address aggregate or window functions yet just to keep the size of the PR manageable.

What changes are included in this PR?

Now that we have trait upcasting since rust 1.86, we no longer need every implementation of ScalarUDFImpl to have the as_any function that returns &self. This PR makes Any an supertrait for ScalarUDFImpl and makes the appropriate casts when necessary. The overall diff is about 1200 lines of code removed.

Are these changes tested?

Existing unit tests.

Are there any user-facing changes?

Users simply need to remove the as_any() function from their implementations.

@github-actions github-actions bot added documentation Improvements or additions to documentation sql SQL Planner logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates optimizer Optimizer rules core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) proto Related to proto crate functions Changes to functions implementation ffi Changes to the ffi crate spark labels Mar 8, 2026
@timsaucer
Copy link
Member Author

@emilk You inspired me to cut almost 1200 lines of code.

@timsaucer timsaucer marked this pull request as draft March 9, 2026 06:37
@timsaucer timsaucer force-pushed the chore/update-any-usage-udf branch from 49d8d72 to 16b5190 Compare March 9, 2026 20:14
@timsaucer timsaucer marked this pull request as ready for review March 9, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate documentation Improvements or additions to documentation ffi Changes to the ffi crate functions Changes to functions implementation logical-expr Logical plan and expressions optimizer Optimizer rules physical-expr Changes to the physical-expr crates proto Related to proto crate spark sql SQL Planner sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant