-
Notifications
You must be signed in to change notification settings - Fork 94
feat(core): handle struct-based UDT literals #613
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
19 commits
Select commit
Hold shift + click to select a range
173ec59
feat: add structured UDT literal support with dual encoding
benbellick f0e13ef
test: add test to ensure struct-UDTs work with type parameters
benbellick f5b6341
test: improve UDT literal test by making opaque-ness explicit
benbellick 8c54706
refactor: rename UserDefined{kind} to UserDefined{kind}Literal
benbellick 36c81f0
feat: first class support for TypeParameters
benbellick 680ed29
docs: update docstring to explain use of Parameter
benbellick 6ac7aab
test: add test showing all Type.Parameters preserved
benbellick b2063d0
fix: correctly handle type conversion with paramterized types
benbellick ce7985f
refactor: revert to simpler binary construction for any rep UDT in ca…
benbellick e8cb862
fix: ensure nullability preserved in calcite roundtrip
benbellick 77f0bd7
chore: addressing some PR comments
benbellick 4b4f5ee
chore: addressing more PR comments
benbellick 3732cf9
chore: simplify documentation
benbellick a216f3e
Merge branch 'main' into benbellick/handle-structured-udt2
benbellick f61f68c
Merge branch 'main' into benbellick/handle-structured-udt2
benbellick 02f7920
Merge branch 'main' into benbellick/handle-structured-udt2
benbellick d009af4
Apply suggestions from code review
benbellick 76cd0f0
add interface for UserDefinedAnyValue
benbellick a60e0b7
Revert "add interface for UserDefinedAnyValue"
benbellick 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
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
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
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
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 |
|---|---|---|
| @@ -1,7 +1,5 @@ | ||
| package io.substrait.expression.proto; | ||
|
|
||
| import com.google.protobuf.Any; | ||
| import com.google.protobuf.InvalidProtocolBufferException; | ||
| import io.substrait.expression.ExpressionVisitor; | ||
| import io.substrait.expression.FieldReference; | ||
| import io.substrait.expression.FunctionArg; | ||
|
|
@@ -377,21 +375,51 @@ public Expression visit( | |
|
|
||
| @Override | ||
| public Expression visit( | ||
| io.substrait.expression.Expression.UserDefinedLiteral expr, EmptyVisitationContext context) { | ||
| io.substrait.expression.Expression.UserDefinedAnyLiteral expr, | ||
| EmptyVisitationContext context) { | ||
| int typeReference = | ||
| extensionCollector.getTypeReference(SimpleExtension.TypeAnchor.of(expr.urn(), expr.name())); | ||
| return lit( | ||
| bldr -> { | ||
| try { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This exception doesn't happen anymore because we don't parse the |
||
| bldr.setNullable(expr.nullable()) | ||
| .setUserDefined( | ||
| Expression.Literal.UserDefined.newBuilder() | ||
| .setTypeReference(typeReference) | ||
| .setValue(Any.parseFrom(expr.value()))) | ||
| .build(); | ||
| } catch (InvalidProtocolBufferException e) { | ||
| throw new IllegalStateException(e); | ||
| } | ||
| Expression.Literal.UserDefined.Builder userDefinedBuilder = | ||
| Expression.Literal.UserDefined.newBuilder() | ||
| .setTypeReference(typeReference) | ||
| .addAllTypeParameters( | ||
| expr.typeParameters().stream() | ||
| .map(typeProtoConverter::toProto) | ||
| .collect(java.util.stream.Collectors.toList())) | ||
| .setValue(expr.value()); | ||
|
|
||
| bldr.setNullable(expr.nullable()).setUserDefined(userDefinedBuilder).build(); | ||
| }); | ||
| } | ||
|
|
||
| @Override | ||
| public Expression visit( | ||
| io.substrait.expression.Expression.UserDefinedStructLiteral expr, | ||
| EmptyVisitationContext context) { | ||
| int typeReference = | ||
| extensionCollector.getTypeReference(SimpleExtension.TypeAnchor.of(expr.urn(), expr.name())); | ||
| return lit( | ||
| bldr -> { | ||
| Expression.Literal.Struct structLiteral = | ||
| Expression.Literal.Struct.newBuilder() | ||
| .addAllFields( | ||
| expr.fields().stream() | ||
| .map(this::toLiteral) | ||
| .collect(java.util.stream.Collectors.toList())) | ||
| .build(); | ||
|
|
||
| Expression.Literal.UserDefined.Builder userDefinedBuilder = | ||
| Expression.Literal.UserDefined.newBuilder() | ||
| .setTypeReference(typeReference) | ||
| .addAllTypeParameters( | ||
| expr.typeParameters().stream() | ||
| .map(typeProtoConverter::toProto) | ||
| .collect(java.util.stream.Collectors.toList())) | ||
| .setStruct(structLiteral); | ||
|
|
||
| bldr.setNullable(expr.nullable()).setUserDefined(userDefinedBuilder).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
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
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.
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.
Release Notes
We should call out that we don't construct UserDefinedLiterals anymore.