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 @@ -1567,6 +1567,62 @@
} ],
"opType" : "CREATETABLE",
"queryDescs" : [ ]
}, {
"classname" : "org.apache.spark.sql.hudi.command.CreateIndexCommand",
"tableDescs" : [ {
"fieldName" : "table",
"fieldExtractor" : "CatalogTableTableExtractor",
"columnDesc" : null,
"actionTypeDesc" : null,
"tableTypeDesc" : null,
"catalogDesc" : null,
"isInput" : false,
"setCurrentDatabaseIfMissing" : false
} ],
"opType" : "CREATETABLE",
"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" : "DROPTABLE",
"queryDescs" : [ ]
}, {
"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.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 @@ -100,6 +100,30 @@ object HudiCommands {
TableCommandSpec(cmd, Seq(tableDesc1, tableDesc2), CREATETABLE)
}

val CreateIndexCommand = {
val cmd = "org.apache.spark.sql.hudi.command.CreateIndexCommand"
val tableDesc = TableDesc("table", classOf[CatalogTableTableExtractor])
TableCommandSpec(cmd, Seq(tableDesc), CREATETABLE)
AngersZhuuuu marked this conversation as resolved.
Show resolved Hide resolved
}

val DropIndexCommand = {
val cmd = "org.apache.spark.sql.hudi.command.DropIndexCommand"
val tableDesc = TableDesc("table", classOf[CatalogTableTableExtractor])
TableCommandSpec(cmd, Seq(tableDesc), DROPTABLE)
AngersZhuuuu marked this conversation as resolved.
Show resolved Hide resolved
}

val ShowIndexCommand = {
val cmd = "org.apache.spark.sql.hudi.command.ShowIndexesCommand"
val tableDesc = TableDesc("table", classOf[CatalogTableTableExtractor], isInput = true)
TableCommandSpec(cmd, Seq(tableDesc))
}

val RefreshIndexCommand = {
val cmd = "org.apache.spark.sql.hudi.command.RefreshIndexCommand"
val tableDesc = TableDesc("table", classOf[CatalogTableTableExtractor], isInput = true)
TableCommandSpec(cmd, Seq(tableDesc))
}

val data: Array[TableCommandSpec] = Array(
AlterHoodieTableAddColumnsCommand,
AlterHoodieTableChangeColumnCommand,
Expand All @@ -109,5 +133,9 @@ object HudiCommands {
Spark31AlterTableCommand,
CreateHoodieTableCommand,
CreateHoodieTableAsSelectCommand,
CreateHoodieTableLikeCommand)
CreateHoodieTableLikeCommand,
CreateIndexCommand,
DropIndexCommand,
ShowIndexCommand,
RefreshIndexCommand)
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class HudiCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {
val table1 = "table1_hoodie"
val table2 = "table2_hoodie"
val outputTable1 = "outputTable_hoodie"
val index1 = "table_hoodie_index1"

override def withFixture(test: NoArgTest): Outcome = {
assume(isSupportedVersion)
Expand Down Expand Up @@ -206,4 +207,55 @@ class HudiCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {
|""".stripMargin)))(s"does not have [select] privilege on [$namespace1/$table1]")
}
}

test("IndexBasedCommand") {
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 [create] 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 [drop] privilege on [$namespace1/$table1]")
doAs(admin, sql(dropIndex))
}
}
}
Loading