yaooqinn commented on a change in pull request #26080: [SPARK-29425][SQL] The 
ownership of a database should be respected
URL: https://github.com/apache/spark/pull/26080#discussion_r348325143
 
 

 ##########
 File path: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
 ##########
 @@ -372,12 +372,44 @@ class HiveCatalogedDDLSuite extends DDLSuite with 
TestHiveSingleton with BeforeA
       assert(table.provider == Some("org.apache.spark.sql.hive.orc"))
     }
   }
+
+  test("Database Ownership") {
+    val catalog = spark.sessionState.catalog
+    try {
+      val dbName = "spark_29425"
+      val location = getDBPath(dbName)
+
+      sql(s"CREATE DATABASE $dbName")
+
+      checkAnswer(
+        sql(s"DESCRIBE DATABASE $dbName"),
+        Row("Database Name", dbName) ::
+          Row("Description", "") ::
+          Row("Location", CatalogUtils.URIToString(location)) ::
+          Row("Owner Name", Utils.getCurrentUserName()) ::
+          Row("Owner Type", "USER") :: Nil)
+
+      sql(s"ALTER DATABASE $dbName SET DBPROPERTIES ('a'='a', 'b'='b', 
'c'='c')")
 
 Review comment:
   Behavior Before: we `create db` with no owner, `alter db` erase the owner if 
exists not with our default spark user.
   Behavior After: we `create db` with the spark user as default, or with 
dbProps if ownerName exists; we `alter db` will prefer the owner in order of  
`specified ownerName` -> `original db's ownerName` -> `spark's default if the 
foregoing ones are null or empty`.
   
   `ALTER DATABASE dbname SET DBPROPERTIES('ownerName'='userName')` equals 
Hive's `ALTER DATABASE dbname SET OWNER USER userName`.
   
   I suggest we make the ownerName and its type become members of 
`CatalogDabase` in followup, and the `CatalogTable` too.
   Then support,
   ```sql
   ALTER [DATABASE|SCHEMA] dbname SET OWNER [USER|ROLE] userName
   ALTER TABLE tblname SET OWNER [USER|ROLE] userName
   ```
   
   

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to