mihailom-db commented on code in PR #45819:
URL: https://github.com/apache/spark/pull/45819#discussion_r1555608196
##########
sql/core/src/test/scala/org/apache/spark/sql/CollationSuite.scala:
##########
@@ -645,6 +646,34 @@ class CollationSuite extends DatasourceV2SQLBase with
AdaptiveSparkPlanHelper {
},
errorClass = "COLLATION_MISMATCH.IMPLICIT"
)
+
+ // check if substring passes through implicit collation
+ checkError(
+ exception = intercept[AnalysisException] {
+ sql(s"SELECT substr('a' COLLATE UNICODE, 0, 1) == substr('b' COLLATE
UNICODE_CI, 0, 1)")
+ },
+ errorClass = "COLLATION_MISMATCH.IMPLICIT"
+ )
+
+ checkAnswer(spark.sql("SELECT collation(:var1 || :var2)",
+ Map(
+ "var1" -> Literal.create("a", StringType(1)),
+ "var2" -> Literal.create("b", StringType(2))
+ )
+ ),
+ Seq(Row("UTF8_BINARY"))
+ )
+
+ withSQLConf(SqlApiConf.DEFAULT_COLLATION -> "UNICODE") {
+ checkAnswer(spark.sql("SELECT collation(:var1 || :var2)",
+ Map(
+ "var1" -> Literal.create("a", StringType(1)),
+ "var2" -> Literal.create("b", StringType(2))
+ )
+ ),
+ Seq(Row("UNICODE"))
+ )
+ }
Review Comment:
Why I ask this is because by implementation we are using Parameter which
binds an Expression to a name/postition depending on the query type. Allowed
expression can be CreateArray, which produces implicit collated elementType,
should we cast it to default if the value comes from a parameter. The thing is
that if I only cast the flag to defaultST, I might get two arrays of different
collationId, but same priority of DafaultST. Current implementation casts any
StringType or ArrayType(StringType) to session level default StringType/
ArrayType with that session level default StringType.
--
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]