Skip to content

Conversation

@benbellick
Copy link
Member

@benbellick benbellick commented Oct 22, 2025

Closes #562

This test resolves an issue in which FunctionConverters constructed with ExtensionCollections 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.

this.substraitFuncKeyToSqlOperatorMap = ArrayListMultimap.create();

ArrayListMultimap<String, F> alm = ArrayListMultimap.<String, F>create();
ArrayListMultimap<String, F> nameToFn = ArrayListMultimap.<String, F>create();
Copy link
Member Author

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.

@benbellick benbellick force-pushed the ben.bellick/562/function-converter-crash branch 2 times, most recently from 20db198 to f68cb82 Compare October 22, 2025 19:15
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.
@benbellick benbellick force-pushed the ben.bellick/562/function-converter-crash branch from f68cb82 to 03b0f24 Compare October 22, 2025 19:44
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.
@benbellick benbellick force-pushed the ben.bellick/562/function-converter-crash branch from d1a29b3 to afa6fdf Compare October 22, 2025 20:02
@benbellick benbellick marked this pull request as ready for review October 22, 2025 20:36
Comment on lines +353 to +355
*
* 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.
Copy link
Member

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?

Copy link
Member Author

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 :)

Copy link
Member

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

@nielspardon
Copy link
Member

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
Copy link
Member

@nielspardon nielspardon left a comment

Choose a reason for hiding this comment

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

LGTM

@benbellick benbellick changed the title Ben.bellick/562/function converter crash fix: prevents exception on construction of FunctionConverter Oct 23, 2025
@benbellick benbellick changed the title fix: prevents exception on construction of FunctionConverter fix: prevents exception on construction of FunctionConverter with duplicate functions Oct 23, 2025
@benbellick benbellick merged commit 1b1dc73 into main Oct 23, 2025
12 checks passed
@benbellick benbellick deleted the ben.bellick/562/function-converter-crash branch October 23, 2025 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FunctionConverter crashes when multiple extensions define functions with the same name and signature

3 participants