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 #5446][AUTHZ] Support Create/Drop/Show/Reresh index command for Hudi #5448

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0222e02
[KYUUBI-5446][AUTHZ] Support Create/Drop/Show/Reresh index command
AngersZhuuuu Oct 17, 2023
b1657d9
follow comment
AngersZhuuuu Oct 18, 2023
fcb3d45
Update HudiCatalogRangerSparkExtensionSuite.scala
AngersZhuuuu Oct 18, 2023
ab8b96d
Merge branch 'master' into KYUUBI-5446
AngersZhuuuu Oct 18, 2023
fefb021
Update table_command_spec.json
AngersZhuuuu Oct 18, 2023
e70c8f1
Update HudiCatalogRangerSparkExtensionSuite.scala
AngersZhuuuu Oct 18, 2023
c404fd7
Update HudiCatalogRangerSparkExtensionSuite.scala
AngersZhuuuu Oct 18, 2023
9632886
Update HudiCatalogRangerSparkExtensionSuite.scala
AngersZhuuuu Oct 18, 2023
aed91cd
Merge branch 'master' into KYUUBI-5446
AngersZhuuuu Oct 18, 2023
544a443
Update HudiCommands.scala
AngersZhuuuu Oct 18, 2023
81881db
Update HudiCommands.scala
AngersZhuuuu Oct 18, 2023
a78425b
Update HudiCommands.scala
AngersZhuuuu Oct 18, 2023
4764531
Merge branch 'master' into KYUUBI-5446
AngersZhuuuu Oct 18, 2023
f174ef2
Update table_command_spec.json
AngersZhuuuu Oct 18, 2023
bed945e
Merge branch 'master' into KYUUBI-5446
AngersZhuuuu Oct 19, 2023
52f67e9
update
AngersZhuuuu Oct 19, 2023
f9a398c
Merge branch 'master' into KYUUBI-5446
AngersZhuuuu Oct 24, 2023
dc9188d
update
AngersZhuuuu Oct 24, 2023
4019f45
update
AngersZhuuuu Oct 24, 2023
0e6f6df
Update
AngersZhuuuu Oct 24, 2023
bc65abd
update
AngersZhuuuu Oct 24, 2023
97cb0f8
Update PrivilegeObject.scala
AngersZhuuuu Oct 24, 2023
214bb86
Update OperationType.scala
AngersZhuuuu Oct 24, 2023
ed1544e
Update
AngersZhuuuu Oct 25, 2023
c4ae073
follow comment
AngersZhuuuu Oct 25, 2023
1be0561
Update ObjectType.scala
AngersZhuuuu Oct 25, 2023
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 @@ -1636,6 +1636,20 @@
} ],
"opType" : "DROPTABLE",
"queryDescs" : [ ]
}, {
"classname" : "org.apache.spark.sql.hudi.command.DropIndexCommand",
"tableDescs" : [ {
"fieldName" : "table",
"fieldExtractor" : "CatalogTableTableExtractor",
"columnDesc" : null,
"actionTypeDesc" : null,
"tableTypeDesc" : null,
"catalogDesc" : null,
"isInput" : false,
"setCurrentDatabaseIfMissing" : false
} ],
"opType" : "ALTERTABLE_PROPERTIES",
"queryDescs" : [ ]
}, {
"classname" : "org.apache.spark.sql.hudi.command.InsertIntoHoodieTableCommand",
"tableDescs" : [ {
Expand All @@ -1657,6 +1671,20 @@
"fieldName" : "query",
"fieldExtractor" : "LogicalPlanQueryExtractor"
} ]
}, {
"classname" : "org.apache.spark.sql.hudi.command.RefreshIndexCommand",
"tableDescs" : [ {
"fieldName" : "table",
"fieldExtractor" : "CatalogTableTableExtractor",
"columnDesc" : null,
"actionTypeDesc" : null,
"tableTypeDesc" : null,
"catalogDesc" : null,
"isInput" : true,
AngersZhuuuu marked this conversation as resolved.
Show resolved Hide resolved
"setCurrentDatabaseIfMissing" : false
} ],
"opType" : "QUERY",
"queryDescs" : [ ]
}, {
"classname" : "org.apache.spark.sql.hudi.command.RepairHoodieTableCommand",
"tableDescs" : [ {
Expand All @@ -1671,6 +1699,20 @@
} ],
"opType" : "MSCK",
"queryDescs" : [ ]
}, {
"classname" : "org.apache.spark.sql.hudi.command.ShowIndexesCommand",
"tableDescs" : [ {
"fieldName" : "table",
"fieldExtractor" : "CatalogTableTableExtractor",
"columnDesc" : null,
"actionTypeDesc" : null,
"tableTypeDesc" : null,
"catalogDesc" : null,
"isInput" : true,
"setCurrentDatabaseIfMissing" : false
} ],
"opType" : "QUERY",
"queryDescs" : [ ]
}, {
"classname" : "org.apache.spark.sql.hudi.command.Spark31AlterTableCommand",
"tableDescs" : [ {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ object HudiCommands {
val tableDesc = TableDesc("table", classOf[CatalogTableTableExtractor], isInput = true)
TableCommandSpec(cmd, Seq(tableDesc))
}

val InsertIntoHoodieTableCommand = {
val cmd = "org.apache.spark.sql.hudi.command.InsertIntoHoodieTableCommand"
val tableDesc = TableDesc(
Expand Down Expand Up @@ -195,6 +195,7 @@ object HudiCommands {
InsertIntoHoodieTableCommand,
RefreshIndexCommand,
RepairHoodieTableCommand,
ShowIndexCommand,
TruncateHoodieTableCommand,
Spark31AlterTableCommand)
}
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,58 @@ class HudiCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {
}
}
}

test("IndexBasedCommand") {
assume(
!isSparkV33OrGreater,
"Hudi index creation not supported on Spark 3.3 or greater currently")
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))

// CreateIndexCommand
val createIndex = s"CREATE INDEX $index1 ON $namespace1.$table1 USING LUCENE (id)"
AngersZhuuuu marked this conversation as resolved.
Show resolved Hide resolved
interceptContains[AccessControlException](
doAs(
someone,
sql(createIndex)))(s"does not have [alter] privilege on [$namespace1/$table1]")
doAs(admin, sql(createIndex))

// RefreshIndexCommand
val refreshIndex = s"REFRESH INDEX $index1 ON $namespace1.$table1"
interceptContains[AccessControlException](
doAs(
someone,
sql(refreshIndex)))(s"does not have [select] privilege on [$namespace1/$table1]")
doAs(admin, sql(refreshIndex))

// ShowIndexesCommand
val showIndex = s"SHOW INDEXES FROM TABLE $namespace1.$table1"
interceptContains[AccessControlException](
doAs(
someone,
sql(showIndex)))(s"does not have [select] privilege on [$namespace1/$table1]")
doAs(admin, sql(showIndex))

// DropIndexCommand
val dropIndex = s"DROP INDEX $index1 ON $namespace1.$table1"
interceptContains[AccessControlException](
doAs(
someone,
sql(dropIndex)))(s"does not have [alter] privilege on [$namespace1/$table1]")
doAs(admin, sql(dropIndex))
}
}
}
Loading