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

maxgekk 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 3bff4f6339f [SPARK-41135][SQL] Rename `UNSUPPORTED_EMPTY_LOCATION` to 
`INVALID_EMPTY_LOCATION`
3bff4f6339f is described below

commit 3bff4f6339f54d19362a0c03ef2b396e47881fd8
Author: itholic <haejoon....@databricks.com>
AuthorDate: Tue Nov 22 13:14:13 2022 +0300

    [SPARK-41135][SQL] Rename `UNSUPPORTED_EMPTY_LOCATION` to 
`INVALID_EMPTY_LOCATION`
    
    ### What changes were proposed in this pull request?
    
    This PR proposes to rename `UNSUPPORTED_EMPTY_LOCATION` to 
`INVALID_EMPTY_LOCATION`.
    
    ### Why are the changes needed?
    
    Error class and its message should be clear/brief, and should not 
ambiguously specific when it illustrates things that possibly supported in the 
future.
    
    ### Does this PR introduce _any_ user-facing change?
    
    Error message changes
    
    From
    ```
    "Unsupported empty location."
    ```
    
    To
    ```
    "The location name cannot be empty string, but `...` was given."
    ```
    
    ### How was this patch tested?
    
    ```
    $ build/sbt “sql/testOnly org.apache.spark.sql.SQLQueryTestSuite*”
    $ build/sbt "core/testOnly *SparkThrowableSuite"
    ```
    
    Closes #38650 from itholic/SPARK-41135.
    
    Authored-by: itholic <haejoon....@databricks.com>
    Signed-off-by: Max Gekk <max.g...@gmail.com>
---
 core/src/main/resources/error/error-classes.json               | 10 +++++-----
 .../org/apache/spark/sql/errors/QueryExecutionErrors.scala     |  6 +++---
 .../spark/sql/catalyst/analysis/ResolveSessionCatalog.scala    |  4 ++--
 .../sql/execution/datasources/v2/DataSourceV2Strategy.scala    |  4 ++--
 .../execution/command/AlterNamespaceSetLocationSuiteBase.scala |  4 ++--
 .../spark/sql/execution/command/CreateNamespaceSuiteBase.scala |  4 ++--
 6 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/core/src/main/resources/error/error-classes.json 
b/core/src/main/resources/error/error-classes.json
index ae76a52e40f..77d155bfc21 100644
--- a/core/src/main/resources/error/error-classes.json
+++ b/core/src/main/resources/error/error-classes.json
@@ -676,6 +676,11 @@
     ],
     "sqlState" : "42000"
   },
+  "INVALID_EMPTY_LOCATION" : {
+    "message" : [
+      "The location name cannot be empty string, but `<location>` was given."
+    ]
+  },
   "INVALID_FIELD_NAME" : {
     "message" : [
       "Field name <fieldName> is invalid: <path> is not a struct."
@@ -1181,11 +1186,6 @@
       }
     }
   },
-  "UNSUPPORTED_EMPTY_LOCATION" : {
-    "message" : [
-      "Unsupported empty location."
-    ]
-  },
   "UNSUPPORTED_FEATURE" : {
     "message" : [
       "The feature is not supported:"
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 6081d9f32a5..5db54f7f4cf 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
@@ -2806,10 +2806,10 @@ private[sql] object QueryExecutionErrors extends 
QueryErrorsBase {
         "size" -> elementSize.toString))
   }
 
-  def unsupportedEmptyLocationError(): SparkIllegalArgumentException = {
+  def invalidEmptyLocationError(location: String): 
SparkIllegalArgumentException = {
     new SparkIllegalArgumentException(
-      errorClass = "UNSUPPORTED_EMPTY_LOCATION",
-      messageParameters = Map.empty)
+      errorClass = "INVALID_EMPTY_LOCATION",
+      messageParameters = Map("location" -> location))
   }
 
   def malformedProtobufMessageDetectedInMessageParsingError(e: Throwable): 
