MaxGekk commented on code in PR #36298:
URL: https://github.com/apache/spark/pull/36298#discussion_r855790900
##########
sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala:
##########
@@ -364,6 +364,21 @@ class QueryCompilationErrorsSuite extends QueryTest with
SharedSparkSession {
}
}
}
+
+ test("INVALID_JSON_SCHEMA_MAPTYPE: " +
+ "Parse JSON rows can only contain StringType as a key type for a
MapType.") {
+ withTempPath { path =>
+ val schema = StructType(
+ StructField("map", MapType(IntegerType, IntegerType, true), false) ::
Nil)
+ val e = intercept[AnalysisException] {
+ spark.read.schema(schema).json(path.getCanonicalPath)
+ }
+ assert(e.getErrorClass === "INVALID_JSON_SCHEMA_MAPTYPE")
+ assert(e.getMessage ===
+ "Input schema
StructType(StructField(map,MapType(IntegerType,IntegerType,true),false)) " +
+ "can only contain StringType as a key type for a MapType.")
Review Comment:
Could you use the `checkErrorClass` method added by
https://github.com/apache/spark/pull/36287.
--
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]