Skip to content

Commit

Permalink
[KYUUBI #6950] Test changing column position
Browse files Browse the repository at this point in the history
### Why are the changes needed?

Ranger check test case missing paimon changing column position command, add the test case
#6950

### How was this patch tested?

Test ranger check with paimon changing column position command

### Was this patch authored or co-authored using generative AI tooling?

No

Closes #6955 from davidyuan1223/test_changing_column_position.

Closes #6950

520b537 [davidyuan] Merge branch 'master' into test_changing_column_position
1eed873 [davidyuan] test changing column position

Authored-by: davidyuan <[email protected]>
Signed-off-by: Kent Yao <[email protected]>
  • Loading branch information
davidyuan1223 authored and yaooqinn committed Mar 4, 2025
1 parent d5b01fa commit 4cab817
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,43 @@ class PaimonCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite {
}
}

test("Changing Column Position") {
withCleanTmpResources(Seq(
(s"$catalogV2.$namespace1.$table1", "table"))) {
val createTableSql =
s"""
|CREATE TABLE IF NOT EXISTS $catalogV2.$namespace1.$table1
|(id int, name string, a int, b int)
|USING paimon
|OPTIONS (
| 'primary-key' = 'id'
|)
|""".stripMargin
doAs(admin, sql(createTableSql))
val changingColumnPositionToFirst =
s"""
|ALTER TABLE $catalogV2.$namespace1.$table1
|ALTER COLUMN a FIRST
|""".stripMargin

interceptEndsWith[AccessControlException] {
doAs(someone, sql(changingColumnPositionToFirst))
}(s"does not have [alter] privilege on [$namespace1/$table1]")
doAs(admin, sql(changingColumnPositionToFirst))

val changingColumnPositionToAfter =
s"""
|ALTER TABLE $catalogV2.$namespace1.$table1
|ALTER COLUMN a AFTER name
|""".stripMargin

interceptEndsWith[AccessControlException] {
doAs(someone, sql(changingColumnPositionToAfter))
}(s"does not have [alter] privilege on [$namespace1/$table1]")
doAs(admin, sql(changingColumnPositionToAfter))
}
}

def createTableSql(namespace: String, table: String): String =
s"""
|CREATE TABLE IF NOT EXISTS $catalogV2.$namespace.$table
Expand Down

0 comments on commit 4cab817

Please sign in to comment.