viirya commented on a change in pull request #27851: [SPARK-31071][SQL] Allow
annotating non-null fields when encoding Java Beans
URL: https://github.com/apache/spark/pull/27851#discussion_r390107102
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/SerializerBuildHelper.scala
##########
@@ -187,8 +187,12 @@ object SerializerBuildHelper {
val nonNullOutput = CreateNamedStruct(fields.flatMap { case(fieldName,
fieldExpr) =>
argumentsForFieldSerializer(fieldName, fieldExpr)
})
- val nullOutput = expressions.Literal.create(null, nonNullOutput.dataType)
- expressions.If(IsNull(inputObject), nullOutput, nonNullOutput)
+ if (inputObject.nullable) {
+ val nullOutput = expressions.Literal.create(null, nonNullOutput.dataType)
+ expressions.If(IsNull(inputObject), nullOutput, nonNullOutput)
Review comment:
In `createDataset`, we use the `schema` of current encoder to be the output
of `LocalRelation`. So the output schema is kept to be nullable.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]