You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/04/27 21:27:02 UTC

[GitHub] [spark] dtenedor commented on a diff in pull request #36122: [SPARK-38838][SQL] Support ALTER TABLE ALTER COLUMN commands with DEFAULT values

dtenedor commented on code in PR #36122:
URL: https://github.com/apache/spark/pull/36122#discussion_r860258269


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala:
##########
@@ -353,7 +353,18 @@ case class AlterTableChangeColumnCommand(
     val newDataSchema = table.dataSchema.fields.map { field =>
       if (field.name == originColumn.name) {
         // Create a new column from the origin column with the new comment.
-        addComment(field, newColumn.getComment)
+        val withNewComment: StructField =
+          addComment(field, newColumn.getComment)
+        // Create a new column from the origin column with the new current default value.
+        if (newColumn.getCurrentDefaultValue().isDefined) {
+          if (newColumn.getCurrentDefaultValue().get.nonEmpty) {
+            addCurrentDefaultValue(withNewComment, newColumn.getCurrentDefaultValue())
+          } else {
+            withNewComment.clearCurrentDefaultValue()

Review Comment:
   Good question. I confirmed that the parser returns the quotes in the default value string, and that passing in a completely empty string is prohibited (since the parser expects a token there). I added a couple unit tests to the `DDLParserSuite` to cover this.



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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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