This is an automated email from the ASF dual-hosted git repository.
pan3793 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 af68ad78ae82 [SPARK-58349][SQL] Assign a name to the error condition
_LEGACY_ERROR_TEMP_1081
af68ad78ae82 is described below
commit af68ad78ae82d81a30d2e717ddf6767d754febd4
Author: Xiao Li <[email protected]>
AuthorDate: Thu Aug 13 16:52:42 2026 +0800
[SPARK-58349][SQL] Assign a name to the error condition
_LEGACY_ERROR_TEMP_1081
### What changes were proposed in this pull request?
Assign the name `TABLE_LOCATION_URI_NOT_SPECIFIED` to the legacy error
condition
`_LEGACY_ERROR_TEMP_1081`. This error is raised by
`QueryCompilationErrors.tableNotSpecifyLocationUriError`, called from
`CatalogTable.location`, when a table's storage `locationUri` is absent.
The new
condition is given SQLSTATE `42601`; the message text and the `identifier`
parameter are unchanged.
### Why are the changes needed?
The error conditions
[README](https://github.com/apache/spark/blob/master/common/utils/src/main/resources/error/README.md)
disallows new `_LEGACY_ERROR_TEMP_*` entries and asks existing ones to be
assigned
proper names. This resolves one of them, under the umbrella
[SPARK-37935](https://issues.apache.org/jira/browse/SPARK-37935).
### Does this PR introduce _any_ user-facing change?
No. The `_LEGACY_ERROR_TEMP_*` names are not part of the public API. The
error
condition name changes to `TABLE_LOCATION_URI_NOT_SPECIFIED` and now reports
SQLSTATE `42601`; the rendered message ("Table `<identifier>` did not
specify
locationUri.") is unchanged.
### How was this patch tested?
Added a `checkError` test in `QueryCompilationErrorsSuite` that constructs a
`CatalogTable` with empty storage and asserts the
`TABLE_LOCATION_URI_NOT_SPECIFIED`
condition when `location` is accessed. `SparkThrowableSuite` validates
error-file
formatting/sorting and that non-legacy conditions carry a SQLSTATE.
### Was this patch authored or co-authored using generative AI tooling?
Yes.
Closes #57537 from gatorsmile/SPARK-58349-table-location-uri.
Authored-by: Xiao Li <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
(cherry picked from commit 449efe6fc2d029463d87da541394906d5335bcfe)
Signed-off-by: Cheng Pan <[email protected]>
---
.../src/main/resources/error/error-conditions.json | 11 ++++++-----
.../spark/sql/errors/QueryCompilationErrors.scala | 2 +-
.../spark/sql/errors/QueryCompilationErrorsSuite.scala | 18 ++++++++++++++++++
3 files changed, 25 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 fe811d4abe59..6c0eceb00055 100644
--- a/common/utils/src/main/resources/error/error-conditions.json
+++ b/common/utils/src/main/resources/error/error-conditions.json
@@ -7914,6 +7914,12 @@
},
"sqlState" : "42601"
},
+ "TABLE_LOCATION_URI_NOT_SPECIFIED" : {
+ "message" : [
+ "Table <identifier> did not specify locationUri."
+ ],
+ "sqlState" : "42601"
+ },
"TABLE_OR_VIEW_ALREADY_EXISTS" : {
"message" : [
"Cannot create table or view <relationName> because it already exists.",
@@ -10041,11 +10047,6 @@
"Table <identifier> did not specify database."
]
},
- "_LEGACY_ERROR_TEMP_1081" : {
- "message" : [
- "Table <identifier> did not specify locationUri."
- ]
- },
"_LEGACY_ERROR_TEMP_1082" : {
"message" : [
"Partition [<specString>] did not specify locationUri."
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 b618399388e6..13006cebc97d 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
@@ -1459,7 +1459,7 @@ private[sql] object QueryCompilationErrors extends
QueryErrorsBase with Compilat
def tableNotSpecifyLocationUriError(identifier: TableIdentifier): Throwable
= {
new AnalysisException(
- errorClass = "_LEGACY_ERROR_TEMP_1081",
+ errorClass = "TABLE_LOCATION_URI_NOT_SPECIFIED",
messageParameters = Map("identifier" -> identifier.toString))
}
diff --git
a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala
b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala
index ce2f7c232a96..7ec699353e68 100644
---
a/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala
+++
b/sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala
@@ -22,6 +22,8 @@ import java.util.IllegalFormatException
import org.apache.spark.{SPARK_DOC_ROOT, SparkIllegalArgumentException,
SparkUnsupportedOperationException}
import org.apache.spark.sql._
import org.apache.spark.sql.api.java.{UDF1, UDF2, UDF23Test}
+import org.apache.spark.sql.catalyst.TableIdentifier
+import org.apache.spark.sql.catalyst.catalog.{CatalogStorageFormat,
CatalogTable, CatalogTableType}
import org.apache.spark.sql.catalyst.expressions.{Coalesce, Literal, UnsafeRow}
import org.apache.spark.sql.catalyst.parser.ParseException
import org.apache.spark.sql.execution.datasources.SaveIntoDataSourceCommand
@@ -1133,6 +1135,22 @@ class QueryCompilationErrorsSuite
parameters = Map("database" -> s"`$globalTempDB`")
)
}
+
+ test("SPARK-58349: TABLE_LOCATION_URI_NOT_SPECIFIED: table does not specify
locationUri") {
+ val identifier = TableIdentifier("t", Some("db"))
+ val table = CatalogTable(
+ identifier = identifier,
+ tableType = CatalogTableType.MANAGED,
+ storage = CatalogStorageFormat.empty,
+ schema = new StructType())
+ checkError(
+ exception = intercept[AnalysisException] {
+ table.location
+ },
+ condition = "TABLE_LOCATION_URI_NOT_SPECIFIED",
+ parameters = Map("identifier" -> identifier.toString)
+ )
+ }
}
class MyCastToString extends SparkUserDefinedFunction(
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]