uros-db commented on code in PR #46474: URL: https://github.com/apache/spark/pull/46474#discussion_r1599500946
########## sql/core/src/test/scala/org/apache/spark/sql/CollationSuite.scala: ########## @@ -851,6 +852,30 @@ class CollationSuite extends DatasourceV2SQLBase with AdaptiveSparkPlanHelper { } } + test("SPARK-47972: Cast expression limitation for collations") { + checkError( + exception = intercept[ParseException] + (sql("SELECT cast(1 as string collate unicode)")), + errorClass = "UNSUPPORTED_DATATYPE", + parameters = Map( + "typeName" -> toSQLType(StringType("UNICODE"))), + context = + ExpectedContext(fragment = s"cast(1 as string collate unicode)", start = 7, stop = 39) + ) + + checkError( + exception = intercept[ParseException] + (sql("SELECT 'A' :: string collate unicode")), + errorClass = "UNSUPPORTED_DATATYPE", + parameters = Map( + "typeName" -> toSQLType(StringType("UNICODE"))), + context = ExpectedContext(fragment = s"'A' :: string collate unicode", start = 7, stop = 35) + ) + + checkAnswer(sql(s"SELECT cast(1 as string)"), Seq(Row("1"))) + checkAnswer(sql(s"SELECT cast('A' as string)"), Seq(Row("A"))) + } Review Comment: just wondering, how does this cope with something like: ``` withSQLConf(SqlApiConf.DEFAULT_COLLATION -> "UNICODE") { checkAnswer(sql(s"SELECT cast(1 as string)"), Seq(Row("1"))) } ``` -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org