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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]