Hello all,

 

I have a question about user-defined functions. I see that one can extend
Calcite by adding new functions to various libraries.

My question is whether there exists a mechanism to add such functions
*dynamically*, without changing the Calcite code.

This would allow users to write UDFs in other languages, as long as their
SQL backends support them. What some PRs call UDFs are not really
user-defined, they are dialect-defined. 

 

In principle, Calcite only needs to know the function type signatures to
pass them through all the compilation stages, so a grammar extension for
declaring function "prototypes" could be enough to make this work (at least
for functions which are not polymorphic and thus require no type inference).
There is a complication with constant evaluation: I think that some Calcite
optimization stages try to evaluate functions with compile-time known
arguments at compilation time. One workaround would be to declare such
functions as "nondeterminstic", but perhaps there is a more principled way.

 

Thank you,

Mihai

Reply via email to