attilapiros opened a new pull request, #7775:
URL: https://github.com/apache/kyuubi/pull/7775

   ### Why are the changes needed?
   
   Granting ownership privileges needs the table owner on the privilege object, 
but it came back empty for Hive tables.
   
   `TableExtractor.getOwner` assumed its argument wraps a connector `Table` in 
a `table` member. `V1Table`, which `V2SessionCatalog.loadTable` returns for a 
session-catalog (Hive) table, carries the properties itself and has no `table` 
accessor, so the lookup threw, was swallowed by the surrounding `catch`, and 
the owner was lost.
   
   `DROP TABLE` on a Hive table reaches exactly this path. With 
`spark.sql.legacy.useV1Command` at its default of `false` the plan is not 
downgraded to `DropTableCommand`; it stays as the v2 
`DropTable(ResolvedIdentifier(...))`, whose first table descriptor resolves the 
owner through `loadTable`.
   
   - `getOwner` picks the properties holder -- `V1Table` itself, or the wrapped 
table otherwise -- and then reads the owner once, instead of duplicating the 
lookup.
   - Empty owners are filtered out. `V1Table.addV2TableProperties` sets 
`PROP_OWNER` unconditionally, so a table with no owner yielded `Some("")`. The 
other owner lookups in this file already filter on `nonEmpty`.
   - A debug line when the catalog lookup fails, so a genuinely absent owner 
can be told apart from a failed load.
   
   `V1Table` is `private[sql]`, so it is matched by class name; it cannot be 
referenced as a type from this package.
   
   ### How was this patch tested?
   
   A new test in `HiveCatalogRangerSparkExtensionSuite` asserts the owner on 
the privilege object built for `DROP TABLE`. It fails without this change: the 
owner is `None`, because `getOwner` throws on a `V1Table`. The test asserts the 
owner value rather than `isDefined` -- since `PROP_OWNER` is always set, 
`isDefined` would also hold for an empty owner.
   
   ### Was this patch assisted by generative AI tooling?
   
   Assisted-by: Claude Opus 5


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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to