You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/11/03 13:52:43 UTC

[GitHub] [spark] HyukjinKwon commented on a change in pull request #30224: [SPARK-33316][SQL] Support user provided nullable Avro schema for non-nullable catalyst schema in Avro writing

HyukjinKwon commented on a change in pull request #30224:
URL: https://github.com/apache/spark/pull/30224#discussion_r516381954



##########
File path: external/avro/src/test/scala/org/apache/spark/sql/avro/AvroSuite.scala
##########
@@ -1015,6 +1015,69 @@ abstract class AvroSuite
     }
   }
 
+  test("support user provided nullable avro schema " +
+    "for non-nullable catalyst schema without any null record") {
+    withTempPath { tempDir =>
+      val catalystSchema =
+        StructType(Seq(
+          StructField("Age", IntegerType, nullable = false),
+          StructField("Name", StringType, nullable = false)))
+
+      val avroSchema =
+        """
+          |{
+          |  "type" : "record",
+          |  "name" : "test_schema",
+          |  "fields" : [
+          |    {"name": "Age", "type": ["null", "int"]},
+          |    {"name": "Name", "type": ["null", "string"]}
+          |  ]
+          |}
+        """.stripMargin
+
+      val df = spark.createDataFrame(
+        spark.sparkContext.parallelize(Seq(Row(2, "Aurora"))), catalystSchema)
+
+      val tempSavePath = s"$tempDir/save/${UUID.randomUUID()}"

Review comment:
       then I think we can just use a name like foo, boo, zoo :-)




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org