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 16:01:20 UTC
[GitHub] [spark] gengliangwang commented on a diff in pull request #36122: [SPARK-38838][SQL] Support ALTER TABLE ALTER COLUMN commands with DEFAULT values
gengliangwang commented on code in PR #36122:
URL: https://github.com/apache/spark/pull/36122#discussion_r859976501
##########
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:
What if the column is string type and the default value is set as `""`?
--
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