Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22151#discussion_r211246084
  
    --- Diff: 
external/avro/src/main/scala/org/apache/spark/sql/avro/AvroSerializer.scala ---
    @@ -201,13 +201,11 @@ class AvroSerializer(rootCatalystType: DataType, 
rootAvroType: Schema, nullable:
     
       private def newStructConverter(
           catalystStruct: StructType, avroStruct: Schema): InternalRow => 
Record = {
    -    if (avroStruct.getType != RECORD) {
    +    if (avroStruct.getType != RECORD || avroStruct.getFields.size() != 
catalystStruct.length) {
           throw new IncompatibleSchemaException(s"Cannot convert Catalyst type 
$catalystStruct to " +
             s"Avro type $avroStruct.")
         }
    -    val avroFields = avroStruct.getFields
    -    assert(avroFields.size() == catalystStruct.length)
    --- End diff --
    
    I think he moved this condition above.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to