Skip to content

Commit 231ed33

Browse files
committed
sort spi file
1 parent 6d2a5bf commit 231ed33

File tree

3 files changed

+201
-0
lines changed

3 files changed

+201
-0
lines changed

extensions/spark/kyuubi-spark-authz/src/main/resources/table_command_spec.json

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,6 +1862,38 @@
18621862
"opType" : "QUERY",
18631863
"queryDescs" : [ ],
18641864
"uriDescs" : [ ]
1865+
}, {
1866+
"classname" : "org.apache.spark.sql.catalyst.plans.logical.DropIdentifierFields",
1867+
"tableDescs" : [ {
1868+
"fieldName" : "table",
1869+
"fieldExtractor" : "ArrayBufferTableExtractor",
1870+
"columnDesc" : null,
1871+
"actionTypeDesc" : null,
1872+
"tableTypeDesc" : null,
1873+
"catalogDesc" : null,
1874+
"isInput" : false,
1875+
"setCurrentDatabaseIfMissing" : false,
1876+
"comment" : "Iceberg"
1877+
} ],
1878+
"opType" : "ALTERTABLE_PROPERTIES",
1879+
"queryDescs" : [ ],
1880+
"uriDescs" : [ ]
1881+
}, {
1882+
"classname" : "org.apache.spark.sql.catalyst.plans.logical.DropPartitionField",
1883+
"tableDescs" : [ {
1884+
"fieldName" : "table",
1885+
"fieldExtractor" : "ArrayBufferTableExtractor",
1886+
"columnDesc" : null,
1887+
"actionTypeDesc" : null,
1888+
"tableTypeDesc" : null,
1889+
"catalogDesc" : null,
1890+
"isInput" : false,
1891+
"setCurrentDatabaseIfMissing" : false,
1892+
"comment" : "Iceberg"
1893+
} ],
1894+
"opType" : "ALTERTABLE_PROPERTIES",
1895+
"queryDescs" : [ ],
1896+
"uriDescs" : [ ]
18651897
}, {
18661898
"classname" : "org.apache.spark.sql.catalyst.plans.logical.MergeIntoIcebergTable",
18671899
"tableDescs" : [ {
@@ -1887,6 +1919,54 @@
18871919
"comment" : ""
18881920
} ],
18891921
"uriDescs" : [ ]
1922+
}, {
1923+
"classname" : "org.apache.spark.sql.catalyst.plans.logical.ReplacePartitionField",
1924+
"tableDescs" : [ {
1925+
"fieldName" : "table",
1926+
"fieldExtractor" : "ArrayBufferTableExtractor",
1927+
"columnDesc" : null,
1928+
"actionTypeDesc" : null,
1929+
"tableTypeDesc" : null,
1930+
"catalogDesc" : null,
1931+
"isInput" : false,
1932+
"setCurrentDatabaseIfMissing" : false,
1933+
"comment" : "Iceberg"
1934+
} ],
1935+
"opType" : "ALTERTABLE_PROPERTIES",
1936+
"queryDescs" : [ ],
1937+
"uriDescs" : [ ]
1938+
}, {
1939+
"classname" : "org.apache.spark.sql.catalyst.plans.logical.SetIdentifierFields",
1940+
"tableDescs" : [ {
1941+
"fieldName" : "table",
1942+
"fieldExtractor" : "ArrayBufferTableExtractor",
1943+
"columnDesc" : null,
1944+
"actionTypeDesc" : null,
1945+
"tableTypeDesc" : null,
1946+
"catalogDesc" : null,
1947+
"isInput" : false,
1948+
"setCurrentDatabaseIfMissing" : false,
1949+
"comment" : "Iceberg"
1950+
} ],
1951+
"opType" : "ALTERTABLE_PROPERTIES",
1952+
"queryDescs" : [ ],
1953+
"uriDescs" : [ ]
1954+
}, {
1955+
"classname" : "org.apache.spark.sql.catalyst.plans.logical.SetWriteDistributionAndOrdering",
1956+
"tableDescs" : [ {
1957+
"fieldName" : "table",
1958+
"fieldExtractor" : "ArrayBufferTableExtractor",
1959+
"columnDesc" : null,
1960+
"actionTypeDesc" : null,
1961+
"tableTypeDesc" : null,
1962+
"catalogDesc" : null,
1963+
"isInput" : false,
1964+
"setCurrentDatabaseIfMissing" : false,
1965+
"comment" : "Iceberg"
1966+
} ],
1967+
"opType" : "ALTERTABLE_PROPERTIES",
1968+
"queryDescs" : [ ],
1969+
"uriDescs" : [ ]
18901970
}, {
18911971
"classname" : "org.apache.spark.sql.catalyst.plans.logical.UnresolvedMergeIntoIcebergTable",
18921972
"tableDescs" : [ {

extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/gen/IcebergCommands.scala

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,42 @@ object IcebergCommands extends CommandSpecs[TableCommandSpec] {
6868
TableCommandSpec(cmd, Seq(tableDesc), opType = OperationType.ALTERTABLE_PROPERTIES)
6969
}
7070

71+
val DropPartitionField = {
72+
val cmd = "org.apache.spark.sql.catalyst.plans.logical.DropPartitionField"
73+
AddPartitionFiled.copy(cmd)
74+
}
75+
76+
val ReplacePartitionField = {
77+
val cmd = "org.apache.spark.sql.catalyst.plans.logical.ReplacePartitionField"
78+
AddPartitionFiled.copy(cmd)
79+
}
80+
81+
val WriteDistributionAndOrdering = {
82+
val cmd = "org.apache.spark.sql.catalyst.plans.logical.SetWriteDistributionAndOrdering"
83+
AddPartitionFiled.copy(cmd)
84+
}
85+
86+
val SetIdentifierFields = {
87+
val cmd = "org.apache.spark.sql.catalyst.plans.logical.SetIdentifierFields"
88+
AddPartitionFiled.copy(cmd)
89+
}
90+
91+
val DropIdentifierFields = {
92+
val cmd = "org.apache.spark.sql.catalyst.plans.logical.DropIdentifierFields"
93+
AddPartitionFiled.copy(cmd)
94+
}
95+
7196
override def specs: Seq[TableCommandSpec] = Seq(
7297
CallProcedure,
7398
DeleteFromIcebergTable,
7499
UpdateIcebergTable,
75100
MergeIntoIcebergTable,
76101
AddPartitionFiled,
102+
DropPartitionField,
103+
ReplacePartitionField,
104+
WriteDistributionAndOrdering,
105+
SetIdentifierFields,
106+
DropIdentifierFields,
77107
MergeIntoIcebergTable.copy(classname =
78108
"org.apache.spark.sql.catalyst.plans.logical.UnresolvedMergeIntoIcebergTable"))
79109
}

extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/ranger/IcebergCatalogRangerSparkExtensionSuite.scala

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,4 +393,95 @@ class IcebergCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite
393393
doAs(admin, sql(addPartitionSql))
394394
}
395395
}
396+
397+
test("ALTER TABLE DROP PARTITION FIELD for Iceberg") {
398+
val table = s"$catalogV2.$namespace1.partitioned_table"
399+
withCleanTmpResources(Seq((table, "table"))) {
400+
doAs(
401+
admin,
402+
sql(
403+
s"CREATE TABLE $table (id int, name string, city string) USING iceberg PARTITIONED BY (id, city)"))
404+
val addPartitionSql = s"ALTER TABLE $table DROP PARTITION FIELD id"
405+
interceptEndsWith[AccessControlException] {
406+
doAs(someone, sql(addPartitionSql))
407+
}(s"does not have [alter] privilege on [$namespace1/partitioned_table]")
408+
doAs(admin, sql(addPartitionSql))
409+
}
410+
}
411+
412+
test("ALTER TABLE REPLACE PARTITION FIELD for Iceberg") {
413+
val table = s"$catalogV2.$namespace1.partitioned_table"
414+
withCleanTmpResources(Seq((table, "table"))) {
415+
doAs(
416+
admin,
417+
sql(
418+
s"CREATE TABLE $table (id int, name string, city string) USING iceberg PARTITIONED BY (city)"))
419+
val addPartitionSql = s"ALTER TABLE $table REPLACE PARTITION FIELD city WITH id"
420+
interceptEndsWith[AccessControlException] {
421+
doAs(someone, sql(addPartitionSql))
422+
}(s"does not have [alter] privilege on [$namespace1/partitioned_table]")
423+
doAs(admin, sql(addPartitionSql))
424+
}
425+
}
426+
427+
test("ALTER TABLE WRITE ORDER BY for Iceberg") {
428+
val table = s"$catalogV2.$namespace1.partitioned_table"
429+
withCleanTmpResources(Seq((table, "table"))) {
430+
doAs(
431+
admin,
432+
sql(
433+
s"CREATE TABLE $table (id int, name string, city string) USING iceberg"))
434+
val writeOrderBySql = s"ALTER TABLE $table WRITE ORDERED BY id"
435+
interceptEndsWith[AccessControlException] {
436+
doAs(someone, sql(writeOrderBySql))
437+
}(s"does not have [alter] privilege on [$namespace1/partitioned_table]")
438+
doAs(admin, sql(writeOrderBySql))
439+
}
440+
}
441+
442+
test("ALTER TABLE WRITE DISTRIBUTED BY PARTITION for Iceberg") {
443+
val table = s"$catalogV2.$namespace1.partitioned_table"
444+
withCleanTmpResources(Seq((table, "table"))) {
445+
doAs(
446+
admin,
447+
sql(
448+
s"CREATE TABLE $table (id int, name string, city string) USING iceberg PARTITIONED BY (city)"))
449+
val writeDistributedSql = s"ALTER TABLE $table WRITE DISTRIBUTED BY PARTITION"
450+
interceptEndsWith[AccessControlException] {
451+
doAs(someone, sql(writeDistributedSql))
452+
}(s"does not have [alter] privilege on [$namespace1/partitioned_table]")
453+
doAs(admin, sql(writeDistributedSql))
454+
}
455+
}
456+
457+
test("ALTER TABLE SET IDENTIFIER FIELD for Iceberg") {
458+
val table = s"$catalogV2.$namespace1.partitioned_table"
459+
withCleanTmpResources(Seq((table, "table"))) {
460+
doAs(
461+
admin,
462+
sql(
463+
s"CREATE TABLE $table (id int NOT NULL, name string, city string) USING iceberg"))
464+
val setIdentifierSql = s"ALTER TABLE $table SET IDENTIFIER FIELDS id"
465+
interceptEndsWith[AccessControlException] {
466+
doAs(someone, sql(setIdentifierSql))
467+
}(s"does not have [alter] privilege on [$namespace1/partitioned_table]")
468+
doAs(admin, sql(setIdentifierSql))
469+
}
470+
}
471+
472+
test("ALTER TABLE DROP IDENTIFIER FIELD for Iceberg") {
473+
val table = s"$catalogV2.$namespace1.partitioned_table"
474+
withCleanTmpResources(Seq((table, "table"))) {
475+
doAs(
476+
admin,
477+
sql(
478+
s"CREATE TABLE $table (id int NOT NULL, name string, city string) USING iceberg"))
479+
doAs(admin, sql(s"ALTER TABLE $table SET IDENTIFIER FIELDS id"))
480+
val dropIdentifierSql = s"ALTER TABLE $table DROP IDENTIFIER FIELDS id"
481+
interceptEndsWith[AccessControlException] {
482+
doAs(someone, sql(dropIdentifierSql))
483+
}(s"does not have [alter] privilege on [$namespace1/partitioned_table]")
484+
doAs(admin, sql(dropIdentifierSql))
485+
}
486+
}
396487
}

0 commit comments

Comments
 (0)