[KYUUBI #4917][Bug][AUTHZ] Table owner undefied in Iceberg 1.3.0 on Spark 3.4
### _Why are the changes needed?_ Fix #4917 - support extracting table owner from `ResolvedIdentifier` ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [x] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request <img width="1266" alt="image" src="https://github.com/apache/kyuubi/assets/88070094/e3066d0e-7a14-41da-96f6-032a5c53780f"> Closes #4941 from zhouyifan279/drop-table. Closes #4917 b2207ed17 [zhouyifan279] [KYUUBI #4917][Bug][AUTHZ] Table owner undefied in Iceberg 1.3.0 on Spark 3.4 bc4661a13 [zhouyifan279] [KYUUBI #4917][Bug][AUTHZ] Table owner undefied in Iceberg 1.3.0 on Spark 3.4 Authored-by: zhouyifan279 <zhouyifan279@gmail.com> Signed-off-by: liangbowen <liangbowen@gf.com.cn>
This commit is contained in:
parent
a9fcf3f280
commit
34e79b4195
@ -51,6 +51,21 @@ object TableExtractor {
|
||||
val properties = invokeAs[JMap[String, String]](table, "properties").asScala
|
||||
properties.get("owner")
|
||||
}
|
||||
|
||||
def getOwner(spark: SparkSession, catalogName: String, tableIdent: AnyRef): Option[String] = {
|
||||
try {
|
||||
val catalogManager = invokeAs[AnyRef](spark.sessionState, "catalogManager")
|
||||
val catalog = invokeAs[AnyRef](catalogManager, "catalog", (classOf[String], catalogName))
|
||||
val table = invokeAs[AnyRef](
|
||||
catalog,
|
||||
"loadTable",
|
||||
(Class.forName("org.apache.spark.sql.connector.catalog.Identifier"), tableIdent))
|
||||
getOwner(table)
|
||||
} catch {
|
||||
// Exception may occur due to invalid reflection or table not found
|
||||
case _: Exception => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -177,7 +192,8 @@ class ResolvedIdentifierTableExtractor extends TableExtractor {
|
||||
val catalog = lookupExtractor[CatalogPluginCatalogExtractor].apply(catalogVal)
|
||||
val identifier = invokeAs[AnyRef](v1, "identifier")
|
||||
val maybeTable = lookupExtractor[IdentifierTableExtractor].apply(spark, identifier)
|
||||
maybeTable.map(_.copy(catalog = catalog))
|
||||
val owner = catalog.flatMap(name => TableExtractor.getOwner(spark, name, identifier))
|
||||
maybeTable.map(_.copy(catalog = catalog, owner = owner))
|
||||
case _ => None
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user