uros-db commented on code in PR #48121:
URL: https://github.com/apache/spark/pull/48121#discussion_r1764771319
##########
sql/core/src/test/scala/org/apache/spark/sql/CollationSuite.scala:
##########
@@ -1625,6 +1626,63 @@ class CollationSuite extends DatasourceV2SQLBase with
AdaptiveSparkPlanHelper {
}
}
+ test("Expressions not supporting CS_AI collators") {
+ val unsupportedExpressions: Seq[Any] = Seq(
+ "ltrim",
+ "rtrim",
+ "trim",
+ "startswith",
+ "endswith",
+ "locate",
+ "instr",
+ "str_to_map",
+ "contains",
+ "replace",
+ ("translate", "efg"),
+ ("split_part", "2"),
+ ("substring_index", "2"))
+
+ val unsupportedCollator = "unicode_ai"
+ val supportedCollators: Seq[String] = Seq("unicode", "unicode_ci",
"unicode_ci_ai")
+
+ unsupportedExpressions.foreach {
+ expression: Any =>
+ val unsupportedQuery: String = {
+ expression match {
+ case expression: String =>
+ s"select $expression('bcd' collate $unsupportedCollator, 'abc')"
+ case (expression: String, parameter: String) =>
+ s"select $expression('bcd' collate $unsupportedCollator, 'abc',
'$parameter')"
+ case (expression: String, parameter: Integer) =>
+ s"select $expression('bcd' collate $unsupportedCollator, 'abc',
$parameter)"
+ }
+ }
+
+ val analysisException = intercept[AnalysisException] {
+ sql(unsupportedQuery).collect()
+ }
+ assert(analysisException.getErrorClass ===
"DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE")
Review Comment:
use `checkError` (see examples elsewhere in the codebase) instead of
`assert(analysisException.getErrorClass`
--
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]