Github user viirya commented on a diff in the pull request:
https://github.com/apache/spark/pull/9759#discussion_r45135290
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonParsingOptionsSuite.scala
---
@@ -93,22 +93,29 @@ class JsonParsingOptionsSuite extends QueryTest with
SharedSQLContext {
assert(df.first().getLong(0) == 18)
}
- // The following two tests are not really working - need to look into
Jackson's
- // JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS.
- ignore("allowNonNumericNumbers off") {
- val str = """{"age": NaN}"""
- val rdd = sqlContext.sparkContext.parallelize(Seq(str))
- val df = sqlContext.read.json(rdd)
+ test("allowNonNumericNumbers off") {
+ val testCases: Seq[String] = Seq("""{"age": NaN}""", """{"age":
Infinity}""",
+ """{"age": -Infinity}""")
- assert(df.schema.head.name == "_corrupt_record")
+ testCases.foreach { str =>
+ val rdd = sqlContext.sparkContext.parallelize(Seq(str))
+ val df = sqlContext.read.option("allowNonNumericNumbers",
"false").json(rdd)
+
+ assert(df.schema.head.name == "_corrupt_record")
+ }
}
- ignore("allowNonNumericNumbers on") {
- val str = """{"age": NaN}"""
- val rdd = sqlContext.sparkContext.parallelize(Seq(str))
- val df = sqlContext.read.option("allowNonNumericNumbers",
"true").json(rdd)
+ test("allowNonNumericNumbers on") {
+ val testCases: Seq[String] = Seq("""{"age": NaN}""", """{"age":
Infinity}""",
--- End diff --
If we don't set `JsonGenerator.Feature.QUOTE_NON_NUMERIC_NUMBERS` to false,
we can't read them normally.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]