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 2021/08/02 08:53:10 UTC
[GitHub] [spark] dongjoon-hyun commented on a change in pull request #33608: [SPARK-36379][SQL] Null at root level of a JSON array should not fail w/ permissive mode
dongjoon-hyun commented on a change in pull request #33608:
URL: https://github.com/apache/spark/pull/33608#discussion_r680792268
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonSuite.scala
##########
@@ -2944,6 +2944,19 @@ abstract class JsonSuite
}
}
}
+
+ test("SPARK-36379: proceed parsing with root nulls in permissive mode") {
+ assert(intercept[SparkException] {
+ spark.read.option("mode", "failfast")
+ .schema("a string").json(Seq("""[{"a": "str"}, null]""").toDS).collect()
+ }.getMessage.contains("Malformed records are detected"))
+
+ // Permissive modes should proceed parsing malformed records (null).
+ // Here, since an array fails to parse in the middle, we will return one row.
+ checkAnswer(
+ spark.read.json(Seq("""[{"a": "str"}, null, {"a": "str"}]""").toDS),
Review comment:
Although `PERMISSIVE`is the default, shall we use `.option("mode", "permissive")` explicitly because this is a test case?
--
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: reviews-unsubscribe@spark.apache.org
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