Skip to content

Commit

Permalink
[KYUUBI apache#5735][AUTHZ] Support vacuum path-based table for Delta…
Browse files Browse the repository at this point in the history
… Lake

# 🔍 Description
## Issue References 🔗

This pull request fixes apache#5735.

## Describe Your Solution 🔧
VacuumTableCommand add uriDescs.

## Types of changes 🔖

- [ ] Bugfix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Test Plan 🧪

#### Behavior Without This Pull Request ⚰️

#### Behavior With This Pull Request 🎉

#### Related Unit Tests
org.apache.kyuubi.plugin.spark.authz.ranger.DeltaCatalogRangerSparkExtensionSuite.test("vacuum path-based table")

---

# Checklists
## 📝 Author Self Checklist

- [x] My code follows the [style guidelines](https://kyuubi.readthedocs.io/en/master/contributing/code/style.html) of this project
- [x] I have performed a self-review
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)

## 📝 Committer Pre-Merge Checklist

- [ ] Pull request title is okay.
- [ ] No license issues.
- [ ] Milestone correctly set?
- [ ] Test coverage is ok
- [ ] Assignees are selected.
- [ ] Minimum number of approvals
- [ ] No changes are requested

**Be nice. Be informative.**

Closes apache#5751 from zml1206/KYUUBI-5735.

Closes apache#5735

463c01b [zml1206] Support vacuum path-based table for Delta Lake in Authz

Authored-by: zml1206 <zhuml1206@gmail.com>
Signed-off-by: Kent Yao <yao@apache.org>
  • Loading branch information
zml1206 authored and yaooqinn committed Nov 23, 2023
1 parent 84a9686 commit fdcb456
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2153,7 +2153,19 @@
} ],
"opType" : "MSCK",
"queryDescs" : [ ],
"uriDescs" : [ ]
"uriDescs" : [ {
"fieldName" : "child",
"fieldExtractor" : "ResolvedTableURIExtractor",
"isInput" : false
}, {
"fieldName" : "table",
"fieldExtractor" : "TableIdentifierOptionURIExtractor",
"isInput" : false
}, {
"fieldName" : "path",
"fieldExtractor" : "StringURIExtractor",
"isInput" : false
} ]
}, {
"classname" : "org.apache.spark.sql.delta.commands.DeleteCommand",
"tableDescs" : [ {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ object DeltaCommands extends CommandSpecs[TableCommandSpec] {
val cmd = "io.delta.tables.execution.VacuumTableCommand"
val childDesc = TableDesc("child", classOf[ResolvedTableTableExtractor])
val tableDesc = TableDesc("table", classOf[TableIdentifierOptionTableExtractor])
TableCommandSpec(cmd, Seq(childDesc, tableDesc), MSCK)
val uriDescs = Seq(
UriDesc("child", classOf[ResolvedTableURIExtractor]),
UriDesc("table", classOf[TableIdentifierOptionURIExtractor]),
UriDesc("path", classOf[StringURIExtractor]))
TableCommandSpec(cmd, Seq(childDesc, tableDesc), MSCK, uriDescs = uriDescs)
}

override def specs: Seq[TableCommandSpec] = Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,23 @@ class DeltaCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {
doAs(admin, sql(optimizeTableSql2))
})
}

test("vacuum path-based table") {
withTempDir(path => {
doAs(admin, sql(createPathBasedTableSql(path)))
val vacuumTableSql1 = s"VACUUM delta.`$path`"
interceptEndsWith[AccessControlException](
doAs(someone, sql(vacuumTableSql1)))(
s"does not have [write] privilege on [[$path, $path/]]")
doAs(admin, sql(vacuumTableSql1))

val vacuumTableSql2 = s"VACUUM '$path'"
interceptEndsWith[AccessControlException](
doAs(someone, sql(vacuumTableSql2)))(
s"does not have [write] privilege on [[$path, $path/]]")
doAs(admin, sql(vacuumTableSql2))
})
}
}

object DeltaCatalogRangerSparkExtensionSuite {
Expand Down

0 comments on commit fdcb456

Please sign in to comment.