You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by "yabola (via GitHub)" <gi...@apache.org> on 2023/09/11 12:01:50 UTC

[GitHub] [kyuubi] yabola commented on a diff in pull request #5248: [AUTHZ] Check previleges for Iceberg's CALL to RewriteDataFilesProcedure procedure

yabola commented on code in PR #5248:
URL: https://github.com/apache/kyuubi/pull/5248#discussion_r1321441282


##########
extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/ranger/IcebergCatalogRangerSparkExtensionSuite.scala:
##########
@@ -226,4 +227,71 @@ class IcebergCatalogRangerSparkExtensionSuite extends RangerSparkExtensionSuite
     assert(e1.getMessage.contains(s"does not have [select] privilege" +
       s" on [$namespace1/$table1]"))
   }
+
+  test("CALL RewriteDataFilesProcedure") {
+    val tableName = "table_select_call_command_table"
+    val table = s"$catalogV2.$namespace1.$tableName"
+    val rewriteDataFiles1 = s"CALL $catalogV2.system.rewrite_data_files " +
+      s"(table => '$table', options => map('min-input-files','2'))"
+    val rewriteDataFiles2 = s"CALL $catalogV2.system.rewrite_data_files " +
+      s"(table => '$table', options => map('min-input-files','3'))"
+
+    withCleanTmpResources(Seq((table, "table"))) {
+      doAs(
+        admin, {
+          sql(s"CREATE TABLE IF NOT EXISTS $table  (id int, name string) USING iceberg")
+          sql(s"INSERT INTO $table VALUES (1, 'chenliang'), (2, 'tom')")
+          sql(s"INSERT INTO $table VALUES (3, 'julie'), (4, 'ross')")
+        })
+
+      // user bob has select permission on table
+      interceptContains[AccessControlException](doAs(icebergReadOnlyUser, sql(rewriteDataFiles1)))(
+        s"does not have [update] privilege on [$namespace1/$tableName]")
+      interceptContains[AccessControlException](doAs(icebergReadOnlyUser, sql(rewriteDataFiles2)))(
+        s"does not have [update] privilege on [$namespace1/$tableName]")
+
+      // user someone has no permission on table
+      interceptContains[AccessControlException](doAs(someone, sql(rewriteDataFiles1)))(
+        s"does not have [select] privilege on [$namespace1/$tableName]")
+      interceptContains[AccessControlException](doAs(someone, sql(rewriteDataFiles2)))(
+        s"does not have [select] privilege on [$namespace1/$tableName]")
+
+      withSingleCallEnabled {
+        interceptContains[AccessControlException](doAs(someone, sql(rewriteDataFiles1).explain()))(
+          s"does not have [select] privilege on [$namespace1/$tableName]," +
+            s" [update] privilege on [$namespace1/$tableName]")
+      }
+
+      /**
+       * Situation 1:
+       * Two logical plans triggered
+       * when ( input-files(2) >= min-input-files(2) ):
+       *
+       * == Physical Plan 1 ==
+       * (1) Call
+       *
+       * == Physical Plan 2 ==
+       * AppendData (3)
+       * +- * ColumnarToRow (2)
+       * +- BatchScan local.iceberg_ns.call_command_table (1)
+       */
+      doAs(
+        admin, {
+          val result2 = sql(rewriteDataFiles1).collect()
+          // rewrite 2 files
+          assert(result2(0)(0) === 2)
+        })
+
+      /**
+       * Situation 2:
+       * Only one logical plan triggered
+       * when ( input-files(2) < min-input-files(3) )

Review Comment:
   I have added the physical plan.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org