dejankrak-db commented on code in PR #49772:
URL: https://github.com/apache/spark/pull/49772#discussion_r1949615560
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveDefaultStringTypes.scala:
##########
@@ -79,18 +79,37 @@ object ResolveDefaultStringTypes extends Rule[LogicalPlan] {
expression.exists(e => transformExpression.isDefinedAt(e))
}
- private def isDefaultSessionCollationUsed: Boolean = conf.defaultStringType
== StringType
+ /** Default string type is UTF8_BINARY */
+ private def defaultStringType: StringType = StringType("UTF8_BINARY")
- /**
- * Returns the default string type that should be used in a given DDL
command (for now always
- * UTF8_BINARY).
- */
- private def stringTypeForDDLCommand(table: LogicalPlan): StringType =
- StringType("UTF8_BINARY")
+ /** Returns the default string type that should be used in a given DDL
command */
+ private def stringTypeForDDLCommand(table: LogicalPlan): StringType = {
+ if (table.isInstanceOf[CreateTable]) {
+ if (table.asInstanceOf[CreateTable].tableSpec.collation.isDefined) {
+ return
StringType(table.asInstanceOf[CreateTable].tableSpec.collation.get)
+ }
+ }
+ else if (table.isInstanceOf[CreateView]) {
+ if (table.asInstanceOf[CreateView].collation.isDefined) {
+ return StringType(table.asInstanceOf[CreateView].collation.get)
+ }
+ }
+ else if (table.isInstanceOf[AlterTableCommand]) {
+ if (table.asInstanceOf[AlterTableCommand].table.resolved) {
+ val collation = Option(table.asInstanceOf[AlterTableCommand]
+ .table.asInstanceOf[ResolvedTable]
+ .table.properties.get(TableCatalog.PROP_COLLATION))
+ if (collation.isDefined) {
+ return StringType(collation.get)
+ }
+ }
+ }
+ defaultStringType
+ }
- /** Returns the session default string type */
- private def sessionDefaultStringType: StringType =
- StringType(conf.defaultStringType.collationId)
+ /** Returns the session default string type used for DML queries */
Review Comment:
Removed and clarified the comment in the new rule for DDL collation
resolution.
--
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]