-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-52281][SQL] Change ALTER TABLE ALTER COLUMN TYPE STRING not to apply default collation if original data type was instance of StringType
#51001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ALTER TABLE ALTER COLUMN TYPE STRING not to apply default collation if original data type was instance of StringTypeALTER TABLE ALTER COLUMN TYPE STRING not to apply default collation if original data type was instance of StringType
|
@cloud-fan can you please review? |
sql/core/src/test/scala/org/apache/spark/sql/collation/DefaultCollationTestSuite.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/scala/org/apache/spark/sql/collation/DefaultCollationTestSuite.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/scala/org/apache/spark/sql/collation/DefaultCollationTestSuite.scala
Outdated
Show resolved
Hide resolved
...rc/main/scala/org/apache/spark/sql/catalyst/analysis/ApplyDefaultCollationToStringType.scala
Outdated
Show resolved
Hide resolved
b40ed07 to
7a39330
Compare
e7e8c33 to
85680fe
Compare
sql/core/src/test/scala/org/apache/spark/sql/execution/command/CharVarcharDDLTestBase.scala
Outdated
Show resolved
Hide resolved
3e929ec to
f9081c3
Compare
...rc/main/scala/org/apache/spark/sql/catalyst/analysis/ApplyDefaultCollationToStringType.scala
Outdated
Show resolved
Hide resolved
c3dbcd0 to
1679aed
Compare
...rc/main/scala/org/apache/spark/sql/catalyst/analysis/ApplyDefaultCollationToStringType.scala
Outdated
Show resolved
Hide resolved
...rc/main/scala/org/apache/spark/sql/catalyst/analysis/ApplyDefaultCollationToStringType.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need it? resolveAlterColumnsDataType removes the newDataType already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part applies default collation to dataType. resolveAlterColumnsDataType just removed dataType if alter column was noop. resolveAlterColumnsDataType isn't really best name since it doesn't fully resolve dataType, so I changed name
1679aed to
3acf439
Compare
3acf439 to
1d6fa46
Compare
|
thanks, merging to master! |
|
@ilicmarkodb is this bug present in spark 4.0? |
…to apply default collation if original data type was instance of `StringType` ### What changes were proposed in this pull request? Changed `ALTER TABLE ALTER COLUMN TYPE STRING` not to apply default collation if original data type was instance of `StringType`. ``` CREATE TABLE T (C1 CHAR/VARCHAR); ALTER TABLE T DEFAULT COLLATION UTF8_LCASE; ALTER TABLE T ALTER COLUMN C1 TYPE STRING COLLATE UTF8_LCASE; ----------------------------------------------------------------------------------- CREATE TABLE T (C1 STRING [COLLATE XYZ]) ALTER TABLE T DEFAULT COLLATION UTF8_LCASE ALTER TABLE T ALTER COLUMN C1 TYPE STRING // C1 -> STRING [COLLATE XYZ] ``` ### Why are the changes needed? Bug fix. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Tests added to `DefaultCollationTestSuite`. ### Was this patch authored or co-authored using generative AI tooling? No. Closes apache#51001 from ilicmarkodb/fix_alter_colum_with_collation. Authored-by: ilicmarkodb <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
What changes were proposed in this pull request?
Changed
ALTER TABLE ALTER COLUMN TYPE STRINGnot to apply default collation if original data type was instance ofStringType.Why are the changes needed?
Bug fix.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Tests added to
DefaultCollationTestSuite.Was this patch authored or co-authored using generative AI tooling?
No.