You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/10/28 17:07:04 UTC

[GitHub] [spark] huaxingao commented on a change in pull request #30142: [SPARK-33095] Follow up, support alter table column rename.

huaxingao commented on a change in pull request #30142:
URL: https://github.com/apache/spark/pull/30142#discussion_r513616044



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/jdbc/MySQLDialect.scala
##########
@@ -57,6 +58,25 @@ private case object MySQLDialect extends JdbcDialect {
     s"ALTER TABLE $tableName MODIFY COLUMN ${quoteIdentifier(columnName)} $newDataType"
   }
 
+  // See Old Syntax: https://dev.mysql.com/doc/refman/5.6/en/alter-table.html
+  // According to https://dev.mysql.com/worklog/task/?id=10761 old syntax works for
+  // both versions of MySQL i.e. 5.x and 8.0
+  // The old syntax requires us to have type definition. Since we do not have type
+  // information, we throw the exception.
+  override def getRenameColumnQuery(
+      tableName: String,
+      columnName: String,
+      newName: String): String = {
+    if (SQLConf.get.jdbcMySQLVersion.matches("^8\\.[0-9].*")) {

Review comment:
       Instead of using a session config, we probably want to get database version using `DatabaseMetaData` in `JdbcUtils.altertable` and pass the info here, and only do `RENAME` if version >= 8
   ```
   conn.getMetaData.getDatabaseMajorVersion
   ```




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org