Skip to content

Commit 34ac927

Browse files
mikhailnik-dbcloud-fan
authored andcommitted
[SPARK-55865][SQL] Rename _LEGACY_ERROR_TEMP_1266 to CANNOT_TRUNCATE_EXTERNAL_TABLE
### What changes were proposed in this pull request? Rename the legacy error condition `_LEGACY_ERROR_TEMP_1266` to a proper error class `CANNOT_TRUNCATE_EXTERNAL_TABLE` with SQL state `0A000` (feature not supported). Also renames the message parameter from `tableIdentWithDB` to `tableName` for consistency. ### Why are the changes needed? `_LEGACY_ERROR_TEMP_1266` is a legacy placeholder error name. It should be replaced with a descriptive error class name and assigned a proper SQL state to improve error reporting and comply with the ANSI SQL standard. ### Does this PR introduce _any_ user-facing change? Yes. The error condition name changes from `_LEGACY_ERROR_TEMP_1266` to `CANNOT_TRUNCATE_EXTERNAL_TABLE` and now includes SQL state `0A000`. The error message itself remains unchanged. ### How was this patch tested? Existing tests (including `TruncateTableSuite`). ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code 2.1.70 Closes #54661 from mikhailnik-db/cannot-truncate-external-table. Authored-by: Mikhail Nikoliukin <mikhail.nikoliukin@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
1 parent 66af041 commit 34ac927

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

common/utils/src/main/resources/error/error-conditions.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,12 @@
547547
],
548548
"sqlState" : "58030"
549549
},
550+
"CANNOT_TRUNCATE_EXTERNAL_TABLE" : {
551+
"message" : [
552+
"Operation not allowed: TRUNCATE TABLE on external tables: <tableName>."
553+
],
554+
"sqlState" : "0A000"
555+
},
550556
"CANNOT_UPDATE_FIELD" : {
551557
"message" : [
552558
"Cannot update <table> field <fieldName> type:"
@@ -9154,11 +9160,6 @@
91549160
"LOAD DATA target table <tableIdentWithDB> is not partitioned, but a partition spec was provided."
91559161
]
91569162
},
9157-
"_LEGACY_ERROR_TEMP_1266" : {
9158-
"message" : [
9159-
"Operation not allowed: TRUNCATE TABLE on external tables: <tableIdentWithDB>."
9160-
]
9161-
},
91629163
"_LEGACY_ERROR_TEMP_1267" : {
91639164
"message" : [
91649165
"Operation not allowed: TRUNCATE TABLE ... PARTITION is not supported for tables that are not partitioned: <tableIdentWithDB>."

sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3175,8 +3175,8 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat
31753175

31763176
def truncateTableOnExternalTablesError(tableIdentWithDB: String): Throwable = {
31773177
new AnalysisException(
3178-
errorClass = "_LEGACY_ERROR_TEMP_1266",
3179-
messageParameters = Map("tableIdentWithDB" -> tableIdentWithDB))
3178+
errorClass = "CANNOT_TRUNCATE_EXTERNAL_TABLE",
3179+
messageParameters = Map("tableName" -> tableIdentWithDB))
31803180
}
31813181

31823182
def truncateTablePartitionNotSupportedForNotPartitionedTablesError(

sql/core/src/test/scala/org/apache/spark/sql/execution/command/v1/TruncateTableSuite.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ class TruncateTableSuite extends TruncateTableSuiteBase with CommandSuiteBase {
201201
exception = intercept[AnalysisException] {
202202
sql(s"TRUNCATE TABLE $t")
203203
},
204-
condition = "_LEGACY_ERROR_TEMP_1266",
205-
parameters = Map("tableIdentWithDB" -> "`spark_catalog`.`ns`.`tbl`")
204+
condition = "CANNOT_TRUNCATE_EXTERNAL_TABLE",
205+
parameters = Map("tableName" -> "`spark_catalog`.`ns`.`tbl`")
206206
)
207207
}
208208
}

0 commit comments

Comments
 (0)