Skip to content

Conversation

taniabogatsch
Copy link
Collaborator

DuckDB v1.4 exposes parts of the scalar function binding interface, including a lightweight API around expressions.

With that, we can make it possible for clients implementing their custom scalar UDFs to also provide a custom bind callback. Binding happens before scalar function execution, meaning any computation based on the input arguments that only has to happen once, should happen during that bind step. Then, the result of that bind step can be made available to the different threads running the "actual" scalar function callback during execution.

In this PR, I've drafted an initial interface to make that possible. There are still a few open questions, like:

  • should the custom bind data (currently a returned ScalarUDFArg) be set in the context, or should we add (yet) another row executor taking that argument as its input? Or, should we add another row executor, but hand it some info-struct, to allow more expansion in the future. I think we want to discuss the options here, as this is also relevant for a long-term stable interface.
  • does this PR sufficiently meet requirements on custom bind callbacks? Is there anything we "forget" by not exposing expressions and their API directly, and instead wrapping them in ScalarUDFArg?

@taniabogatsch taniabogatsch added the feature / enhancement Code improvements or a new feature label Sep 22, 2025
@taniabogatsch taniabogatsch changed the title Expose scalar UDF arguments Expose scalar UDF arguments and a custom bind-callback Sep 22, 2025
Copy link

@lorenzowritescode lorenzowritescode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Tania, looks great - this will help us simplify our usage of UDFs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature / enhancement Code improvements or a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants