Skip to content

Commit 3c77234

Browse files
gatorsmilewangzejie
authored andcommitted
[SPARK-21112][SQL] ALTER TABLE SET TBLPROPERTIES should not overwrite COMMENT
### What changes were proposed in this pull request? `ALTER TABLE SET TBLPROPERTIES` should not overwrite `COMMENT` even if the input property does not have the property of `COMMENT`. This PR is to fix the issue. ### How was this patch tested? Covered by the existing tests. Author: Xiao Li <gatorsmile@gmail.com> Closes apache#18318 from gatorsmile/fixTableComment.
1 parent 6e74008 commit 3c77234

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ case class AlterTableSetPropertiesCommand(
235235
// direct property.
236236
val newTable = table.copy(
237237
properties = table.properties ++ properties,
238-
comment = properties.get("comment"))
238+
comment = properties.get("comment").orElse(table.comment))
239239
catalog.alterTable(newTable)
240240
Seq.empty[Row]
241241
}

sql/core/src/test/resources/sql-tests/results/describe.sql.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ Provider parquet
127127
Num Buckets 2
128128
Bucket Columns [`a`]
129129
Sort Columns [`b`]
130+
Comment table_comment
130131
Table Properties [e=3]
131132
Location [not included in comparison]sql/core/spark-warehouse/t
132133
Storage Properties [a=1, b=2]
@@ -157,6 +158,7 @@ Provider parquet
157158
Num Buckets 2
158159
Bucket Columns [`a`]
159160
Sort Columns [`b`]
161+
Comment table_comment
160162
Table Properties [e=3]
161163
Location [not included in comparison]sql/core/spark-warehouse/t
162164
Storage Properties [a=1, b=2]

0 commit comments

Comments
 (0)