Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19124#discussion_r137174337
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala ---
    @@ -206,6 +206,9 @@ case class AlterTableAddColumnsCommand(
           reorderedSchema.map(_.name), "in the table definition of " + 
table.identifier,
           conf.caseSensitiveAnalysis)
     
    +    val newDataSchema = StructType(catalogTable.dataSchema ++ columns)
    +    DDLUtils.checkFieldNames(catalogTable.copy(schema = newDataSchema))
    --- End diff --
    
    Is it okay to use the following?
    ```scala
        val reorderedSchema = catalogTable.dataSchema ++ columns ++ 
catalogTable.partitionSchema
        val newDataSchema = StructType(catalogTable.dataSchema ++ columns)
    
        SchemaUtils.checkColumnNameDuplication(
          reorderedSchema.map(_.name), "in the table definition of " + 
table.identifier,
          conf.caseSensitiveAnalysis)
        DDLUtils.checkFieldNames(catalogTable.copy(schema = newDataSchema))
    
        catalog.alterTableSchema(
          table, catalogTable.schema.copy(fields = reorderedSchema.toArray))
    ```


---

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

Reply via email to