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

    https://github.com/apache/spark/pull/22251#discussion_r213231887
  
    --- Diff: 
external/avro/src/main/scala/org/apache/spark/sql/avro/SchemaConverters.scala 
---
    @@ -143,29 +143,25 @@ object SchemaConverters {
             val avroType = LogicalTypes.decimal(d.precision, d.scale)
             val fixedSize = minBytesForPrecision(d.precision)
             // Need to avoid naming conflict for the fixed fields
    -        val name = prevNameSpace match {
    +        val name = nameSpace match {
               case "" => s"$recordName.fixed"
    -          case _ => s"$prevNameSpace.$recordName.fixed"
    +          case _ => s"$nameSpace.$recordName.fixed"
             }
             avroType.addToSchema(SchemaBuilder.fixed(name).size(fixedSize))
     
           case BinaryType => builder.bytesType()
           case ArrayType(et, containsNull) =>
             builder.array()
    -          .items(toAvroType(et, containsNull, recordName, prevNameSpace))
    +          .items(toAvroType(et, containsNull, recordName, nameSpace))
           case MapType(StringType, vt, valueContainsNull) =>
             builder.map()
    -          .values(toAvroType(vt, valueContainsNull, recordName, 
prevNameSpace))
    +          .values(toAvroType(vt, valueContainsNull, recordName, nameSpace))
           case st: StructType =>
    -        val nameSpace = prevNameSpace match {
    -          case "" => recordName
    -          case _ => s"$prevNameSpace.$recordName"
    -        }
    -
    +        val childNameSpace = if (nameSpace != "") 
s"$nameSpace.$recordName" else recordName
             val fieldsAssembler = 
builder.record(recordName).namespace(nameSpace).fields()
    --- End diff --
    
    +1, this line is the only difference for the whole code change. The 
namespace here should not be the one with `recordName` at the end.


---

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

Reply via email to