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_r353752835
########## File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala ########## @@ -379,22 +374,35 @@ private[hive] class HiveClientImpl( s"Hive ${version.fullVersion} does not support altering database location") } } - client.alterDatabase( + val hiveDb = toHiveDatabase(database, false) + client.alterDatabase(database.name, hiveDb) + } + + private def toHiveDatabase(database: CatalogDatabase, isCreate: Boolean): HiveDatabase = { + val props = database.properties + val hiveDb = new HiveDatabase( database.name, - new HiveDatabase( - database.name, - database.description, - CatalogUtils.URIToString(database.locationUri), - Option(database.properties).map(_.asJava).orNull)) + database.description, + CatalogUtils.URIToString(database.locationUri), + (props -- Seq(PROP_OWNER_NAME, PROP_OWNER_TYPE)).asJava) + props.get(PROP_OWNER_NAME).orElse(if (isCreate) Some(userName) else None).foreach { ownerName => + shim.setDatabaseOwnerName(hiveDb, ownerName) + } + props.get(PROP_OWNER_TYPE).foreach(ownerType => shim.setDatabaseOwnerType(hiveDb, ownerType)) Review comment: if `isCreate = true`, we will owner name to `userName`. We should set owner type to `PrincipalType.USER` as well. ---------------------------------------------------------------- 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