Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15717#discussion_r92117267
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala ---
    @@ -274,6 +274,76 @@ case class AlterTableUnsetPropertiesCommand(
     
     }
     
    +
    +/**
    + * A command to change the columns for a table, only support changing the 
comments of non-partition
    + * columns for now.
    + *
    + * The syntax of using this command in SQL is:
    + * {{{
    + *   ALTER TABLE table_identifier
    + *   CHANGE [COLUMN] column_old_name column_new_name column_dataType 
[COMMENT column_comment]
    + *   [FIRST | AFTER column_name];
    + * }}}
    + */
    +case class AlterTableChangeColumnsCommand(
    +    tableName: TableIdentifier,
    +    columns: Map[String, StructField]) extends RunnableCommand {
    +
    +  // TODO: support change column name/dataType/metadata/position.
    +  override def run(sparkSession: SparkSession): Seq[Row] = {
    +    val catalog = sparkSession.sessionState.catalog
    +    val table = catalog.getTableMetadata(tableName)
    +    val resolver = sparkSession.sessionState.conf.resolver
    +    DDLUtils.verifyAlterTableType(catalog, table, isView = false)
    +
    +    // Create a map that converts the origin column to the new column with 
changed comment, throw
    +    // a Exception if the column reference is invalid or the column 
name/dataType is changed.
    +    val columnsMap = columns.map { case (oldName: String, newField: 
StructField) =>
    +      // Find the origin column from schema by column name.
    +      val originColumn = findColumn(table.schema, oldName, resolver)
    +      // Throw a Exception if the column name/dataType is changed.
    --- End diff --
    
    Nit: please correct `a Exception` to `an exception` in all the comments you 
added. Thanks!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to