stefankandic commented on code in PR #48750:
URL: https://github.com/apache/spark/pull/48750#discussion_r1828130698
##########
sql/core/src/test/scala/org/apache/spark/sql/CollationSQLExpressionsSuite.scala:
##########
@@ -3173,6 +3174,41 @@ class CollationSQLExpressionsSuite
})
}
+ test("from_json and from_xml transformations with session collation") {
+ val spark = this.spark
+ import spark.implicits._
+
+ def checkSchema(
+ dataset: Dataset[String],
+ transformation: Column,
+ expectedSchema: StructType): Unit = {
+ val transformedSchema =
dataset.select(transformation.as("result")).schema
+ assert(transformedSchema === expectedSchema)
+ }
+
+ withSQLConf(SqlApiConf.DEFAULT_COLLATION -> "UNICODE_CI_AI") {
+ Seq(
+ StringType,
+ StringType("UTF8_BINARY"),
+ StringType("UNICODE"),
+ StringType("UNICODE_CI_AI"),
+ ).foreach { stringType =>
+ val dataSchema = StructType(Seq(StructField("fieldName", stringType)))
+ val expectedSchema = StructType(Seq(StructField("result", dataSchema)))
+
+ // JSON Test
+ val jsonData = Seq("""{"fieldName": "fieldValue"}""")
+ val jsonDataset = spark.createDataset(jsonData)
+ checkSchema(jsonDataset, from_json($"value", dataSchema),
expectedSchema)
Review Comment:
makes sense, done!
--
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]