MaxGekk commented on code in PR #36320:
URL: https://github.com/apache/spark/pull/36320#discussion_r855790359
##########
sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala:
##########
@@ -373,4 +373,29 @@ class QueryExecutionErrorsSuite extends QueryTest
assert(e2.getMessage.matches("Failed to execute user defined function " +
"\\(QueryExecutionErrorsSuite\\$\\$Lambda\\$\\d+/\\w+: \\(string, int\\)
=> string\\)"))
}
+
+ test("INCOMPARABLE_PIVOT_COLUMN: Pivot columns can't be comparable") {
+ withSQLConf() {
+ val e = intercept[AnalysisException] {
+ trainingSales
+ sql(
+ """
+ | select * from (
+ | select *,map(sales.course, sales.year) as map
+ | from trainingSales
+ | )
+ | pivot (
+ | sum(sales.earnings) as sum
+ | for map in (
+ | map("dotNET", 2012), map("JAVA", 2012),
+ | map("dotNet", 2013), map("Java", 2013)
+ | ))
+ |""".stripMargin).collect()
+ }
+ assert(e.getErrorClass === "INCOMPARABLE_PIVOT_COLUMN")
+ assert(e.getSqlState === "42000")
+ assert(e.getMessage.matches("Invalid pivot column 'map.*\\'. " +
+ "Pivot columns must be comparable."))
Review Comment:
Could you use the `checkErrorClass` method added by
https://github.com/apache/spark/pull/36287. BTW, the method checks the tag in
error messages.
--
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]