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

MaxGekk 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 7d81978f55b7 [SPARK-58098][SQL] Convert _LEGACY_ERROR_TEMP_0033 to an 
internal error
7d81978f55b7 is described below

commit 7d81978f55b7b96f7e2bf6a1d61564803aae23bc
Author: YangJie <[email protected]>
AuthorDate: Mon Jul 13 22:08:16 2026 +0200

    [SPARK-58098][SQL] Convert _LEGACY_ERROR_TEMP_0033 to an internal error
    
    ### What changes were proposed in this pull request?
    
    Convert the legacy error condition `_LEGACY_ERROR_TEMP_0033` to a 
`SparkException.internalError` and remove it from `error-conditions.json`.
    
    ### 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 of them.
    
    The condition is raised in `AstBuilder.visitCreateFileFormat`, in the 
branch where both `STORED AS` and `STORED BY` are present. That branch is not 
reachable from normal parsing:
    
    - The grammar rule `createFileFormat` is `STORED AS fileFormat | STORED BY 
storageHandler`, so one clause carries only one of the two.
    - Two clauses (`STORED AS ... STORED BY ...`) are rejected earlier by 
`checkDuplicateClauses` as `DUPLICATE_CLAUSES`.
    
    As it only signals an internal inconsistency, it does not need a 
user-facing error condition and is converted to an internal error, following 
precedents such as SPARK-42839.
    
    One trade-off: `SparkException.internalError` has no overload that carries 
the parser context, so the `ParseException` position information (offending 
fragment, line/column) is no longer attached. This is acceptable here because 
the branch is unreachable from user queries.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No. The code path is unreachable from user queries, so the change is not 
observable in practice.
    
    ### How was this patch tested?
    
    `build/sbt "core/testOnly org.apache.spark.SparkThrowableSuite"` passes, 
covering the JSON validation gates (alphabetical ordering, mandatory SQLSTATE, 
round-trip). No test is added because the path is unreachable.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Code (Opus 4.8)
    
    Closes #57218 from LuciferYang/assign-name-legacy-0033.
    
    Authored-by: YangJie <[email protected]>
    Signed-off-by: Max Gekk <[email protected]>
    (cherry picked from commit e33ac2188dea66d6253baef98528bac5453f00c9)
    Signed-off-by: Max Gekk <[email protected]>
---
 common/utils/src/main/resources/error/error-conditions.json          | 5 -----
 .../main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala  | 4 ++--
 .../main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala | 2 +-
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/common/utils/src/main/resources/error/error-conditions.json 
b/common/utils/src/main/resources/error/error-conditions.json
index 079507803bd6..e375724f64d3 100644
--- a/common/utils/src/main/resources/error/error-conditions.json
+++ b/common/utils/src/main/resources/error/error-conditions.json
@@ -9372,11 +9372,6 @@
       "Duplicated table paths found: '<pathOne>' and '<pathTwo>'. LOCATION and 
the case insensitive key 'path' in OPTIONS are all used to indicate the custom 
table path, you can only specify one of them."
     ]
   },
-  "_LEGACY_ERROR_TEMP_0033" : {
-    "message" : [
-      "Expected either STORED AS or STORED BY, not both."
-    ]
-  },
   "_LEGACY_ERROR_TEMP_0034" : {
     "message" : [
       "<operation> is not supported in Hive-style <command><msg>."
diff --git 
a/sql/api/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala 
b/sql/api/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala
index f73b0457f87f..cd3cc63bda17 100644
--- 
a/sql/api/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala
+++ 
b/sql/api/src/main/scala/org/apache/spark/sql/errors/QueryParsingErrors.scala
@@ -550,8 +550,8 @@ private[sql] object QueryParsingErrors extends 
DataTypeErrorsBase {
       ctx)
   }
 
-  def storedAsAndStoredByBothSpecifiedError(ctx: CreateFileFormatContext): 
Throwable = {
-    new ParseException(errorClass = "_LEGACY_ERROR_TEMP_0033", ctx)
+  def storedAsAndStoredByBothSpecifiedError(): Throwable = {
+    SparkException.internalError("Expected either STORED AS or STORED BY, not 
both.")
   }
 
   def operationInHiveStyleCommandUnsupportedError(
diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
index ad798d06e621..0b28afb281c8 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
@@ -5594,7 +5594,7 @@ class AstBuilder extends DataTypeAstBuilder
       case (null, storageHandler) =>
         invalidStatement("STORED BY", ctx)
       case _ =>
-        throw QueryParsingErrors.storedAsAndStoredByBothSpecifiedError(ctx)
+        throw QueryParsingErrors.storedAsAndStoredByBothSpecifiedError()
     }
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to