@@ -484,4 +484,106 @@ class IcebergCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite
484
484
doAs(admin, sql(dropIdentifierSql))
485
485
}
486
486
}
487
+
488
+ test(" CREATE BRANCH for Iceberg" ) {
489
+ val table = s " $catalogV2. $namespace1.partitioned_table "
490
+ withCleanTmpResources(Seq ((table, " table" ))) {
491
+ doAs(
492
+ admin,
493
+ sql(
494
+ s " CREATE TABLE $table (id int NOT NULL, name string, city string) USING iceberg " ))
495
+ doAs(admin, sql(s " INSERT INTO $table VALUES (1, 'test', 'city') " ))
496
+ val createBranchSql = s " ALTER TABLE $table CREATE BRANCH test_branch "
497
+ interceptEndsWith[AccessControlException ] {
498
+ doAs(someone, sql(createBranchSql))
499
+ }(s " does not have [alter] privilege on [ $namespace1/partitioned_table] " )
500
+ doAs(admin, sql(createBranchSql))
501
+ }
502
+ }
503
+
504
+ test(" CREATE TAG for Iceberg" ) {
505
+ val table = s " $catalogV2. $namespace1.partitioned_table "
506
+ withCleanTmpResources(Seq ((table, " table" ))) {
507
+ doAs(
508
+ admin,
509
+ sql(
510
+ s " CREATE TABLE $table (id int NOT NULL, name string, city string) USING iceberg " ))
511
+ doAs(admin, sql(s " INSERT INTO $table VALUES (1, 'test', 'city') " ))
512
+ val createTagSql = s " ALTER TABLE $table CREATE TAG test_tag "
513
+ interceptEndsWith[AccessControlException ] {
514
+ doAs(someone, sql(createTagSql))
515
+ }(s " does not have [alter] privilege on [ $namespace1/partitioned_table] " )
516
+ doAs(admin, sql(createTagSql))
517
+ }
518
+ }
519
+
520
+ test(" REPLACE BRANCH for Iceberg" ) {
521
+ val table = s " $catalogV2. $namespace1.partitioned_table "
522
+ withCleanTmpResources(Seq ((table, " table" ))) {
523
+ doAs(
524
+ admin,
525
+ sql(
526
+ s " CREATE TABLE $table (id int NOT NULL, name string, city string) USING iceberg " ))
527
+ doAs(admin, sql(s " INSERT INTO $table VALUES (1, 'test', 'city') " ))
528
+ doAs(admin, sql(s " ALTER TABLE $table CREATE BRANCH test_branch " ))
529
+ doAs(admin, sql(s " INSERT INTO $table VALUES (2, 'test2', 'city2') " ))
530
+ val replaceBranchSql = s " ALTER TABLE $table REPLACE BRANCH test_branch "
531
+ interceptEndsWith[AccessControlException ] {
532
+ doAs(someone, sql(replaceBranchSql))
533
+ }(s " does not have [alter] privilege on [ $namespace1/partitioned_table] " )
534
+ doAs(admin, sql(replaceBranchSql))
535
+ }
536
+ }
537
+
538
+ test(" REPLACE TAG for Iceberg" ) {
539
+ val table = s " $catalogV2. $namespace1.partitioned_table "
540
+ withCleanTmpResources(Seq ((table, " table" ))) {
541
+ doAs(
542
+ admin,
543
+ sql(
544
+ s " CREATE TABLE $table (id int NOT NULL, name string, city string) USING iceberg " ))
545
+ doAs(admin, sql(s " INSERT INTO $table VALUES (1, 'test', 'city') " ))
546
+ doAs(admin, sql(s " ALTER TABLE $table CREATE TAG test_tag " ))
547
+ doAs(admin, sql(s " INSERT INTO $table VALUES (2, 'test2', 'city2') " ))
548
+ val replaceTagSql = s " ALTER TABLE $table REPLACE TAG test_tag "
549
+ interceptEndsWith[AccessControlException ] {
550
+ doAs(someone, sql(replaceTagSql))
551
+ }(s " does not have [alter] privilege on [ $namespace1/partitioned_table] " )
552
+ doAs(admin, sql(replaceTagSql))
553
+ }
554
+ }
555
+
556
+ test(" DROP BRANCH for Iceberg" ) {
557
+ val table = s " $catalogV2. $namespace1.partitioned_table "
558
+ withCleanTmpResources(Seq ((table, " table" ))) {
559
+ doAs(
560
+ admin,
561
+ sql(
562
+ s " CREATE TABLE $table (id int NOT NULL, name string, city string) USING iceberg " ))
563
+ doAs(admin, sql(s " INSERT INTO $table VALUES (1, 'test', 'city') " ))
564
+ doAs(admin, sql(s " ALTER TABLE $table CREATE BRANCH test_branch " ))
565
+ val dropBranchSql = s " ALTER TABLE $table DROP BRANCH test_branch "
566
+ interceptEndsWith[AccessControlException ] {
567
+ doAs(someone, sql(dropBranchSql))
568
+ }(s " does not have [alter] privilege on [ $namespace1/partitioned_table] " )
569
+ doAs(admin, sql(dropBranchSql))
570
+ }
571
+ }
572
+
573
+ test(" DROP TAG for Iceberg" ) {
574
+ val table = s " $catalogV2. $namespace1.partitioned_table "
575
+ withCleanTmpResources(Seq ((table, " table" ))) {
576
+ doAs(
577
+ admin,
578
+ sql(
579
+ s " CREATE TABLE $table (id int NOT NULL, name string, city string) USING iceberg " ))
580
+ doAs(admin, sql(s " INSERT INTO $table VALUES (1, 'test', 'city') " ))
581
+ doAs(admin, sql(s " ALTER TABLE $table CREATE TAG test_tag " ))
582
+ val dropTagSql = s " ALTER TABLE $table DROP TAG test_tag "
583
+ interceptEndsWith[AccessControlException ] {
584
+ doAs(someone, sql(dropTagSql))
585
+ }(s " does not have [alter] privilege on [ $namespace1/partitioned_table] " )
586
+ doAs(admin, sql(dropTagSql))
587
+ }
588
+ }
487
589
}
0 commit comments