You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/05/18 03:23:14 UTC

[GitHub] [spark] viirya commented on a change in pull request #24635: [SPARK-27762][SQL] Support user provided avro schema for writing fields with different ordering

viirya 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_r285327314
 
 

 ##########
 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:
   When converting catalyst struct "a int, b int" -> avro type "b int, c int", we will update only the first avro field.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org