cloud-fan 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_r352477417
 
 

 ##########
 File path: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
 ##########
 @@ -372,12 +372,58 @@ class HiveCatalogedDDLSuite extends DDLSuite with 
TestHiveSingleton with BeforeA
       assert(table.provider == Some("org.apache.spark.sql.hive.orc"))
     }
   }
+
+  private def checkOwner(db: String, owner: String,
+      location: URI, hasProps: Boolean = false): Unit = {
+    val answer = Seq(Row("Database Name", db),
+      Row("Description", ""),
+      Row("Location", CatalogUtils.URIToString(location)),
+      Row("Owner Name", owner),
+      Row("Owner Type", "USER"))
+    val props = if (hasProps) {
+      Seq(Row("Properties", "((a,a))"))
+    } else {
+      Seq(Row("Properties", ""))
+    }
+    checkAnswer(sql(s"DESCRIBE DATABASE EXTENDED $db"), answer ++ props)
+  }
+
+  test("Database Ownership") {
+    val catalog = spark.sessionState.catalog
+    try {
+      val db1 = "spark_29425_1"
+      val db2 = "spark_29425_2"
+      val owner = "spark_29425"
+      val location1 = getDBPath(db1)
+      val location2 = getDBPath(db2)
+
+      sql(s"CREATE DATABASE $db1")
+      checkOwner(db1, Utils.getCurrentUserName(), location1)
+
+      // TODO: Specify ownership should be forbidden after we implement `SET 
OWNER` syntax
+      sql(s"CREATE DATABASE $db2 WITH DBPROPERTIES('ownerName'='$owner')")
+      checkOwner(db2, owner, location2)
+
+      sql(s"ALTER DATABASE $db1 SET DBPROPERTIES ('a'='a')")
 
 Review comment:
   nit: can we put the tests of `db1` together? It's a little hard to follow 
the test flow here.

----------------------------------------------------------------
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