You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ch...@apache.org on 2026/08/13 09:00:52 UTC

(spark) branch master updated: [SPARK-58351][CORE] Assign a name to the error condition _LEGACY_ERROR_TEMP_3014

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

pan3793 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 d8797af6cd74 [SPARK-58351][CORE] Assign a name to the error condition _LEGACY_ERROR_TEMP_3014
d8797af6cd74 is described below

commit d8797af6cd7436f870eb10d96b5b3ca33f01e8d3
Author: Xiao Li <li...@databricks.com>
AuthorDate: Thu Aug 13 17:00:35 2026 +0800

    [SPARK-58351][CORE] Assign a name to the error condition _LEGACY_ERROR_TEMP_3014
    
    ### What changes were proposed in this pull request?
    
    Assign the name `EMPTY_COLLECTION_NOT_ALLOWED` to the legacy error condition
    `_LEGACY_ERROR_TEMP_3014`. This error is a `SparkUnsupportedOperationException`
    raised by `SparkCoreErrors.emptyCollectionError`, thrown by RDD reduce/first-style
    operations on an empty RDD (`RDD.scala`). The new condition is given SQLSTATE
    `0A000`; the message text ("empty collection") and its parameterless shape 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 `EMPTY_COLLECTION_NOT_ALLOWED` and now reports SQLSTATE
    `0A000`; the underlying message text ("empty collection") is unchanged.
    
    ### How was this patch tested?
    
    Updated the "empty RDD" test in `RDDSuite` from a `getMessage.contains` assertion to
    `checkError` on the `EMPTY_COLLECTION_NOT_ALLOWED` condition. Other RDD tests that hit
    this path assert only the exception type (`UnsupportedOperationException`), which still
    holds since `SparkUnsupportedOperationException` extends it. `SparkThrowableSuite`
    validates SQLSTATE presence and error-file formatting/sorting for the new entry.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Yes
    
    Closes #57539 from gatorsmile/SPARK-58351-empty-collection.
    
    Authored-by: Xiao Li <li...@databricks.com>
    Signed-off-by: Cheng Pan <ch...@apache.org>
---
 common/utils/src/main/resources/error/error-conditions.json   | 11 ++++++-----
 .../main/scala/org/apache/spark/errors/SparkCoreErrors.scala  |  2 +-
 core/src/test/scala/org/apache/spark/rdd/RDDSuite.scala       | 10 ++++++----
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/common/utils/src/main/resources/error/error-conditions.json b/common/utils/src/main/resources/error/error-conditions.json
index 21d06132ca66..dc5631bdbdb1 100644
--- a/common/utils/src/main/resources/error/error-conditions.json
+++ b/common/utils/src/main/resources/error/error-conditions.json
@@ -2491,6 +2491,12 @@
     ],
     "sqlState" : "42815"
   },
+  "EMPTY_COLLECTION_NOT_ALLOWED" : {
+    "message" : [
+      "empty collection"
+    ],
+    "sqlState" : "0A000"
+  },
   "EMPTY_JSON_FIELD_VALUE" : {
     "message" : [
       "Failed to parse an empty string for data type <dataType>."
@@ -11516,11 +11522,6 @@
       "Can only zip RDDs with same number of elements in each partition"
     ]
   },
-  "_LEGACY_ERROR_TEMP_3014" : {
-    "message" : [
-      "empty collection"
-    ]
-  },
   "_LEGACY_ERROR_TEMP_3015" : {
     "message" : [
       "countByValueApprox() does not support arrays"
diff --git a/core/src/main/scala/org/apache/spark/errors/SparkCoreErrors.scala b/core/src/main/scala/org/apache/spark/errors/SparkCoreErrors.scala
index 95a1f44ef090..cf931707c89e 100644
--- a/core/src/main/scala/org/apache/spark/errors/SparkCoreErrors.scala
+++ b/core/src/main/scala/org/apache/spark/errors/SparkCoreErrors.scala
@@ -146,7 +146,7 @@ private[spark] object SparkCoreErrors {
   }
 
   def emptyCollectionError(): Throwable = {
-    new SparkUnsupportedOperationException("_LEGACY_ERROR_TEMP_3014")
+    new SparkUnsupportedOperationException("EMPTY_COLLECTION_NOT_ALLOWED")
   }
 
   def countByValueApproxNotSupportArraysError(): Throwable = {
diff --git a/core/src/test/scala/org/apache/spark/rdd/RDDSuite.scala b/core/src/test/scala/org/apache/spark/rdd/RDDSuite.scala
index 3c295aecf274..5ef10b6d7e2e 100644
--- a/core/src/test/scala/org/apache/spark/rdd/RDDSuite.scala
+++ b/core/src/test/scala/org/apache/spark/rdd/RDDSuite.scala
@@ -325,10 +325,12 @@ class RDDSuite extends SparkFunSuite with SharedSparkContext with Eventually {
     assert(empty.count() === 0)
     assert(empty.collect().length === 0)
 
-    val thrown = intercept[UnsupportedOperationException]{
-      empty.reduce(_ + _)
-    }
-    assert(thrown.getMessage.contains("empty"))
+    checkError(
+      exception = intercept[SparkUnsupportedOperationException] {
+        empty.reduce(_ + _)
+      },
+      condition = "EMPTY_COLLECTION_NOT_ALLOWED",
+      parameters = Map.empty[String, String])
 
     val emptyKv = new EmptyRDD[(Int, Int)](sc)
     val rdd = sc.parallelize(1 to 2, 2).map(x => (x, x))


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org