ilicmarkodb commented on code in PR #51001:
URL: https://github.com/apache/spark/pull/51001#discussion_r2107403074


##########
sql/core/src/test/scala/org/apache/spark/sql/collation/DefaultCollationTestSuite.scala:
##########
@@ -128,10 +128,23 @@ abstract class DefaultCollationTestSuite extends 
QueryTest with SharedSparkSessi
       sql(s"ALTER TABLE $testTable ALTER COLUMN c1 TYPE STRING COLLATE 
UNICODE_CI")
       assertTableColumnCollation(testTable, "c1", "UNICODE_CI")
 
+      // alter table alter column should inherit the table collation only if 
the column was not
+      // originally of a string type
+      sql(s"ALTER TABLE $testTable ALTER COLUMN c1 TYPE STRING")
+      assertTableColumnCollation(testTable, "c1", "UTF8_BINARY")
+
       // alter table add columns with explicit collation, check collation for 
each column
       sql(s"ALTER TABLE $testTable ADD COLUMN c7 STRING COLLATE SR_CI_AI")
       sql(s"ALTER TABLE $testTable ADD COLUMN c8 STRING COLLATE UTF8_BINARY")
-      assertTableColumnCollation(testTable, "c1", "UNICODE_CI")
+      assertTableColumnCollation(testTable, "c7", "SR_CI_AI")
+      assertTableColumnCollation(testTable, "c8", "UTF8_BINARY")
+
+      // alter table alter column should inherit the table collation only if 
the column was not
+      // originally of a string type
+      sql(s"ALTER TABLE $testTable ALTER COLUMN c8 TYPE STRING")

Review Comment:
   I think it isn't possible.
   
https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala#L467
   This method is used in `AlterTableChangeColumnCommand` which is called for 
this command.



-- 
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

Reply via email to