-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Support variadic arguments in the middle of a function signature #9451
feat: Support variadic arguments in the middle of a function signature #9451
Conversation
ksqldb-common/src/main/java/io/confluent/ksql/function/UdfIndex.java
Outdated
Show resolved
Hide resolved
ksqldb-common/src/main/java/io/confluent/ksql/function/UdfIndex.java
Outdated
Show resolved
Hide resolved
ksqldb-common/src/test/java/io/confluent/ksql/function/UdfIndexTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm thanks @reneesoika
@jzaralim I noticed a minor bug that would cause the function call to be ambiguous, which I just pushed a commit to fix. If you had these two function signatures:
I moved all the precedence rule comparisons into the same comparator, which fixes the issue. In the original |
Description
Follow-up to #9361. This PR adds support for a variadic argument anywhere in the function signature. There can still be only one variadic argument in the function signature.
This change is being made because we currently cannot support variadic UDAFs with initial arguments. Allowing a variadic argument in the middle removes this restriction.
The main changes to enable this feature are in
UdfIndex
. The tree of parameter types is now based on pairs of parameters, with one parameter from the left half of the parameter list and one parameter from the right half. This structure ensures the loop for variadic arguments is always at the bottom of the tree, eliminating most edge cases. There is also a new rule to determine function precedence:The number of nodes generated is quadratic with respect to the number of parameters in the function (only for variadic functions), but we only generate the tree once at startup. The number of nodes generated is not excessive unless there is a grossly absurd number of arguments (see graph). Currently, the only way to have a function with this many arguments is to have many initial arguments, as Java supports up to 255 arguments for a method. Resolving a function still takes linear time.
How
UdfIndex
now works is documented more thoroughly in comments. Other changes are removing exceptions thrown for var args in the middle or tests.Testing done
Added unit tests and QTTs for var args in the middle.
Reviewer checklist