-
Notifications
You must be signed in to change notification settings - Fork 94
feat(extensions): support impl-level description in extensions #848
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
nielspardon
merged 2 commits into
substrait-io:main
from
nielspardon:feat/extension-impl-description
Jun 12, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
91 changes: 91 additions & 0 deletions
91
core/src/test/java/io/substrait/extension/DescriptionExtensionTest.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,91 @@ | ||
| package io.substrait.extension; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| import io.substrait.TestBase; | ||
| import java.io.IOException; | ||
| import java.io.UncheckedIOException; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| /** | ||
| * Verifies that descriptions can be read from extension YAML files at both the function level and | ||
| * the function-implementation level. An implementation-level description documents | ||
| * overload-specific behavior and takes precedence over the parent function's description when both | ||
| * are present. | ||
| */ | ||
| class DescriptionExtensionTest extends TestBase { | ||
|
|
||
| static final String URN = "extension:test:description_extensions"; | ||
| static final SimpleExtension.ExtensionCollection DESCRIPTION_EXTENSION; | ||
|
|
||
| static { | ||
| try { | ||
| String extensionStr = asString("extensions/description_extensions.yaml"); | ||
| DESCRIPTION_EXTENSION = SimpleExtension.load(extensionStr); | ||
| } catch (IOException e) { | ||
| throw new UncheckedIOException(e); | ||
| } | ||
| } | ||
|
|
||
| DescriptionExtensionTest() { | ||
| super(DESCRIPTION_EXTENSION); | ||
| } | ||
|
|
||
| @Test | ||
| void testFunctionLevelDescriptionInherited() { | ||
| // The single impl has no description of its own, so it inherits the function-level description. | ||
| SimpleExtension.FunctionAnchor anchor = | ||
| SimpleExtension.FunctionAnchor.of(URN, "documentedScalar:i64"); | ||
| assertEquals( | ||
| "Function-level scalar description", extensions.getScalarFunction(anchor).description()); | ||
| } | ||
|
|
||
| @Test | ||
| void testImplLevelDescriptionTakesPrecedence() { | ||
| // The i64 overload defines its own description; it must win over the function-level one. | ||
| SimpleExtension.FunctionAnchor anchor = | ||
| SimpleExtension.FunctionAnchor.of(URN, "overloadDocumented:i64"); | ||
| assertEquals( | ||
| "Overload-specific description for i64", | ||
| extensions.getScalarFunction(anchor).description()); | ||
| } | ||
|
|
||
| @Test | ||
| void testOverloadWithoutDescriptionInheritsFunctionLevel() { | ||
| // The fp32 overload has no description of its own, so it inherits the function-level one. | ||
| SimpleExtension.FunctionAnchor anchor = | ||
| SimpleExtension.FunctionAnchor.of(URN, "overloadDocumented:fp32"); | ||
| assertEquals( | ||
| "Shared function-level description", extensions.getScalarFunction(anchor).description()); | ||
| } | ||
|
|
||
| @Test | ||
| void testImplLevelDescriptionWithoutFunctionLevel() { | ||
| SimpleExtension.FunctionAnchor anchor = | ||
| SimpleExtension.FunctionAnchor.of(URN, "implOnlyScalar:i64"); | ||
| assertEquals("Only the impl is documented", extensions.getScalarFunction(anchor).description()); | ||
| } | ||
|
|
||
| @Test | ||
| void testAggregateImplLevelDescription() { | ||
| SimpleExtension.FunctionAnchor anchor = | ||
| SimpleExtension.FunctionAnchor.of(URN, "documentedAggregate:i64"); | ||
| assertEquals( | ||
| "Aggregate impl description", extensions.getAggregateFunction(anchor).description()); | ||
| } | ||
|
|
||
| @Test | ||
| void testAggregateImplDescriptionCarriesOverToWindowFunction() { | ||
| // Aggregate functions are also registered as window functions; the description must carry over. | ||
| SimpleExtension.FunctionAnchor anchor = | ||
| SimpleExtension.FunctionAnchor.of(URN, "documentedAggregate:i64"); | ||
| assertEquals("Aggregate impl description", extensions.getWindowFunction(anchor).description()); | ||
| } | ||
|
|
||
| @Test | ||
| void testWindowImplLevelDescriptionTakesPrecedence() { | ||
| SimpleExtension.FunctionAnchor anchor = | ||
| SimpleExtension.FunctionAnchor.of(URN, "documentedWindow:i64"); | ||
| assertEquals("Window impl description", extensions.getWindowFunction(anchor).description()); | ||
| } | ||
| } |
45 changes: 45 additions & 0 deletions
45
core/src/test/resources/extensions/description_extensions.yaml
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,45 @@ | ||
| %YAML 1.2 | ||
| --- | ||
| urn: extension:test:description_extensions | ||
| scalar_functions: | ||
| # Function-level description only; the single impl inherits it. | ||
| - name: "documentedScalar" | ||
| description: "Function-level scalar description" | ||
| impls: | ||
| - args: | ||
| - value: i64 | ||
| return: i64 | ||
| # The i64 overload documents itself and overrides the function-level | ||
| # description; the fp32 overload inherits the function-level description. | ||
| - name: "overloadDocumented" | ||
| description: "Shared function-level description" | ||
| impls: | ||
| - args: | ||
| - value: i64 | ||
| description: "Overload-specific description for i64" | ||
| return: i64 | ||
| - args: | ||
| - value: fp32 | ||
| return: fp32 | ||
| # Impl-level description with no function-level description. | ||
| - name: "implOnlyScalar" | ||
| impls: | ||
| - args: | ||
| - value: i64 | ||
| description: "Only the impl is documented" | ||
| return: i64 | ||
| aggregate_functions: | ||
| - name: "documentedAggregate" | ||
| impls: | ||
| - args: | ||
| - value: i64 | ||
| description: "Aggregate impl description" | ||
| return: i64 | ||
| window_functions: | ||
| - name: "documentedWindow" | ||
| description: "Window function-level description" | ||
| impls: | ||
| - args: | ||
| - value: i64 | ||
| description: "Window impl description" | ||
| return: i64 |
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.