yaooqinn commented on a change in pull request #26847: [SPARK-30214][SQL] 
Support COMMENT ON syntax
URL: https://github.com/apache/spark/pull/26847#discussion_r360413341
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala
 ##########
 @@ -210,6 +212,16 @@ object DataSourceV2Strategy extends Strategy with 
PredicateHelper {
     case AlterNamespaceSetProperties(catalog, namespace, properties) =>
       AlterNamespaceSetPropertiesExec(catalog, namespace, properties) :: Nil
 
+    case CommentOnNamespace(ResolvedNamespace(catalog, namespace), comment) =>
+      AlterNamespaceSetPropertiesExec(
+        catalog,
+        namespace,
+        Map(SupportsNamespaces.PROP_COMMENT -> comment)) :: Nil
 
 Review comment:
   Ok, let’s get this straight.
   Postgres treats `null`/`empty string` the same as `null` to delete the 
comment key-value, but when we run `\d+ xxx`, the Comment(Description) is a 
must-show field whether is null or not, see as below,
   ```sql
   postgres=# \d+
                            List of relations
    Schema |    Name     | Type  |  Owner   |    Size    | Description
   --------+-------------+-------+----------+------------+-------------
    public | b           | table | postgres | 8192 bytes | abc
    public | bo          | table | postgres | 8192 bytes |
    public | i           | table | postgres | 0 bytes    |
   ```
   In Spark, w/ or w/o this PR, the Comment(Description) of a database is a 
must-show field for `describe namespace` as Postgres. When it's null(as if we 
delete it as Postgres), we have to fill it with an empty string.
   In Spark w/o this PR, the Comment(Description) of a table is an optional 
field for `describe table`, it is not shown if it is null. when it an empty 
string, the field exists.
   In Spark w/ this PR, the Comment(Description) of a table is a must-show 
field for `describe table` as Postgres.
   
   Additionally, if we delete comment here when it is empty string, then we 
have to do the same in create-table-comment-clause.`CREATE TABLE(v int) COMMENT 
''` should not leave a comment with empty string as it does now. 
   
   All in all, let's say the same result in different processes between spark 
and Postgres after 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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to