gengliangwang commented on a change in pull request #26780: [SPARK-27506][SQL] 
Allow deserialization of Avro data using compatible schemas 
URL: https://github.com/apache/spark/pull/26780#discussion_r356219806
 
 

 ##########
 File path: 
external/avro/src/main/scala/org/apache/spark/sql/avro/AvroDataToCatalyst.scala
 ##########
 @@ -51,9 +51,13 @@ case class AvroDataToCatalyst(
 
   override def nullable: Boolean = true
 
+  private lazy val avroOptions = AvroOptions(options)
+
   @transient private lazy val avroSchema = new 
Schema.Parser().parse(jsonFormatSchema)
 
-  @transient private lazy val reader = new GenericDatumReader[Any](avroSchema)
+  @transient private lazy val reader = avroOptions.actualSchema
+    .map(writer => new GenericDatumReader[Any](new 
Schema.Parser().parse(writer), avroSchema))
 
 Review comment:
   writer => acutalSchema

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