[SPARK-41690][SQL][CONNECT] Agnostic Encoders#39186
Closed
hvanhovell wants to merge 5 commits intoapache:masterfrom
Closed
[SPARK-41690][SQL][CONNECT] Agnostic Encoders#39186hvanhovell wants to merge 5 commits intoapache:masterfrom
hvanhovell wants to merge 5 commits intoapache:masterfrom
Conversation
hvanhovell
commented
Dec 22, 2022
| |The type path of the target object is: | ||
| |- array element class: "scala.Long" | ||
| |- field (class: "scala.Array", name: "arr") | ||
| |- array element class: "long" |
Contributor
Author
There was a problem hiding this comment.
This is a side effect of not having the same type information when creating the deserializer.
cloud-fan
reviewed
Dec 23, 2022
| typePath: WalkedTypePath): Expression = enc match { | ||
| case _ if isNativeEncoder(enc) => | ||
| input | ||
| case BooleanEncoder => |
Contributor
There was a problem hiding this comment.
aren't these handled by case _ if isNativeEncoder(enc) => already?
Contributor
There was a problem hiding this comment.
nvm, we have PrimitiveBooleanEncoder and BooleanEncoder
Contributor
There was a problem hiding this comment.
maybe BoxedBooleanEncoder is a better name
cloud-fan
approved these changes
Dec 27, 2022
Contributor
|
thanks, merging to master! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changes were proposed in this pull request?
This PR introduces so AgnosticEncoders. AgnosticEncoders describe how an external type maps to a Spark data type. They are agnostic in the sense that they do not prescribe which internal format is to be used.
For example the following class:
Translates into the following agnostic encoder:
This PR integrates
AgnosticEncodersinScalaReflection, and so it is used for allDatasetoperations. In a follow-up we will addressRowEncoderandJavaReflection. In the old situation we would traverse the type hierarchy for each options (serializedForType,deserializerForType&schemaFor). In the new situation we will create an AgnosticEncoder first and then generate a serializer, deserializer, and/orschema. This saves significantly in time, especially forExpressionEncoderwhere we only need one pass through the type hierarchy instead 2 or 3.Why are the changes needed?
For the Spark Connect Scala Client we need encoders. We want to stay as close to the current Dataset APIs and encoders are part of this. Additionally we would like retain the rich type support.
Encoders are currently tied to ExpressionEncoders, we cannot use for a couple of reasons:
So we need an alternative to the current ExpressionEncoders. This class need to be serializable.
Does this PR introduce any user-facing change?
No
How was this patch tested?
Existing tests.