Skip to content

Commit

Permalink
Supports check hoodie procedures show_commits resource privileges
Browse files Browse the repository at this point in the history
  • Loading branch information
yikf committed Jan 13, 2024
1 parent b9ce95b commit 4e609b0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,9 @@ abstract class HudiCallProcedureTableExtractor extends TableExtractor {
(
s"$PROCEDURE_CLASS_PATH.ShowClusteringProcedure",
ProcedureArgsInputOutputPair(input = Some("table"))),
(
s"$PROCEDURE_CLASS_PATH.ShowCommitsProcedure",
ProcedureArgsInputOutputPair(input = Some("table"))),
(
s"$PROCEDURE_CLASS_PATH.ShowCommitExtraMetadataProcedure",
ProcedureArgsInputOutputPair(input = Some("table"))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,4 +618,30 @@ class HudiCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {
doAs(admin, sql(dropIndex))
}
}

test("ShowCommitsProcedure") {
withCleanTmpResources(Seq((s"$namespace1.$table1", "table"), (namespace1, "database"))) {
doAs(admin, sql(s"CREATE DATABASE IF NOT EXISTS $namespace1"))
doAs(
admin,
sql(
s"""
|CREATE TABLE IF NOT EXISTS $namespace1.$table1(id int, name string, city string)
|USING HUDI
|OPTIONS (
| type = 'mor',
| primaryKey = 'id',
| 'hoodie.datasource.hive_sync.enable' = 'false'
|)
|PARTITIONED BY(city)
|TBLPROPERTIES ('hoodie.datasource.write.precombine.field' = 'id')
|""".stripMargin))

val showCommitsSql = s"CALL SHOW_COMMITS(table => '$namespace1.$table1', limit => 10)"
interceptEndsWith[AccessControlException] {
doAs(someone, sql(showCommitsSql))
}(s"does not have [select] privilege on [$namespace1/$table1]")
doAs(admin, sql(showCommitsSql))
}
}
}

0 comments on commit 4e609b0

Please sign in to comment.