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

LuciferYang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 8a18d2831baa [SPARK-58121][SQL] Assign a name to the error condition 
_LEGACY_ERROR_TEMP_0012
8a18d2831baa is described below

commit 8a18d2831baa8ff687cbe44ef885e0dd1f223519
Author: YangJie <[email protected]>
AuthorDate: Wed Jul 15 16:14:08 2026 +0800

    [SPARK-58121][SQL] Assign a name to the error condition 
_LEGACY_ERROR_TEMP_0012
    
    ### What changes were proposed in this pull request?
    
    Convert the legacy error condition `_LEGACY_ERROR_TEMP_0012` ("DISTRIBUTE 
BY is not supported.") into the `UNSUPPORTED_FEATURE.DISTRIBUTE_BY` subclass 
(SQLSTATE `0A000`, inherited from the `UNSUPPORTED_FEATURE` umbrella).
    
    ### 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 error is raised by the base `AstBuilder`, which does not support 
`DISTRIBUTE BY`; `SparkSqlAstBuilder` overrides `withRepartitionByExpression` 
to support it, so only parsers built on the base `AstBuilder` (via 
`CatalystSqlParser`) reject the clause. This is the same 
`withQueryResultClauses` code path whose combination case already reports 
`UNSUPPORTED_FEATURE.COMBINATION_QUERY_RESULT_CLAUSES`, so a `DISTRIBUTE_BY` 
subclass under the same umbrella keeps the parser feature-not-suppo [...]
    
    ### Does this PR introduce _any_ user-facing change?
    
    No. Only the error condition name is assigned; the `_LEGACY_ERROR_TEMP_*` 
names are not part of the public API. The rendered message becomes "The feature 
is not supported: DISTRIBUTE BY clause."
    
    ### How was this patch tested?
    
    Added a `checkError` test in `PlanParserSuite` (which uses 
`CatalystSqlParser`) that parses `select * from t distribute by a` and asserts 
the `UNSUPPORTED_FEATURE.DISTRIBUTE_BY` condition. `build/sbt 
"catalyst/testOnly *PlanParserSuite" "core/testOnly 
org.apache.spark.SparkThrowableSuite"` passes.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Code (Opus 4.8)
    
    Closes #57249 from LuciferYang/assign-name-legacy-0012.
    
    Authored-by: YangJie <[email protected]>
    Signed-off-by: yangjie01 <[email protected]>
---
 common/utils/src/main/resources/error/error-conditions.json  | 10 +++++-----
 .../org/apache/spark/sql/errors/QueryParsingErrors.scala     |  2 +-
 .../apache/spark/sql/catalyst/parser/PlanParserSuite.scala   | 12 ++++++++++++
 3 files changed, 18 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 6adcf5d23cb7..a6150f5e9500 100644
--- a/common/utils/src/main/resources/error/error-conditions.json
+++ b/common/utils/src/main/resources/error/error-conditions.json
@@ -8331,6 +8331,11 @@
           "DESC TABLE COLUMN for a specific partition."
         ]
       },
+      "DISTRIBUTE_BY" : {
+        "message" : [
+          "DISTRIBUTE BY clause."
+        ]
+      },
       "DROP_DATABASE" : {
         "message" : [
           "Drop the default database <database>."
@@ -9348,11 +9353,6 @@
       "Empty source for merge: you should specify a source table/subquery in 
merge."
     ]
   },
-  "_LEGACY_ERROR_TEMP_0012" : {
-    "message" : [
-      "DISTRIBUTE BY is not supported."
-    ]
-  },
   "_LEGACY_ERROR_TEMP_0014" : {
     "message" : [
       "TABLESAMPLE does not accept empty inputs."
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 cd3cc63bda17..9c7eaadedd78 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
@@ -161,7 +161,7 @@ private[sql] object QueryParsingErrors extends 
DataTypeErrorsBase {
   }
 
   def distributeByUnsupportedError(ctx: QueryOrganizationContext): Throwable = 
{
-    new ParseException(errorClass = "_LEGACY_ERROR_TEMP_0012", ctx)
+    new ParseException(errorClass = "UNSUPPORTED_FEATURE.DISTRIBUTE_BY", ctx)
   }
 
   def transformNotSupportQuantifierError(ctx: ParserRuleContext): Throwable = {
diff --git 
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala
 
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala
index e9f1a94f7010..6e5239b3d206 100644
--- 
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala
+++ 
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/PlanParserSuite.scala
@@ -437,6 +437,18 @@ class PlanParserSuite extends AnalysisTest {
         stop = 41))
   }
 
+  test("DISTRIBUTE BY is not supported in the Catalyst parser") {
+    val sql = "select * from t distribute by a"
+    checkError(
+      exception = parseException(sql),
+      condition = "UNSUPPORTED_FEATURE.DISTRIBUTE_BY",
+      parameters = Map.empty,
+      context = ExpectedContext(
+        fragment = "distribute by a",
+        start = 16,
+        stop = 30))
+  }
+
   test("insert into") {
     import org.apache.spark.sql.catalyst.dsl.expressions._
     import org.apache.spark.sql.catalyst.dsl.plans._


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

Reply via email to