yaooqinn commented on a change in pull request #26775: [SPARK-30018][SQL]
Support ALTER DATABASE SET OWNER syntax
URL: https://github.com/apache/spark/pull/26775#discussion_r364631966
##########
File path:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
##########
@@ -388,20 +391,29 @@ class HiveCatalogedDDLSuite extends DDLSuite with
TestHiveSingleton with BeforeA
val db1 = "spark_29425_1"
val db2 = "spark_29425_2"
val owner = "spark_29425"
+ val currentUser = Utils.getCurrentUserName()
sql(s"CREATE DATABASE $db1")
- checkOwner(db1, Utils.getCurrentUserName())
+ checkOwner(db1, currentUser, "USER")
sql(s"ALTER DATABASE $db1 SET DBPROPERTIES ('a'='a')")
- checkOwner(db1, Utils.getCurrentUserName())
-
- // TODO: Specify ownership should be forbidden after we implement `SET
OWNER` syntax
- sql(s"CREATE DATABASE $db2 WITH DBPROPERTIES('ownerName'='$owner')")
- checkOwner(db2, owner)
- sql(s"ALTER DATABASE $db2 SET DBPROPERTIES ('a'='a')")
- checkOwner(db2, owner)
- // TODO: Changing ownership should be forbidden after we implement `SET
OWNER` syntax
- sql(s"ALTER DATABASE $db2 SET DBPROPERTIES ('ownerName'='a')")
- checkOwner(db2, "a")
+ checkOwner(db1, currentUser, "USER")
+ val e = intercept[AnalysisException](sql(s"ALTER DATABASE $db1 SET
DBPROPERTIES ('a'='a',"
+ + s"'ownerName'='$owner','ownerType'='XXX')"))
Review comment:
It does not matter but I guess we should mention this
```
spark-sql> create namespace abcde with properties('LOCATION'= 'b');
20/01/09 17:21:54 INFO HiveMetaStore: 0: get_database: global_temp
20/01/09 17:21:54 INFO audit: ugi=kentyao ip=unknown-ip-addr
cmd=get_database: global_temp
20/01/09 17:21:54 WARN ObjectStore: Failed to get database global_temp,
returning NoSuchObjectException
20/01/09 17:21:54 INFO HiveMetaStore: 0: create_database:
Database(name:abcde, description:,
locationUri:file:/Users/kentyao/Downloads/spark/spark-3.0.0-SNAPSHOT-bin-20200103/spark-warehouse/abcde.db,
parameters:{LOCATION=b}, ownerName:kentyao, ownerType:USER)
20/01/09 17:21:54 INFO audit: ugi=kentyao ip=unknown-ip-addr
cmd=create_database: Database(name:abcde, description:,
locationUri:file:/Users/kentyao/Downloads/spark/spark-3.0.0-SNAPSHOT-bin-20200103/spark-warehouse/abcde.db,
parameters:{LOCATION=b}, ownerName:kentyao, ownerType:USER)
20/01/09 17:21:54 WARN ObjectStore: Failed to get database abcde, returning
NoSuchObjectException
20/01/09 17:21:54 INFO FileUtils: Creating directory if it doesn't exist:
file:/Users/kentyao/Downloads/spark/spark-3.0.0-SNAPSHOT-bin-20200103/spark-warehouse/abcde.db
Time taken: 1.891 seconds
```
```
spark-sql> create namespace abcdef with properties('location'= 'b');
20/01/09 17:22:52 INFO HiveMetaStore: 0: create_database:
Database(name:abcdef, description:,
locationUri:file:/Users/kentyao/Downloads/spark/spark-3.0.0-SNAPSHOT-bin-20200103/b,
parameters:{}, ownerName:kentyao, ownerType:USER)
20/01/09 17:22:52 INFO audit: ugi=kentyao ip=unknown-ip-addr
cmd=create_database: Database(name:abcdef, description:,
locationUri:file:/Users/kentyao/Downloads/spark/spark-3.0.0-SNAPSHOT-bin-20200103/b,
parameters:{}, ownerName:kentyao, ownerType:USER)
20/01/09 17:22:52 WARN ObjectStore: Failed to get database abcdef, returning
NoSuchObjectException
20/01/09 17:22:52 INFO FileUtils: Creating directory if it doesn't exist:
file:/Users/kentyao/Downloads/spark/spark-3.0.0-SNAPSHOT-bin-20200103/b
```
----------------------------------------------------------------
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]