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_r285804966
########## 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: +1 for that. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org