Throwable = {
diff --git 
a/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
 
b/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
index d00d07150b0..d7e26b04ce4 100644
--- 
a/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
+++ 
b/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
@@ -134,7 +134,7 @@ class ResolveSessionCatalog(val catalogManager: 
CatalogManager)
 
     case SetNamespaceLocation(DatabaseInSessionCatalog(db), location) if 
conf.useV1Command =>
       if (StringUtils.isEmpty(location)) {
-        throw QueryExecutionErrors.unsupportedEmptyLocationError()
+        throw QueryExecutionErrors.invalidEmptyLocationError(location)
       }
       AlterDatabaseSetLocationCommand(db, location)
 
@@ -243,7 +243,7 @@ class ResolveSessionCatalog(val catalogManager: 
CatalogManager)
       val location = c.properties.get(SupportsNamespaces.PROP_LOCATION)
       val newProperties = c.properties -- 
CatalogV2Util.NAMESPACE_RESERVED_PROPERTIES
       if (location.isDefined && location.get.isEmpty) {
-        throw QueryExecutionErrors.unsupportedEmptyLocationError()
+        throw QueryExecutionErrors.invalidEmptyLocationError(location.get)
       }
       CreateDatabaseCommand(name, c.ifNotExists, location, comment, 
newProperties)
 
diff --git 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala
 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala
index 88dbe49c5af..34dd1fb9c39 100644
--- 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala
+++ 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala
@@ -353,7 +353,7 @@ class DataSourceV2Strategy(session: SparkSession) extends 
Strategy with Predicat
 
     case SetNamespaceLocation(ResolvedNamespace(catalog, ns), location) =>
       if (StringUtils.isEmpty(location)) {
-        throw QueryExecutionErrors.unsupportedEmptyLocationError()
+        throw QueryExecutionErrors.invalidEmptyLocationError(location)
       }
       AlterNamespaceSetPropertiesExec(
         catalog.asNamespaceCatalog,
@@ -369,7 +369,7 @@ class DataSourceV2Strategy(session: SparkSession) extends 
Strategy with Predicat
     case CreateNamespace(ResolvedNamespace(catalog, ns), ifNotExists, 
properties) =>
       val location = properties.get(SupportsNamespaces.PROP_LOCATION)
       if (location.isDefined && location.get.isEmpty) {
-        throw QueryExecutionErrors.unsupportedEmptyLocationError()
+        throw QueryExecutionErrors.invalidEmptyLocationError(location.get)
       }
       val finalProperties = 
properties.get(SupportsNamespaces.PROP_LOCATION).map { loc =>
         properties + (SupportsNamespaces.PROP_LOCATION -> 
makeQualifiedDBObjectPath(loc))
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/AlterNamespaceSetLocationSuiteBase.scala
 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/AlterNamespaceSetLocationSuiteBase.scala
index 653a6d91891..5b78665d878 100644
--- 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/AlterNamespaceSetLocationSuiteBase.scala
+++ 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/AlterNamespaceSetLocationSuiteBase.scala
@@ -51,8 +51,8 @@ trait AlterNamespaceSetLocationSuiteBase extends QueryTest 
with DDLCommandTestUt
         exception = intercept[SparkIllegalArgumentException] {
           sql(sqlText)
         },
-        errorClass = "UNSUPPORTED_EMPTY_LOCATION",
-        parameters = Map.empty)
+        errorClass = "INVALID_EMPTY_LOCATION",
+        parameters = Map("location" -> ""))
     }
   }
 
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala
 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala
index 1f0c3513dc9..e90469c29a5 100644
--- 
a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala
+++ 
b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala
@@ -74,8 +74,8 @@ trait CreateNamespaceSuiteBase extends QueryTest with 
DDLCommandTestUtils {
           exception = intercept[SparkIllegalArgumentException] {
             sql(sqlText)
           },
-          errorClass = "UNSUPPORTED_EMPTY_LOCATION",
-          parameters = Map.empty)
+          errorClass = "INVALID_EMPTY_LOCATION",
+          parameters = Map("location" -> ""))
         val uri = new Path(path).toUri
         sql(s"CREATE NAMESPACE $ns LOCATION '$uri'")
         // Make sure the location is qualified.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to