You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ur...@apache.org on 2026/09/22 10:51:09 UTC

(spark) branch branch-4.x updated: [SPARK-58274][SQL] Assign a name to the error condition _LEGACY_ERROR_TEMP_1068

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

uros-b pushed a commit to branch branch-4.x
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-4.x by this push:
     new ffc9f47039f7 [SPARK-58274][SQL] Assign a name to the error condition _LEGACY_ERROR_TEMP_1068
ffc9f47039f7 is described below

commit ffc9f47039f77c2fb8a4445e899d9453c4469a63
Author: Matthew B. <mg...@uci.edu>
AuthorDate: Tue Sep 22 10:50:43 2026 +0000

    [SPARK-58274][SQL] Assign a name to the error condition _LEGACY_ERROR_TEMP_1068
    
    ### What changes were proposed in this pull request?
    
    Rename the legacy error condition `_LEGACY_ERROR_TEMP_1068` to the new named condition `CANNOT_USE_RESERVED_DATABASE_AS_CURRENT` (SQLSTATE `42939`). It is raised when a session sets the current database to the global temporary view database, e.g. `USE global_temp`.
    
    ### Why are the changes needed?
    
    The error-conditions README disallows new `_LEGACY_ERROR_TEMP_*` entries and asks existing ones to be resolved. This resolves one (part of SPARK-37935).
    
    ### Does this PR introduce _any_ user-facing change?
    
    Yes. The condition becomes `CANNOT_USE_RESERVED_DATABASE_AS_CURRENT`, and the message is reworded and now quotes the database name with backticks, e.g. ``Cannot use `global_temp` as the current database because the name is reserved for system use. To access global temporary views, use a qualified name, e.g. SELECT * FROM `global_temp`.viewName.``
    
    ### How was this patch tested?
    
    Converted the message assertion in `GlobalTempViewSuite` to `checkError`. `SparkThrowableSuite` and `GlobalTempViewSuite` pass.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Co-authored with Claude Opus 4.8
    
    Closes #58761 from Ma77Ball/assign-name-legacy-error-1068.
    
    Authored-by: Matthew B. <mg...@uci.edu>
    Signed-off-by: Uros Bojanic <22...@users.noreply.github.com>
    (cherry picked from commit 4fee759348db6cfb92d61ebe638f6444f1e5d6ec)
    Signed-off-by: Uros Bojanic <22...@users.noreply.github.com>
---
 common/utils/src/main/resources/error/error-conditions.json   | 11 ++++++-----
 .../org/apache/spark/sql/errors/QueryCompilationErrors.scala  |  4 ++--
 .../org/apache/spark/sql/execution/GlobalTempViewSuite.scala  |  6 ++++--
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/common/utils/src/main/resources/error/error-conditions.json b/common/utils/src/main/resources/error/error-conditions.json
index e1cf64b5e48d..66d9fc9bc9c5 100644
--- a/common/utils/src/main/resources/error/error-conditions.json
+++ b/common/utils/src/main/resources/error/error-conditions.json
@@ -981,6 +981,12 @@
     ],
     "sqlState" : "42000"
   },
+  "CANNOT_USE_RESERVED_DATABASE_AS_CURRENT" : {
+    "message" : [
+      "Cannot use <database> as the current database because the name is reserved for system use. To access global temporary views, use a qualified name, e.g. SELECT * FROM <database>.viewName."
+    ],
+    "sqlState" : "42939"
+  },
   "CANNOT_WRITE_STATE_STORE" : {
     "message" : [
       "Error writing state store files for provider <providerClass>."
@@ -10325,11 +10331,6 @@
       "<command> does not support nested column: <column>."
     ]
   },
-  "_LEGACY_ERROR_TEMP_1068" : {
-    "message" : [
-      "<database> is a system preserved database, you cannot use it as current database. To access global temporary views, you should use qualified name with the GLOBAL_TEMP_DATABASE, e.g. SELECT * FROM <database>.viewName."
-    ]
-  },
   "_LEGACY_ERROR_TEMP_1071" : {
     "message" : [
       "Some existing schema fields (<nonExistentColumnNames>) are not present in the new schema. We don't support dropping columns yet."
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala
index faaeae9d91a5..6ad8b7a6acbe 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala
@@ -1381,8 +1381,8 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat
 
   def cannotUsePreservedDatabaseAsCurrentDatabaseError(database: String): Throwable = {
     new AnalysisException(
-      errorClass = "_LEGACY_ERROR_TEMP_1068",
-      messageParameters = Map("database" -> database))
+      errorClass = "CANNOT_USE_RESERVED_DATABASE_AS_CURRENT",
+      messageParameters = Map("database" -> toSQLId(database)))
   }
 
   def createExternalTableWithoutLocationError(): Throwable = {
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/GlobalTempViewSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/GlobalTempViewSuite.scala
index 13035814dc80..4b812601d4ed 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/execution/GlobalTempViewSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/GlobalTempViewSuite.scala
@@ -98,8 +98,10 @@ class GlobalTempViewSuite extends SharedSparkSession {
       condition = "RESERVED_DATABASE_NAME",
       parameters = Map("database" -> s"`$globalTempDB`"))
 
-    val e2 = intercept[AnalysisException](sql(s"USE $globalTempDB"))
-    assert(e2.message.contains("system preserved database"))
+    checkError(
+      exception = intercept[AnalysisException](sql(s"USE $globalTempDB")),
+      condition = "CANNOT_USE_RESERVED_DATABASE_AS_CURRENT",
+      parameters = Map("database" -> s"`$globalTempDB`"))
   }
 
   test("CREATE GLOBAL TEMP VIEW USING") {


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