Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KYUUBI #5457] [AUTHZ] Support RepairTable Commands for Hudi #5458

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1622,6 +1622,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 Down Expand Up @@ -151,6 +156,7 @@ object HudiCommands {
CompactionHoodieTableCommand,
CompactionShowHoodieTableCommand,
DropHoodieTableCommand,
RepairHoodieTableCommand,
TruncateHoodieTableCommand,
Spark31AlterTableCommand)
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,14 @@ class HudiCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {
s" on [$namespace1/$table1]")

// AlterTableCommand && Spark31AlterTableCommand
sql("set hoodie.schema.on.read.enable=true")
interceptContains[AccessControlException](
doAs(someone, sql(s"ALTER TABLE $namespace1.$table1 ADD COLUMNS(age int)")))(
s"does not have [alter] privilege on [$namespace1/$table1]")
try {
sql("set hoodie.schema.on.read.enable=true")
interceptContains[AccessControlException](
doAs(someone, sql(s"ALTER TABLE $namespace1.$table1 ADD COLUMNS(age int)")))(
s"does not have [alter] privilege on [$namespace1/$table1]")
} finally {
sql("set hoodie.schema.on.read.enable=false")
}
}
}

Expand Down Expand Up @@ -240,6 +244,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
Loading