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

    https://github.com/apache/spark/pull/19773#discussion_r151739604
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala ---
    @@ -318,16 +318,28 @@ case class AlterTableChangeColumnCommand(
               s"'${newColumn.name}' with type '${newColumn.dataType}'")
         }
     
    +    val changeSchema = originColumn.dataType != newColumn.dataType
         val newSchema = table.schema.fields.map { field =>
           if (field.name == originColumn.name) {
    -        // Create a new column from the origin column with the new comment.
    -        addComment(field, newColumn.getComment)
    +        var newField = field
    --- End diff --
    
    I'd recommend getting rid of this `var` and re-writting the code as follows:
    
    ```
    val newField = newColumn.getComment.map(...).getOrElse(field)
    ```


---

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

Reply via email to