LuciferYang opened a new pull request, #14294:
URL: https://github.com/apache/gravitino/pull/14294

   ### What changes were proposed in this pull request?
   
   - `AuthorizationTable` now carries the table identifier, the required 
privileges and the original error. `RequiredPrivilegesCheck` collects these 
placeholders from the analyzed plan (`DataSourceV2Relation`, `ResolvedTable`, 
`StreamingRelationV2` and the target of a `V2WriteCommand`) and reports them in 
one error, as before.
   - The thread-local list, `AuthorizationTable.drainFailure()` and `clear()`, 
and the parser wrappers in the Spark 3.5 and 4.0 
`GravitinoAuthorizationSparkSessionExtensions` are removed. Nothing else in the 
repository calls them.
   - A denied write still fails when the table is loaded, with the same 
aggregated message, now built without the thread-local.
   
   ### Why are the changes needed?
   
   A recorded denial stayed on the thread until the next SQL parse. When the 
post-hoc rule did not run, for example after `spark.catalog.getTable` on Spark 
3.5 or after an analysis that failed on another table, the next DataFrame query 
on that thread failed with a `ForbiddenException` for a table it never used. 
The denials now live only in the plan that contains them.
   
   Fix: #14290
   
   ### Does this PR introduce _any_ user-facing change?
   
   A denied table no longer fails later queries. Two error messages list fewer 
tables than before: when denied tables appear both in a subquery and in the 
outer query, the error lists the subquery's tables, because Spark analyzes the 
subquery separately; and when both `w` and `r` are denied, `INSERT INTO w 
SELECT ... FROM r` lists only `w`.
   
   ### How was this patch tested?
   
   - `TestRequiredPrivilegesSparkResolution` runs a real analyzer. 
`testDeniedGetTableDoesNotFailLaterQueries` and 
`testAbortedAnalysisDoesNotFailLaterQueries` run `spark.range(1).count()` after 
`getTable` on a denied table and after an analysis that fails on a second 
catalog. `testDescribeDeniedTableReportsForbidden` and 
`testSubqueryOnDeniedTableReportsForbidden` cover tables resolved to 
`ResolvedTable` and tables inside a subquery.
   - `TestRequiredPrivilegesCheck.testDeniedTableFailsClosedWhenAccessed` 
checks that the placeholder still rejects reads and writes.
   - `TestBaseCatalogAuthorization.testDeniedWriteReportsTheWriteTarget` checks 
the write-path message and cause.
   


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

Reply via email to