Skip to content

Commit

Permalink
[KYUUBI apache#5457] [AUTHZ] Support RepairTable Commands for Hudi
Browse files Browse the repository at this point in the history
  • Loading branch information
AngersZhuuuu committed Oct 18, 2023
1 parent c5854f7 commit 4319763
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,20 @@
} ],
"opType" : "DROPTABLE",
"queryDescs" : [ ]
}, {
"classname" : "org.apache.spark.sql.hudi.command.RepairHoodieTableCommand",
"tableDescs" : [ {
"fieldName" : "tableName",
"fieldExtractor" : "TableIdentifierTableExtractor",
"columnDesc" : null,
"actionTypeDesc" : null,
"tableTypeDesc" : null,
"catalogDesc" : null,
"isInput" : false,
"setCurrentDatabaseIfMissing" : false
} ],
"opType" : "MSCK",
"queryDescs" : [ ]
}, {
"classname" : "org.apache.spark.sql.hudi.command.Spark31AlterTableCommand",
"tableDescs" : [ {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ object HudiCommands {
DROPTABLE)
}

val RepairHoodieTableCommand = {
val cmd = "org.apache.spark.sql.hudi.command.RepairHoodieTableCommand"
TableCommandSpec(cmd, Seq(TableDesc("tableName", classOf[TableIdentifierTableExtractor])), MSCK)
}

val TruncateHoodieTableCommand = {
val cmd = "org.apache.spark.sql.hudi.command.TruncateHoodieTableCommand"
val columnDesc = ColumnDesc("partitionSpec", classOf[PartitionOptionColumnExtractor])
Expand All @@ -138,5 +143,6 @@ object HudiCommands {
CreateHoodieTableAsSelectCommand,
CreateHoodieTableLikeCommand,
DropHoodieTableCommand,
RepairHoodieTableCommand,
TruncateHoodieTableCommand)
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class HudiCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {
interceptContains[AccessControlException](
doAs(someone, sql(s"ALTER TABLE $namespace1.$table1 ADD COLUMNS(age int)")))(
s"does not have [alter] privilege on [$namespace1/$table1]")
sql("set hoodie.schema.on.read.enable=false")
}
}

Expand Down Expand Up @@ -240,6 +241,31 @@ class HudiCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {
}
}

test("RepairHoodieTableCommand") {
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 = 'cow',
| primaryKey = 'id',
| 'hoodie.datasource.hive_sync.enable' = 'false'
|)
|PARTITIONED BY(city)
|""".stripMargin))

val repairTableSql = s"MSCK REPAIR TABLE $namespace1.$table1"
interceptContains[AccessControlException] {
doAs(someone, sql(repairTableSql))
}(s"does not have [alter] privilege on [$namespace1/$table1]")
doAs(admin, sql(repairTableSql))
}
}

test("TruncateHoodieTableCommand") {
withCleanTmpResources(Seq((s"$namespace1.$table1", "table"), (namespace1, "database"))) {
doAs(admin, sql(s"CREATE DATABASE IF NOT EXISTS $namespace1"))
Expand Down

0 comments on commit 4319763

Please sign in to comment.