dongjoon-hyun commented on a change in pull request #32147:
URL: https://github.com/apache/spark/pull/32147#discussion_r613756126
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonSuite.scala
##########
@@ -2844,6 +2844,25 @@ abstract class JsonSuite
assert(readback.collect sameElements Array(Row(0), Row(1), Row(2)))
}
}
+
+ test("Write Non-ASCII character as codepoint") {
+ // scalastyle:off nonascii
+ withTempPath { path =>
+ val basePath = path.getCanonicalPath
+ Seq("a", "\n", "\u3042").toDF.write
+ .option("writeNonAsciiCharacterAsCodePoint", "true").json(s"$basePath")
+ val actualText = spark.read.text(s"$basePath")
+ .sort("value").map(_.getString(0)).collect().mkString
+ val expectedText =
"{\"value\":\"\\n\"}{\"value\":\"\\u3042\"}{\"value\":\"a\"}"
+ assert(actualText === expectedText)
+
+ val actualJson = spark.read.json(s"$basePath")
+ .sort("value").map(_.getString(0)).collect().mkString
+ val expectedJson = "\na\u3042"
+ assert(actualJson === expectedJson)
+ }
+ // scalastyle:on nonascii
+ }
Review comment:
It would be great if we can have a test coverage for setting both pretty
and non-ascii-as-codepoint at the same time.
--
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]