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



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala
##########
@@ -184,15 +189,62 @@ abstract class JdbcDialect extends Serializable {
   /**
    * Rename an existing table.
    *
-   * TODO (SPARK-32382): Override this method in the dialects that don't 
support such syntax.
-   *
    * @param oldTable The existing table.
    * @param newTable New name of the table.
    * @return The SQL statement to use for renaming the table.
    */
   def renameTable(oldTable: String, newTable: String): String = {
     s"ALTER TABLE $oldTable RENAME TO $newTable"
   }
+
+  /**
+   * Alter an existing table.
+   * TODO (SPARK-32523): Override this method in the dialects that have 
different syntax.
+   *
+   * @param tableName The name of the table to be altered.
+   * @param changes Changes to apply to the table.
+   * @return The SQL statements to use for altering the table.
+   */
+  def alterTable(tableName: String, changes: Seq[TableChange]): Array[String] 
= {
+    val updateClause = ArrayBuilder.make[String]
+    for (change <- changes) {
+      change match {
+        case add: AddColumn =>
+          add.fieldNames match {
+            case Array(name) =>

Review comment:
       @cloud-fan I changed code to what you suggested.
   We don't support nested column in JDBC yet. In `JdbcUtils.getCatalystType`, 
we map `java.sql.Types.STRUCT        => StringType`. In `getCommonJDBCType`, we 
don't  have a match case for StructType and the default is None. Seems to me 
currently it is not possible to reach the code path of multiple parts 
fieldNames in `JdbcDialects.alterTable`, so I will not have a negative test 
case for this code path for now.




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