steven-aerts commented on code in PR #36506:
URL: https://github.com/apache/spark/pull/36506#discussion_r1056755944
##########
connector/avro/src/main/scala/org/apache/spark/sql/avro/AvroSerializer.scala:
##########
@@ -218,6 +218,17 @@ private[sql] class AvroSerializer(
val numFields = st.length
(getter, ordinal) => structConverter(getter.getStruct(ordinal,
numFields))
+ case (st: StructType, UNION) =>
+ val unionConvertor = newComplexUnionConverter(st, avroType,
catalystPath, avroPath)
Review Comment:
@gengliangwang this branch will only be hit if the resolved avro type is
determined to be of the type union.
For optional fields, so a union of a type with `null`. The [resolution
](https://github.com/apache/spark/pull/36506/files/1d950f55e85f11bfb85d9d57324d7ef7916b4a54#diff-e84c7dfce11df94178029c05a8427668c9dab4bb809ed6e362a39ff043a59f89R369)
already deterimined that it was not a union type and will hit the branches
another branch in this case. It is also why `newConverter` is almost always
called from a type generated by
[`resolveNullableType`](https://github.com/apache/spark/pull/36506/files/1d950f55e85f11bfb85d9d57324d7ef7916b4a54#diff-e84c7dfce11df94178029c05a8427668c9dab4bb809ed6e362a39ff043a59f89R358).
Let me know if this is not clear.
Btw, I missed you question somehow, sorry for the late reply.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]