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/08 09:25:07 UTC
(spark) branch branch-4.x updated: [SPARK-59129][SQL] Assign a name to the error condition _LEGACY_ERROR_TEMP_2033
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 c0f6b9820c01 [SPARK-59129][SQL] Assign a name to the error condition _LEGACY_ERROR_TEMP_2033
c0f6b9820c01 is described below
commit c0f6b9820c01bf440eaa32792048b66b2c93671a
Author: Dieter Kling <42...@users.noreply.github.com>
AuthorDate: Tue Sep 8 09:24:43 2026 +0000
[SPARK-59129][SQL] Assign a name to the error condition _LEGACY_ERROR_TEMP_2033
### What changes were proposed in this pull request?
Renames `_LEGACY_ERROR_TEMP_2033` to `UNABLE_TO_CREATE_DATABASE_DIRECTORY`. It's raised by `QueryExecutionErrors.unableToCreateDatabaseAsFailedToCreateDirectoryError` when `InMemoryCatalog.createDatabase` can't create the database's backing directory. SQLSTATE `58030` follows the same convention as other filesystem I/O failures such as `FAILED_CREATE_CHECKPOINT_DIRECTORY` and `UNABLE_TO_FETCH_HIVE_TABLES`. Message text and parameters are unchanged.
### Why are the changes needed?
Part of the SPARK-37935 effort to replace `_LEGACY_ERROR_TEMP_*` placeholders with proper error conditions.
### Does this PR introduce _any_ user-facing change?
Yes. The error condition name changes from `_LEGACY_ERROR_TEMP_2033` to `UNABLE_TO_CREATE_DATABASE_DIRECTORY` and now carries SQLSTATE `58030`. The rendered message is unchanged.
### How was this patch tested?
Added a `checkError` test in `InMemoryCatalogSuite` that points `createDatabase` at a location nested under an existing regular file, so directory creation fails and the new condition fires. Ran `InMemoryCatalogSuite` and `SparkThrowableSuite` locally; both pass.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #58219 from dkling-it/name-legacy-error-2033.
Authored-by: Dieter Kling <42...@users.noreply.github.com>
Signed-off-by: Uros Bojanic <22...@users.noreply.github.com>
(cherry picked from commit 9a18c2fabc6ede61e56176ca7b56b4e2a20391dc)
Signed-off-by: Uros Bojanic <22...@users.noreply.github.com>
---
.../src/main/resources/error/error-conditions.json | 11 +++++-----
.../spark/sql/errors/QueryExecutionErrors.scala | 2 +-
.../catalyst/catalog/InMemoryCatalogSuite.scala | 25 ++++++++++++++++++++++
3 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/common/utils/src/main/resources/error/error-conditions.json b/common/utils/src/main/resources/error/error-conditions.json
index 7b44f12a32d9..2f71709cd7ae 100644
--- a/common/utils/src/main/resources/error/error-conditions.json
+++ b/common/utils/src/main/resources/error/error-conditions.json
@@ -8341,6 +8341,12 @@
],
"sqlState" : "42K0G"
},
+ "UNABLE_TO_CREATE_DATABASE_DIRECTORY" : {
+ "message" : [
+ "Unable to create database <name> as failed to create its directory <locationUri>."
+ ],
+ "sqlState" : "58030"
+ },
"UNABLE_TO_FETCH_HIVE_TABLES" : {
"message" : [
"Unable to fetch tables of Hive database: <dbName>."
@@ -10920,11 +10926,6 @@
"<fieldCannotBeNullMsg>"
]
},
- "_LEGACY_ERROR_TEMP_2033" : {
- "message" : [
- "Unable to create database <name> as failed to create its directory <locationUri>."
- ]
- },
"_LEGACY_ERROR_TEMP_2034" : {
"message" : [
"Unable to drop database <name> as failed to delete its directory <locationUri>."
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 9dc85dcca1eb..b1eb94fb30d1 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
@@ -582,7 +582,7 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase with ExecutionE
def unableToCreateDatabaseAsFailedToCreateDirectoryError(
dbDefinition: CatalogDatabase, e: IOException): Throwable = {
new SparkException(
- errorClass = "_LEGACY_ERROR_TEMP_2033",
+ errorClass = "UNABLE_TO_CREATE_DATABASE_DIRECTORY",
messageParameters = Map(
"name" -> dbDefinition.name,
"locationUri" -> dbDefinition.locationUri.toString()),
diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalogSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalogSuite.scala
index eb3fc006b2b7..42eff6c95cd9 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalogSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalogSuite.scala
@@ -17,6 +17,10 @@
package org.apache.spark.sql.catalyst.catalog
+import java.io.File
+import java.nio.file.Files
+
+import org.apache.spark.SparkException
/** Test suite for the [[InMemoryCatalog]]. */
class InMemoryCatalogSuite extends ExternalCatalogSuite {
@@ -28,4 +32,25 @@ class InMemoryCatalogSuite extends ExternalCatalogSuite {
override def newEmptyCatalog(): ExternalCatalog = new InMemoryCatalog
}
+ test("createDatabase throws UNABLE_TO_CREATE_DATABASE_DIRECTORY when mkdirs fails") {
+ withTempDir { parentFile =>
+ // A path nested under an existing regular file: the filesystem cannot create it as a
+ // directory, so `fs.mkdirs` throws an IOException.
+ val blockingFile = new File(parentFile, "not-a-directory")
+ Files.createFile(blockingFile.toPath)
+ val dbLocation = new File(blockingFile, "db_dir").toURI
+
+ val catalog = new InMemoryCatalog
+ val db = CatalogDatabase("unreachable_db", "db", dbLocation, Map.empty)
+ checkError(
+ exception = intercept[SparkException] {
+ catalog.createDatabase(db, ignoreIfExists = false)
+ },
+ condition = "UNABLE_TO_CREATE_DATABASE_DIRECTORY",
+ parameters = Map(
+ "name" -> "unreachable_db",
+ "locationUri" -> dbLocation.toString))
+ }
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org