dongjoon-hyun commented on a change in pull request #24635: [SPARK-27762][SQL] 
Support user provided avro schema for writing fields with different ordering
URL: https://github.com/apache/spark/pull/24635#discussion_r285326200
 
 

 ##########
 File path: 
external/avro/src/main/scala/org/apache/spark/sql/avro/AvroSerializer.scala
 ##########
 @@ -205,18 +205,28 @@ class AvroSerializer(rootCatalystType: DataType, 
rootAvroType: Schema, nullable:
       throw new IncompatibleSchemaException(s"Cannot convert Catalyst type 
$catalystStruct to " +
         s"Avro type $avroStruct.")
     }
-    val fieldConverters = catalystStruct.zip(avroStruct.getFields.asScala).map 
{
-      case (f1, f2) => newConverter(f1.dataType, 
resolveNullableType(f2.schema(), f1.nullable))
-    }
+
+    val (avroIndices: Array[Int], fieldConverters: Array[Converter]) =
+      catalystStruct.map { catalystField =>
+        val avroField = avroStruct.getField(catalystField.name)
+        if (avroField == null) {
 
 Review comment:
   To fix `enum` issue at 
https://github.com/apache/spark/pull/24635#discussion_r285326100, can we try to 
use the corresponding field at the same position when `avroField == null`?

----------------------------------------------------------------
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]

Reply via email to