From 3da8f70668929581d6e651751fa23cfa32ab221e Mon Sep 17 00:00:00 2001 From: Haejoon Lee Date: Fri, 25 Oct 2024 12:55:58 +0200 Subject: [PATCH] [SPARK-50015][SQL] Assign appropriate error condition for `_LEGACY_ERROR_TEMP_1125`: `MISSING_DATABASE_FOR_V1_SESSION_CATALOG` ### What changes were proposed in this pull request? This PR proposes to assign proper error condition & sqlstate for `_LEGACY_ERROR_TEMP_1125`: `MISSING_DATABASE_FOR_V1_SESSION_CATALOG` ### Why are the changes needed? To improve the error message by assigning proper error condition and SQLSTATE ### Does this PR introduce _any_ user-facing change? No, only user-facing error message improved ### How was this patch tested? Updated the existing tests ### Was this patch authored or co-authored using generative AI tooling? No Closes #48652 from itholic/LEGACY_1125. Authored-by: Haejoon Lee Signed-off-by: Max Gekk --- .../src/main/resources/error/error-conditions.json | 11 ++++++----- .../spark/sql/errors/QueryCompilationErrors.scala | 2 +- .../sql/execution/command/v1/ShowTablesSuite.scala | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/common/utils/src/main/resources/error/error-conditions.json b/common/utils/src/main/resources/error/error-conditions.json index f9cdeb7e3fafa..68ccf7244cc39 100644 --- a/common/utils/src/main/resources/error/error-conditions.json +++ b/common/utils/src/main/resources/error/error-conditions.json @@ -3477,6 +3477,12 @@ }, "sqlState" : "XX000" }, + "MISSING_DATABASE_FOR_V1_SESSION_CATALOG" : { + "message" : [ + "Database name is not specified in the v1 session catalog. Please ensure to provide a valid database name when interacting with the v1 catalog." + ], + "sqlState" : "3F000" + }, "MISSING_GROUP_BY" : { "message" : [ "The query does not include a GROUP BY clause. Add GROUP BY or turn it into the window functions using OVER clauses." @@ -6157,11 +6163,6 @@ "Cannot rename a table with ALTER VIEW. Please use ALTER TABLE instead." ] }, - "_LEGACY_ERROR_TEMP_1125" : { - "message" : [ - "Database from v1 session catalog is not specified." - ] - }, "_LEGACY_ERROR_TEMP_1126" : { "message" : [ "Nested databases are not supported by v1 session catalog: ." 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 acee5c2a86e10..8332d82b7a7b8 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 @@ -1607,7 +1607,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat def databaseFromV1SessionCatalogNotSpecifiedError(): Throwable = { new AnalysisException( - errorClass = "_LEGACY_ERROR_TEMP_1125", + errorClass = "MISSING_DATABASE_FOR_V1_SESSION_CATALOG", messageParameters = Map.empty) } diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/v1/ShowTablesSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/v1/ShowTablesSuite.scala index 001267a37d382..92bea4d8655c5 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/v1/ShowTablesSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/v1/ShowTablesSuite.scala @@ -102,7 +102,7 @@ trait ShowTablesSuiteBase extends command.ShowTablesSuiteBase with command.Tests exception = intercept[AnalysisException] { sql(showTableCmd) }, - condition = "_LEGACY_ERROR_TEMP_1125", + condition = "MISSING_DATABASE_FOR_V1_SESSION_CATALOG", parameters = Map.empty ) }