-
Notifications
You must be signed in to change notification settings - Fork 93
fix: prevents exception on construction of FunctionConverter with duplicate functions
#564
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
Conversation
| this.substraitFuncKeyToSqlOperatorMap = ArrayListMultimap.create(); | ||
|
|
||
| ArrayListMultimap<String, F> alm = ArrayListMultimap.<String, F>create(); | ||
| ArrayListMultimap<String, F> nameToFn = ArrayListMultimap.<String, F>create(); |
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.
This is unrelated to the PR technically, but I just thought that this was a clearer name.
20db198 to
f68cb82
Compare
isthmus/src/test/java/io/substrait/isthmus/DuplicateFunctionUrnTest.java
Outdated
Show resolved
Hide resolved
This commit introduces a test to capture the bug where name-colliding extension functions with different URNs cause an exception to be thrown on `FunctionConverter` construction.
This is a small change to make the meaning of a variable clearer in the `FunctionConverter.java` implementation.
f68cb82 to
03b0f24
Compare
Added a test for ltrim to ensure there is no issue specifically with the default extension collection functions (which have some special handling in isthmus) and an introduced ltrim function.
d1a29b3 to
afa6fdf
Compare
isthmus/src/test/java/io/substrait/isthmus/DuplicateFunctionUrnTest.java
Outdated
Show resolved
Hide resolved
| * | ||
| * Note that if there are multiple registered function extensions which can match a particular Call, | ||
| * the last one added to the extension collection will be matched. |
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.
I'm wondering whether this comment should be also in a more prominent place for any consumers of isthmus and where they would find that. Would maybe at the top of the FunctionConverter class be more prominent?
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.
I ended up adding quite a bit of comments. Let me know if anything added is incorrect or just too much :)
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.
looks great, I was suggesting to Victor a couple weeks in another PR that we maybe should try to add javadocs whenever we touch code to slowly build up javadoc documentation so this is a great contribution
isthmus/src/test/java/io/substrait/isthmus/DuplicateFunctionUrnTest.java
Outdated
Show resolved
Hide resolved
isthmus/src/test/java/io/substrait/isthmus/DuplicateFunctionUrnTest.java
Outdated
Show resolved
Hide resolved
|
looks good in general. just some minor remarks from my side |
This commit: - improves the documentation around the `FunctionConverter.java` class - fixes some minor stylistic comments around the tests
isthmus/src/main/java/io/substrait/isthmus/expression/FunctionConverter.java
Show resolved
Hide resolved
nielspardon
left a comment
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
FunctionConverter
FunctionConverterFunctionConverter with duplicate functions
Closes #562
This test resolves an issue in which
FunctionConverters constructed withExtensionCollections that contain multiple functions with different URNs results in an exception being thrown.The fix is to allow a list of functions to be associated with a particular
<name>:<sig>pairing, and then to select the final option of those available. This is reflected in the comments, which clarify that the last added function takes precedence.