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: [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]