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

 ##########
 File path: 
external/avro/src/test/scala/org/apache/spark/sql/avro/AvroFunctionsSuite.scala
 ##########
 @@ -153,4 +153,79 @@ class AvroFunctionsSuite extends QueryTest with 
SharedSparkSession {
       assert(df.collect().map(_.get(0)) === Seq(Row("one"), Row("two"), 
Row("three"), Row("four")))
     }
   }
+
+  test("SPARK-27506: roundtrip in to_avro and from_avro with different 
compatible schemas") {
+    val df = spark.range(10).select(
+      struct('id.as("col1"), 'id.cast("string").as("col2")).as("struct")
+    )
+    val avroStructDF = df.select(functions.to_avro('struct).as("avro"))
+    val actualAvroSchema = s"""
+                              |{
+                              |  "type": "record",
+                              |  "name": "struct",
+                              |  "fields": [
+                              |    {"name": "col1", "type": "int"},
+                              |    {"name": "col2", "type": "string"}
+                              |  ]
+                              |}
 
 Review comment:
   I've also looked through the codebase of Spark, but it is rather incoherent. 
Please let me know if you want to change it, and I'll update it right away.

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

Reply via email to