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


##########
extensions/spark/kyuubi-spark-authz/src/test/scala/org/apache/kyuubi/plugin/spark/authz/ranger/IcebergCatalogRangerSparkExtensionSuite.scala:
##########
@@ -226,4 +227,74 @@ 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 `user_read_only_on_iceberg` has select permission on database 
`iceberg_ns`
+      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 ==
+       * Call (1)
+       *
+       * == 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

Review Comment:
   It means number of data files which were re-written by this command.  The 
explanation of the output of this command can refer to 
https://iceberg.apache.org/docs/latest/spark-procedures/#rewrite_data_files
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to