dbatomic commented on code in PR #45592:
URL: https://github.com/apache/spark/pull/45592#discussion_r1537396548
##########
sql/core/src/test/scala/org/apache/spark/sql/CollationSuite.scala:
##########
@@ -638,7 +641,33 @@ class CollationSuite extends DatasourceV2SQLBase with
AdaptiveSparkPlanHelper {
parameters = Map(
"fieldName" -> "c2",
"expressionStr" -> "UCASE(struct1.a)",
- "reason" -> "generation expression cannot contain non-default collated
string type"))
+ "reason" ->
+ "generation expression cannot contain non-binary orderable collated
string type"))
+ }
+
+ test("SPARK-47431: Default collation set to UNICODE, literal test") {
+ withSQLConf(SqlApiConf.DEFAULT_COLLATION -> "UNICODE") {
+ checkAnswer(sql(s"SELECT collation('aa')"), Seq(Row("UNICODE")))
+ }
+ }
+
+ test("SPARK-47431: Check if config changes value") {
+ sql("SET spark.sql.session.collation.default=UNICODE")
+ checkAnswer(sql(s"SELECT collation('aa')"), Seq(Row("UNICODE")))
+ sql("SET spark.sql.session.collation.default=UTF8_BINARY")
+ checkAnswer(sql(s"SELECT collation('aa')"), Seq(Row("UTF8_BINARY")))
+ }
+
+ test("SPARK-47431: Default collation set to UNICODE, column type test") {
+ withSQLConf(SqlApiConf.DEFAULT_COLLATION -> "UNICODE") {
+ sql(
+ s"""
+ |CREATE TABLE t(c1 STRING)
Review Comment:
AFAIK in table metadata we will push explicit collation - `COLLATE UNICODE`.
The rules are following:
1) We take default session level collation if no collation is specified.
2) If collation is UTF8_BINARY (being it implicit through default collation
or explicit) we write `string` in metadata.
3) If collation is anything else we write `string collate collation_name` in
metadata.
When reading we don't care about session default collation. We will just
read whatever is in metadata.
--
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]