MaxGekk commented on code in PR #41662:
URL: https://github.com/apache/spark/pull/41662#discussion_r1245142314


##########
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonSuite.scala:
##########
@@ -3225,6 +3225,21 @@ abstract class JsonSuite
       Row(null) :: Nil)
   }
 
+  test("SPARK-44079: fix incorrect result when parse array as struct " +
+    "using PERMISSIVE mode with corrupt record") {
+    val data = """[{"a": "incorrect", "b": "correct"}, {"a": "incorrect", "b": 
"correct"}]"""
+    val schema = new StructType(Array(StructField("a", IntegerType),
+      StructField("b", StringType), StructField("_corrupt_record", 
StringType)))
+
+    val result = spark.read.option("mode", "PERMISSIVE").option("multiline", 
"true").schema(schema)
+      .json(Seq(data).toDS()).collect()
+
+    assert(result.length == 2)
+    assert(result(0).getString(0) == null)
+    assert(result(0).getString(1) == "correct")
+    assert(result(0).getString(2) == data)

Review Comment:
   ```suggestion
       val result = spark.read
         .option("mode", "PERMISSIVE")
         .option("multiline", "true")
         .schema(schema)
         .json(Seq(data).toDS())
   
       checkAnswer(result, Seq(Row(null, "correct", data), Row(null, "correct", 
data)))
   ```



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to