Repository: spark
Updated Branches:
  refs/heads/master a18d63711 -> 5d35d5c15


[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 <gatorsm...@gmail.com>

Closes #18318 from gatorsmile/fixTableComment.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/5d35d5c1
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/5d35d5c1
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/5d35d5c1

Branch: refs/heads/master
Commit: 5d35d5c15c63debaa79202708c6e6481980a6a7f
Parents: a18d637
Author: Xiao Li <gatorsm...@gmail.com>
Authored: Fri Jun 16 10:11:23 2017 +0800
Committer: Wenchen Fan <wenc...@databricks.com>
Committed: Fri Jun 16 10:11:23 2017 +0800

----------------------------------------------------------------------
 .../main/scala/org/apache/spark/sql/execution/command/ddl.scala    | 2 +-
 sql/core/src/test/resources/sql-tests/results/describe.sql.out     | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/5d35d5c1/sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala
----------------------------------------------------------------------
diff --git 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala
index 5a7f8cf..f924b3d 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala
@@ -235,7 +235,7 @@ case class AlterTableSetPropertiesCommand(
     // direct property.
     val newTable = table.copy(
       properties = table.properties ++ properties,
-      comment = properties.get("comment"))
+      comment = properties.get("comment").orElse(table.comment))
     catalog.alterTable(newTable)
     Seq.empty[Row]
   }

http://git-wip-us.apache.org/repos/asf/spark/blob/5d35d5c1/sql/core/src/test/resources/sql-tests/results/describe.sql.out
----------------------------------------------------------------------
diff --git a/sql/core/src/test/resources/sql-tests/results/describe.sql.out 
b/sql/core/src/test/resources/sql-tests/results/describe.sql.out
index 329532c..ab9f278 100644
--- a/sql/core/src/test/resources/sql-tests/results/describe.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/describe.sql.out
@@ -127,6 +127,7 @@ Provider                    parquet
 Num Buckets            2                                           
 Bucket Columns         [`a`]                                       
 Sort Columns           [`b`]                                       
+Comment                table_comment                               
 Table Properties       [e=3]                                       
 Location [not included in comparison]sql/core/spark-warehouse/t                
            
 Storage Properties     [a=1, b=2]                                  
@@ -157,6 +158,7 @@ Provider                    parquet
 Num Buckets            2                                           
 Bucket Columns         [`a`]                                       
 Sort Columns           [`b`]                                       
+Comment                table_comment                               
 Table Properties       [e=3]                                       
 Location [not included in comparison]sql/core/spark-warehouse/t                
            
 Storage Properties     [a=1, b=2]                                  


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to