This is an automated email from the ASF dual-hosted git repository.

wenchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 757e5448c4c [SPARK-41984][SQL] Rename & improve error message for 
`RESET_PERMISSION_TO_ORIGINAL`
757e5448c4c is described below

commit 757e5448c4cf9be0728766ed02cd05bd0926e215
Author: itholic <[email protected]>
AuthorDate: Wed Jan 18 17:17:06 2023 +0800

    [SPARK-41984][SQL] Rename & improve error message for 
`RESET_PERMISSION_TO_ORIGINAL`
    
    ### What changes were proposed in this pull request?
    
    This PR proposes to rename & improve error message for 
`RESET_PERMISSION_TO_ORIGINAL`
    
    ### Why are the changes needed?
    
    We should have proper name and error message for error classes.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    `./build/sbt "sql/testOnly org.apache.spark.sql.SQLQueryTestSuite*"`
    
    Closes #39507 from itholic/RESET_PERMISSION_TO_ORIGINAL.
    
    Authored-by: itholic <[email protected]>
    Signed-off-by: Wenchen Fan <[email protected]>
---
 core/src/main/resources/error/error-classes.json               | 10 +++++-----
 .../org/apache/spark/sql/errors/QueryExecutionErrors.scala     | 10 +++-------
 .../scala/org/apache/spark/sql/execution/command/tables.scala  |  4 ++--
 .../apache/spark/sql/errors/QueryExecutionErrorsSuite.scala    |  7 +++----
 4 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/core/src/main/resources/error/error-classes.json 
b/core/src/main/resources/error/error-classes.json
index 9db0dc74562..39c23054945 100644
--- a/core/src/main/resources/error/error-classes.json
+++ b/core/src/main/resources/error/error-classes.json
@@ -93,6 +93,11 @@
     ],
     "sqlState" : "22007"
   },
+  "CANNOT_RESTORE_PERMISSIONS_FOR_PATH" : {
+    "message" : [
+      "Failed to set permissions on created path <path> back to <permission>."
+    ]
+  },
   "CANNOT_UP_CAST_DATATYPE" : {
     "message" : [
       "Cannot up cast <expression> from <sourceType> to <targetType>.",
@@ -1149,11 +1154,6 @@
     ],
     "sqlState" : "42K03"
   },
-  "RESET_PERMISSION_TO_ORIGINAL" : {
-    "message" : [
-      "Failed to set original permission <permission> back to the created 
path: <path>. Exception: <message>"
-    ]
-  },
   "ROUTINE_ALREADY_EXISTS" : {
     "message" : [
       "Cannot create the function <routineName> because it already exists.",
diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
index a957fffc97c..0473736d018 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala
@@ -2245,16 +2245,12 @@ private[sql] object QueryExecutionErrors extends 
QueryErrorsBase {
       cause = null)
   }
 
-  def failToSetOriginalPermissionBackError(
-      permission: FsPermission,
-      path: Path,
-      e: Throwable): Throwable = {
+  def cannotRestorePermissionsForPathError(permission: FsPermission, path: 
Path): Throwable = {
     new SparkSecurityException(
-      errorClass = "RESET_PERMISSION_TO_ORIGINAL",
+      errorClass = "CANNOT_RESTORE_PERMISSIONS_FOR_PATH",
       messageParameters = Map(
         "permission" -> permission.toString,
-        "path" -> path.toString,
-        "message" -> e.getMessage))
+        "path" -> path.toString))
   }
 
   def failToSetOriginalACLBackError(
diff --git 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala
index 5e733ad9e5b..b47f0e376ac 100644
--- 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala
+++ 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala
@@ -530,8 +530,8 @@ case class TruncateTableCommand(
                 fs.setPermission(path, permission)
               } catch {
                 case NonFatal(e) =>
-                  throw 
QueryExecutionErrors.failToSetOriginalPermissionBackError(
-                    permission, path, e)
+                  throw 
QueryExecutionErrors.cannotRestorePermissionsForPathError(
+                    permission, path)
               }
             }
             optAcls.foreach { acls =>
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala
 
b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala
index e692a1e2ffa..70311a2f7b8 100644
--- 
a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala
+++ 
b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionErrorsSuite.scala
@@ -417,7 +417,7 @@ class QueryExecutionErrorsSuite
     }
   }
 
-  test("RESET_PERMISSION_TO_ORIGINAL: can't set permission") {
+  test("CANNOT_RESTORE_PERMISSIONS_FOR_PATH: can't set permission") {
       withTable("t") {
         withSQLConf(
           "fs.file.impl" -> classOf[FakeFileSystemSetPermission].getName,
@@ -431,10 +431,9 @@ class QueryExecutionErrorsSuite
 
           checkError(
             exception = e.getCause.asInstanceOf[SparkSecurityException],
-            errorClass = "RESET_PERMISSION_TO_ORIGINAL",
+            errorClass = "CANNOT_RESTORE_PERMISSIONS_FOR_PATH",
             parameters = Map("permission" -> ".+",
-              "path" -> ".+",
-              "message" -> ".+"),
+              "path" -> ".+"),
             matchPVals = true)
       }
     }


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

Reply via email to