moelhoussein opened a new issue, #7852:
URL: https://github.com/apache/kyuubi/issues/7852
### Code of Conduct
- [x] I agree to follow the project's Code of Conduct.
### Search before asking
- [x] I searched existing issues and PRs. The related items below do not
cover this procedure-argument path.
### Describe the bug
Kyuubi AuthZ parses table identifiers in procedure arguments with
`Expression.toString()` followed by `String.split("\\.")`. Spark procedure
implementations parse the same value with the quote-aware
`parseMultipartIdentifier`. Equivalent quoted and unquoted arguments therefore
produce different Ranger resources.
With Ranger `ALTER` permission on `db/tbl`:
```sql
CALL local.system.rewrite_data_files(
table => '`local`.`db`.`tbl`'
)
```
Kyuubi checks `` `db`/`tbl` `` and denies the request. The equivalent `table
=> 'local.db.tbl'` checks `db/tbl` and works.
Both forms should authorize the same table. Quoting is required when an
identifier part contains a dot or another special character. Raw splitting can
then produce more than three parts and throw `MatchError`; the extraction
exception is caught and can leave the `CALL` plan without its intended
privilege object.
This is shared AuthZ parsing, not a format-specific resource model.
`ExpressionSeqTableExtractor` is currently used by Spark `Call` and Paimon
`PaimonCallCommand` plans.
Current implementation:
https://github.com/apache/kyuubi/blob/f3125812e364ad1ad687d2e57b693de114a4991d/extensions/spark/kyuubi-spark-authz/src/main/scala/org/apache/kyuubi/plugin/spark/authz/serde/tableExtractors.scala#L181-L205
Upstream procedure test using a quoted multipart identifier:
https://github.com/apache/iceberg/blob/apache-iceberg-1.6.1/spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestRollbackToSnapshotProcedure.java#L155-L198
Suggested fix: parse procedure table strings with the active Spark SQL
parser before constructing the privilege object. Keep this scoped to values
known to be multipart identifiers rather than parsing opaque connector-defined
`Table.name()` values.
Tests should verify that quoted and unquoted forms produce the same
privilege object, quoted dots and escaped backticks remain in their identifier
part, and parse failures do not silently remove authorization.
Related but distinct: #5248, #5406, #7593, #7740, and #7741. The #7741 patch
handles Iceberg metadata wrappers and does not change this path.
### Affects Version(s)
1.9.0 through master. Observed on Kyuubi 1.11.1 with Spark 3.5.9.
### Kyuubi Server Log Output
N/A
### Kyuubi Engine Log Output
```text
org.apache.kyuubi.plugin.spark.authz.AccessControlException:
Permission denied: user [...] does not have [alter] privilege on [`db`/`tbl`]
```
### Kyuubi Server Configurations
N/A
### Kyuubi Engine Configurations
```yaml
spark.sql.extensions:
org.apache.kyuubi.plugin.spark.authz.ranger.RangerSparkExtension
```
### Additional context
This is parser parity with the execution layer, not a claim about ANSI SQL
syntax.
### Are you willing to submit PR?
- [x] Yes. I would be willing to submit a PR with guidance from the Kyuubi
community to fix.
--
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]