-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-49960][SQL] Custom ExpressionEncoder support and TransformingEncoder fixes #50023
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
Changes from all commits
db54298
1a20169
cff4eeb
99422bb
6785504
8da83ad
9260516
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ import org.apache.spark.SparkRuntimeException | |
| import org.apache.spark.sql.{Encoder, Row} | ||
| import org.apache.spark.sql.catalyst.{DeserializerBuildHelper, InternalRow, JavaTypeInference, ScalaReflection, SerializerBuildHelper} | ||
| import org.apache.spark.sql.catalyst.analysis.{Analyzer, GetColumnByOrdinal, SimpleAnalyzer, UnresolvedAttribute, UnresolvedExtractValue} | ||
| import org.apache.spark.sql.catalyst.encoders.AgnosticEncoders.{OptionEncoder, TransformingEncoder} | ||
| import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder.{Deserializer, Serializer} | ||
| import org.apache.spark.sql.catalyst.expressions._ | ||
| import org.apache.spark.sql.catalyst.expressions.objects.AssertNotNull | ||
|
|
@@ -215,6 +216,13 @@ case class ExpressionEncoder[T]( | |
| StructField(s.name, s.dataType, s.nullable) | ||
| }) | ||
|
|
||
| private def transformerOfOption(enc: AgnosticEncoder[_]): Boolean = | ||
| enc match { | ||
| case t: TransformingEncoder[_, _] => transformerOfOption(t.transformed) | ||
| case _: OptionEncoder[_] => true | ||
| case _ => false | ||
| } | ||
|
|
||
| /** | ||
| * Returns true if the type `T` is serialized as a struct by `objSerializer`. | ||
| */ | ||
|
|
@@ -228,7 +236,8 @@ case class ExpressionEncoder[T]( | |
| * returns true if `T` is serialized as struct and is not `Option` type. | ||
| */ | ||
| def isSerializedAsStructForTopLevel: Boolean = { | ||
| isSerializedAsStruct && !classOf[Option[_]].isAssignableFrom(clsTag.runtimeClass) | ||
| isSerializedAsStruct && !classOf[Option[_]].isAssignableFrom(clsTag.runtimeClass) && | ||
|
Contributor
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.
Contributor
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. I am wondering if we should make these checks part of the AgnosticEncoder api.
Contributor
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. I think it'd make sense, for the path encoder backwards compat logic I can embed / document that in shim. The Builders could embed that. I can take a stab at that post rc2. |
||
| !transformerOfOption(encoder) | ||
| } | ||
|
|
||
| // serializer expressions are used to encode an object to a row, while the object is usually an | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.