-
Notifications
You must be signed in to change notification settings - Fork 93
feat(isthmus): add dynamic function conversion for Substrait<->Calcite #457
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
9d60dc7
feat(isthmus): udf support for substrait<->calcite
ZorinAnton 556847b
chore(isthmus): handle nullability and EnumArgument in SimplExtension…
ZorinAnton 857fe2c
feat(isthmus): udf support for substrait<->calcite
ZorinAnton eeb97cd
chore(isthmus): handle nullability and EnumArgument in SimplExtension…
ZorinAnton f30b556
Merge branch 'main' into zor-udf
ZorinAnton 6d9cc2a
chore: resolve pmd
ZorinAnton 1a1bf47
chore: sync submodules with main
ZorinAnton 834ab5e
chore: sync substrait with main
ZorinAnton 8340cc5
chore(isthmus): resolve conflicts after submodule update
ZorinAnton 6ba115f
chore(isthmus): fix yaml for custom udf
ZorinAnton e739184
Merge branch 'main' into zor-udf
ZorinAnton 838a0a7
chore(isthmus): fix regression
ZorinAnton 32ae275
fix: add missing serialVersionUIDs (#621)
nielspardon e4f656d
Merge branch 'main' into zor-udf
ZorinAnton 8d2b4ed
chore(isthmus): fix regression
ZorinAnton 9b0c027
feat(isthmus): enable dynamic UDFs with FeatureBoard
ZorinAnton a9e7c60
chore(isthmus): refactor SimpleExtensionToSqlOperatorTest
ZorinAnton 2f6cd28
chore(isthmus): address minor PR comments
ZorinAnton 71fcdfc
feat(isthmus): make dynamic UDF configurable for substrait to sql con…
ZorinAnton ca3d967
Merge branch 'main' into zor-udf
ZorinAnton 142d372
chore(isthmus): fix format violations
ZorinAnton 74fd2e7
chore(isthmus): minor refactoring
ZorinAnton ec45173
chore(isthmus): check arg types in SimpleExtensionToSqlOperatorTest
ZorinAnton 6eedacd
chore(isthmus): minor refactoring of SimpleExtensionToSqlOperator
ZorinAnton b002d9b
chore(isthmus): fix opt-in for dynamic operators
ZorinAnton fcf24bb
Merge branch 'main' into zor-udf
ZorinAnton fc2d576
chore(isthmus): fix regression in test
ZorinAnton 26c15dc
Merge branch 'main' into zor-udf
ZorinAnton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
isthmus/src/main/java/io/substrait/isthmus/ExtensionUtils.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package io.substrait.isthmus; | ||
|
|
||
| import io.substrait.extension.SimpleExtension; | ||
| import io.substrait.isthmus.expression.FunctionMappings; | ||
| import java.util.List; | ||
| import java.util.Locale; | ||
| import java.util.Set; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| public class ExtensionUtils { | ||
|
|
||
| /** | ||
| * Extracts dynamic extensions from a collection of extensions. | ||
| * | ||
| * <p>A <b>dynamic extension</b> is a user-defined function (UDF) that is not part of the standard | ||
| * Substrait function catalog. These are custom functions that users define and provide at | ||
| * runtime, extending the built-in function set with domain-specific or application-specific | ||
| * operations. | ||
| * | ||
| * <p>This method filters out all functions that are already known to the Calcite operator table | ||
| * (the standard/built-in functions) and returns only the custom functions that represent new | ||
| * capabilities not available in the default function set. | ||
| * | ||
| * <p><b>Example:</b> If a user defines a custom UDF "my_hash_function" that computes a | ||
| * proprietary hash, this would be a dynamic extension since it's not part of the standard | ||
| * Substrait specification. | ||
| * | ||
| * @param extensions the complete collection of extensions (both standard and custom) | ||
| * @return a new ExtensionCollection containing only the dynamic (custom/user-defined) functions | ||
| * that are not present in the standard Substrait function catalog | ||
| */ | ||
| public static SimpleExtension.ExtensionCollection getDynamicExtensions( | ||
| SimpleExtension.ExtensionCollection extensions) { | ||
| Set<String> knownFunctionNames = | ||
| FunctionMappings.SCALAR_SIGS.stream() | ||
| .map(FunctionMappings.Sig::name) | ||
| .collect(Collectors.toSet()); | ||
|
|
||
| List<SimpleExtension.ScalarFunctionVariant> customFunctions = | ||
| extensions.scalarFunctions().stream() | ||
| .filter(f -> !knownFunctionNames.contains(f.name().toLowerCase(Locale.ROOT))) | ||
vbarua marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .collect(Collectors.toList()); | ||
|
|
||
| return SimpleExtension.ExtensionCollection.builder() | ||
| .scalarFunctions(customFunctions) | ||
| // TODO: handle aggregates and other functions | ||
| .build(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.