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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to