From e89cca0158cc14a6ee0a1ed7904a808148a4513e Mon Sep 17 00:00:00 2001 From: Pedrum Jalali Date: Wed, 11 Nov 2026 12:20:25 -0800 Subject: [PATCH 1/4] [GLUTEN-11912][VL] Translate Velox char/varchar length errors to Spark's exception MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What changes are proposed in this pull request? Spark fails an insert of a char or varchar value that is longer than its declared length with [EXCEED_LIMIT_LENGTH](https://github.com/apache/spark/blob/v3.5.5/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/CharVarcharCodegenUtils.java#L31), while the Velox backend failed it with a [GlutenException](https://github.com/apache/gluten/blob/31fb4dad58e7339ac4f4b820931d648160dc4746/gluten-core/src/main/java/org/apache/gluten/exception/GlutenException.java) carrying Velox's own message ([CharVarcharUtils.cpp](https://github.com/IBM/velox/blob/6deac80271569277bf54b6d04547620c17438348/velox/functions/sparksql/CharVarcharUtils.cpp#L37-L38)). With this change, the Velox backend fails with Spark's exception. | Inserted value | Spark 3.5.5 without Gluten | Gluten before this change | Gluten after this change | |---|---|---|---| | `'12345'` into `VARCHAR(5)` | Inserted | Inserted | Inserted | | `'123456'` into `VARCHAR(5)` | `EXCEED_LIMIT_LENGTH` | `GlutenException` | `EXCEED_LIMIT_LENGTH` | | `'123456'` into `CHAR(5)` | `EXCEED_LIMIT_LENGTH` | `GlutenException` | `EXCEED_LIMIT_LENGTH` | [apache/gluten#9107](https://github.com/apache/gluten/pull/9107) moved Spark's char/varchar length check into Velox; before it, Spark ran the check and threw its own exception. Since then, Spark's tests for this error have been excluded, replaced with Gluten copies that look for Velox's text, or checked with an assertion that also accepts Velox's text, so CI did not catch the different exception. With this change, those tests run again on Spark 4.0, 4.1 and 4.2, and all but two of them run again on Spark 3.4 and 3.5. Code that matches on the EXCEED_LIMIT_LENGTH condition now gets it under Gluten, as it does in Spark. [length check for input string values: partitioned columns](https://github.com/apache/spark/blob/v3.5.5/sql/core/src/test/scala/org/apache/spark/sql/CharVarcharTestSuite.scala#L332-L349) and [char/varchar type values length check: partitioned columns of other types](https://github.com/apache/spark/blob/v3.5.5/sql/core/src/test/scala/org/apache/spark/sql/CharVarcharTestSuite.scala#L1037-L1066) stay excluded on Spark 3.4 and 3.5. Spark expects the error of these partitioned inserts wrapped in [TASK_WRITE_FAILED](https://github.com/apache/spark/blob/v3.5.5/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileFormatWriter.scala#L419-L420), and Gluten throws it unwrapped. The Gluten copies of these two tests now check for Spark's exception instead of Velox's text. On Spark 3.4, which has no error class for this, Gluten throws the [plain RuntimeException](https://github.com/apache/spark/blob/v3.4.4/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/util/CharVarcharCodegenUtils.java#L30) that Spark 3.4 throws. Part of apache/gluten#11912 ## How was this patch tested? ### Reproduction 1. Clone the repo and check out the base commit: ```bash git clone https://github.com/apache/gluten.git cd gluten git checkout 31fb4dad58e7339ac4f4b820931d648160dc4746 ``` 2. Build the native libraries and the bundle jar: ```bash docker run --rm -v "$PWD":/work/gluten:z apache/gluten:centos-9-jdk8 bash -c ' source /opt/rh/gcc-toolset-12/enable export VELOX_BUILD_SHARED=ON cd /work/gluten ./dev/builddeps-veloxbe.sh --run_setup_script=OFF --build_arrow=OFF ./build/mvn clean install -Pbackends-velox -Pspark-3.5 -DskipTests ' ``` 3. Fetch Spark 3.5.5: ```bash curl -sSL https://archive.apache.org/dist/spark/spark-3.5.5/spark-3.5.5-bin-hadoop3.tgz | tar -xz ``` 4. Write three queries that insert from a Parquet table: ```bash cat > fits.sql <<'EOF' DROP TABLE IF EXISTS src; DROP TABLE IF EXISTS t; CREATE TABLE src USING parquet AS SELECT '12345' AS s; CREATE TABLE t (c VARCHAR(5)) USING parquet; INSERT INTO t SELECT s FROM src; SELECT c FROM t; EOF cat > varchar.sql <<'EOF' DROP TABLE IF EXISTS src; DROP TABLE IF EXISTS t; CREATE TABLE src USING parquet AS SELECT '123456' AS s; CREATE TABLE t (c VARCHAR(5)) USING parquet; INSERT INTO t SELECT s FROM src; EOF cat > char.sql <<'EOF' DROP TABLE IF EXISTS src; DROP TABLE IF EXISTS t; CREATE TABLE src USING parquet AS SELECT '123456' AS s; CREATE TABLE t (c CHAR(5)) USING parquet; INSERT INTO t SELECT s FROM src; EOF ``` 5. Run each query with Gluten, and print the exception it fails with and Velox's reason, if any: ```bash docker run --rm -v "$PWD":/work/gluten:z apache/gluten:centos-9-jdk8 bash -c ' cd /work/gluten BUNDLE=$(ls package/target/gluten-velox-bundle-spark3.5_2.12-linux_amd64-*.jar) for q in fits.sql varchar.sql char.sql; do spark-3.5.5-bin-hadoop3/bin/spark-sql --master "local[2]" \ --jars "$BUNDLE" --driver-class-path "$BUNDLE" \ --conf spark.plugins=org.apache.gluten.GlutenPlugin \ --conf spark.memory.offHeap.enabled=true \ --conf spark.memory.offHeap.size=4g \ --conf spark.shuffle.manager=org.apache.spark.shuffle.sort.ColumnarShuffleManager \ -f "$q" 2>err.log grep -m 1 "Job aborted" err.log | sed "s/.*executor driver): //" grep -m 1 "^Reason:" err.log done ' ``` On the base commit, both too-long values fail with a `GlutenException` that wraps Velox's error: ``` 12345 org.apache.gluten.exception.GlutenException: org.apache.gluten.exception.GlutenException: Exception: VeloxUserError Reason: (6 vs. 5) Exceeds allowed length limitation: 5 org.apache.gluten.exception.GlutenException: org.apache.gluten.exception.GlutenException: Exception: VeloxUserError Reason: (6 vs. 5) Exceeds allowed length limitation: 5 ``` On this pull request's branch, rerunning steps 2 and 5 gives Spark's exception, with Velox's error kept as its cause: ``` 12345 org.apache.spark.SparkRuntimeException: [EXCEED_LIMIT_LENGTH] Exceeds char/varchar type length limitation: 5. Reason: (6 vs. 5) Exceeds allowed length limitation: 5 org.apache.spark.SparkRuntimeException: [EXCEED_LIMIT_LENGTH] Exceeds char/varchar type length limitation: 5. Reason: (6 vs. 5) Exceeds allowed length limitation: 5 ``` Spark without Gluten, which is step 5's `spark-sql` command keeping only `--master`, wraps the same exception in `TASK_WRITE_FAILED`: ``` 12345 org.apache.spark.SparkException: [TASK_WRITE_FAILED] Task failed while writing rows to file:/work/gluten/spark-warehouse/t. org.apache.spark.SparkException: [TASK_WRITE_FAILED] Task failed while writing rows to file:/work/gluten/spark-warehouse/t. ``` ```bash grep -m 1 "^Caused by: org.apache.spark.SparkRuntimeException" err.log ``` ``` Caused by: org.apache.spark.SparkRuntimeException: [EXCEED_LIMIT_LENGTH] Exceeds char/varchar type length limitation: 5. ``` ### Automated tests Inside the `apache/gluten:centos-9-jdk8` image, the char/varchar suites pass on Spark 3.5: ```bash ./build/mvn -B clean install -Pbackends-velox -Pspark-3.5 -Pspark-ut -DskipTests -Dspotless.check.skip=true -Dscalastyle.skip=true -Dcheckstyle.skip=true ./build/mvn -B test -Pbackends-velox -Pspark-3.5 -Pspark-ut -pl gluten-ut/spark35 -DargLine="-Dspark.test.home=/opt/shims/spark35/spark_home/" -Dtest=none -DfailIfNoTests=false -DwildcardSuites=org.apache.spark.sql.GlutenFileSourceCharVarcharTestSuite,org.apache.spark.sql.GlutenDSV2CharVarcharTestSuite -Dspotless.check.skip=true -Dscalastyle.skip=true -Dcheckstyle.skip=true ``` ``` GlutenFileSourceCharVarcharTestSuite: … - length check for input string values: nested in map key … - Gluten - length check for input string values: partitioned columns - Gluten - char/varchar type values length check: partitioned columns of other types … Tests: succeeded 101, failed 0, canceled 0, ignored 2, pending 0 All tests passed. ``` On Spark 3.4, with the same two commands using `-Pspark-3.4`, `gluten-ut/spark34` and `/opt/shims/spark34/spark_home/`: ``` GlutenFileSourceCharVarcharTestSuite: … - length check for input string values: nested in map key … - Gluten - length check for input string values: partitioned columns - Gluten - char/varchar type values length check: partitioned columns of other types … Tests: succeeded 100, failed 0, canceled 0, ignored 2, pending 0 All tests passed. ``` On Spark 4.0, 4.1 and 4.2, with JDK 17 and `SPARK_ANSI_SQL_MODE=false`, which [Gluten's CI sets](https://github.com/apache/gluten/blob/31fb4dad58e7339ac4f4b820931d648160dc4746/.github/workflows/velox_backend_x86.yml#L65-L66): ```bash ./build/mvn -B clean install -Pbackends-velox -Pspark-4.0 -Pscala-2.13 -Pjava-17 -Pspark-ut -DskipTests -Dspotless.check.skip=true -Dscalastyle.skip=true -Dcheckstyle.skip=true SPARK_ANSI_SQL_MODE=false ./build/mvn -B test -Pbackends-velox -Pspark-4.0 -Pscala-2.13 -Pjava-17 -Pspark-ut -pl gluten-ut/spark40 -DargLine="-Dspark.test.home=/opt/shims/spark40/spark_home/" -Dtest=none -DfailIfNoTests=false -DwildcardSuites=org.apache.spark.sql.GlutenFileSourceCharVarcharTestSuite,org.apache.spark.sql.GlutenDSV2CharVarcharTestSuite -Dspotless.check.skip=true -Dscalastyle.skip=true -Dcheckstyle.skip=true ``` ``` GlutenFileSourceCharVarcharTestSuite: … - length check for input string values: nested in map key … Tests: succeeded 118, failed 0, canceled 1, ignored 0, pending 0 All tests passed. ``` Spark 4.1 runs the same commands with `-Pspark-4.1`, `gluten-ut/spark41` and `/opt/shims/spark41/spark_home/`: ``` Tests: succeeded 118, failed 0, canceled 1, ignored 0, pending 0 All tests passed. ``` Spark 4.2 runs them with `-Pspark-4.2`, `gluten-ut/spark42` and no `-DargLine`, adding [GlutenResolveDefaultColumnsSuite](https://github.com/apache/gluten/blob/31fb4dad58e7339ac4f4b820931d648160dc4746/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/GlutenResolveDefaultColumnsSuite.scala) to `-DwildcardSuites`: ``` GlutenResolveDefaultColumnsSuite: … - SPARK-57187: non-foldable default exceeding CHAR/VARCHAR length fails at INSERT time (explicit DEFAULT keyword) … Tests: succeeded 138, failed 0, canceled 1, ignored 0, pending 0 All tests passed. ``` The canceled test on Spark 4.0, 4.1 and 4.2 is [SPARK-48792: Fix INSERT with partial column list to a table with char/varchar](https://github.com/apache/spark/blob/v4.0.2/sql/core/src/test/scala/org/apache/spark/sql/CharVarcharTestSuite.scala#L687), which Spark cancels itself with an `assume`. ## Was this patch authored or co-authored using generative AI tooling? Generated-by: Co-authored with Claude Code (claude-opus-5-5) --- .../vectorized/ColumnarBatchOutIterator.java | 24 ++ .../utils/velox/VeloxTestSettings.scala | 38 +- .../sql/GlutenCharVarcharTestSuite.scala | 306 +--------------- .../utils/velox/VeloxTestSettings.scala | 36 +- .../sql/GlutenCharVarcharTestSuite.scala | 329 ++---------------- .../sql/GlutenCharVarcharTestSuite.scala | 51 +-- .../sql/GlutenCharVarcharTestSuite.scala | 51 +-- .../utils/velox/VeloxTestSettings.scala | 4 - .../sql/GlutenCharVarcharTestSuite.scala | 51 +-- .../GlutenResolveDefaultColumnsSuite.scala | 20 +- .../apache/gluten/sql/shims/SparkShims.scala | 8 + .../sql/shims/spark35/Spark35Shims.scala | 4 + .../errors/GlutenQueryExecutionErrors.scala | 30 ++ .../sql/shims/spark40/Spark40Shims.scala | 4 + .../errors/GlutenQueryExecutionErrors.scala | 30 ++ .../sql/shims/spark41/Spark41Shims.scala | 4 + .../errors/GlutenQueryExecutionErrors.scala | 30 ++ .../sql/shims/spark42/Spark42Shims.scala | 4 + .../errors/GlutenQueryExecutionErrors.scala | 30 ++ 19 files changed, 202 insertions(+), 852 deletions(-) create mode 100644 shims/spark35/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala create mode 100644 shims/spark40/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala create mode 100644 shims/spark41/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala create mode 100644 shims/spark42/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala diff --git a/gluten-arrow/src/main/java/org/apache/gluten/vectorized/ColumnarBatchOutIterator.java b/gluten-arrow/src/main/java/org/apache/gluten/vectorized/ColumnarBatchOutIterator.java index d2513718411..6410832a77d 100644 --- a/gluten-arrow/src/main/java/org/apache/gluten/vectorized/ColumnarBatchOutIterator.java +++ b/gluten-arrow/src/main/java/org/apache/gluten/vectorized/ColumnarBatchOutIterator.java @@ -21,11 +21,14 @@ import org.apache.gluten.iterator.ClosableIterator; import org.apache.gluten.runtime.Runtime; import org.apache.gluten.runtime.RuntimeAware; +import org.apache.gluten.sql.shims.SparkShimLoader; import org.apache.spark.sql.execution.datasources.SchemaColumnConvertNotSupportedException; import org.apache.spark.sql.vectorized.ColumnarBatch; import java.io.IOException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class ColumnarBatchOutIterator extends ClosableIterator implements RuntimeAware { @@ -132,6 +135,10 @@ public void requestBarrier() { nativeRequestBarrier(iterHandle); } + // Velox's message when a char or varchar value is longer than its declared length. + private static final Pattern CHAR_VARCHAR_LENGTH_EXCEEDED = + Pattern.compile("Exceeds allowed length limitation: (\\d+)"); + /** * Translates a Velox type conversion error into a SchemaColumnConvertNotSupportedException. * Returns null if the message does not indicate a type conversion error. @@ -143,6 +150,19 @@ private static RuntimeException translateToSchemaException(String msg) { return null; } + /** + * Translates a Velox char/varchar length check failure into the exception Spark throws for a + * value longer than its declared length. Returns null if the message does not indicate one. + */ + private static RuntimeException translateToCharVarcharLengthException(String msg, Exception e) { + Matcher matcher = CHAR_VARCHAR_LENGTH_EXCEEDED.matcher(msg); + if (!matcher.find()) { + return null; + } + int limit = Integer.parseInt(matcher.group(1)); + return SparkShimLoader.getSparkShims().charVarcharLengthExceededError(limit, e); + } + @Override protected RuntimeException translateException(Exception e) { String msg = findFirstNonNullMessage(e); @@ -152,6 +172,10 @@ protected RuntimeException translateException(Exception e) { schemaEx.initCause(e); return schemaEx; } + RuntimeException lengthEx = translateToCharVarcharLengthException(msg, e); + if (lengthEx != null) { + return lengthEx; + } } return new GlutenException(e); } diff --git a/gluten-ut/spark34/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala b/gluten-ut/spark34/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala index 104461c2a34..fd976d8dae1 100644 --- a/gluten-ut/spark34/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala +++ b/gluten-ut/spark34/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala @@ -649,45 +649,11 @@ class VeloxTestSettings extends BackendTestSettings { // Rewrite for different cache size. .exclude("SPARK-36120: Support cache/uncache table with TimestampNTZ type") enableSuite[GlutenFileSourceCharVarcharTestSuite] - .exclude("length check for input string values: nested in array") - .exclude("length check for input string values: nested in array") - .exclude("length check for input string values: nested in map key") - .exclude("length check for input string values: nested in map value") - .exclude("length check for input string values: nested in both map key and value") - .exclude("length check for input string values: nested in array of struct") - .exclude("length check for input string values: nested in array of array") - // Following tests are excluded as these are overridden in Gluten test suite.. - // The overridden tests assert against Velox-specific error messages for char/varchar - // length validation, which differ from the original vanilla Spark tests. - .exclude("length check for input string values: top-level columns") + // Spark expects the length error of these partitioned inserts wrapped in TASK_WRITE_FAILED, + // but Gluten throws it unwrapped. Rewritten in GlutenCharVarcharTestSuite. .exclude("length check for input string values: partitioned columns") - .exclude("length check for input string values: nested in struct of array") - .exclude("length check for input string values: with implicit cast") .exclude("char/varchar type values length check: partitioned columns of other types") - enableSuite[GlutenDSV2CharVarcharTestSuite] - // Following tests are excluded as these are overridden in Gluten test suite.. - // The overridden tests assert against Velox-specific error messages for char/varchar - // length validation, which differ from the original vanilla Spark tests. - .exclude("SPARK-42611: check char/varchar length in reordered structs within arrays") - .exclude("char/varchar type values length check: partitioned columns of other types") - .exclude("length check for input string values: top-level columns") - .exclude("length check for input string values: nested in array") - .exclude("length check for input string values: nested in struct of array") - .exclude("length check for input string values: nested in array of struct") - .exclude("length check for input string values: nested in array of array") - .exclude("length check for input string values: with implicit cast") - // Overridden. - .exclude("length check for input string values: nested in map key") - // Overridden. - .exclude("length check for input string values: nested in map value") - // Overridden. - .exclude("length check for input string values: nested in both map key and value") - // Overridden. - .exclude("SPARK-42611: check char/varchar length in reordered structs within map keys") - // Overridden. - .exclude("SPARK-42611: check char/varchar length in reordered structs within map values") - enableSuite[GlutenColumnExpressionSuite] // Velox raise_error('errMsg') throws a velox_user_error exception with the message 'errMsg'. // The final caught Spark exception's getCause().getMessage() contains 'errMsg' but does not diff --git a/gluten-ut/spark34/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala b/gluten-ut/spark34/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala index 5930d7ce7b6..c8a44a9ae8a 100644 --- a/gluten-ut/spark34/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala +++ b/gluten-ut/spark34/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala @@ -29,113 +29,6 @@ class GlutenFileSourceCharVarcharTestSuite private val ERROR_MESSAGE = "Exceeds char/varchar type length limitation: 5" - private val VELOX_ERROR_MESSAGE = - "Exceeds allowed length limitation: 5" - - testGluten("length check for input string values: nested in struct") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c STRUCT) USING $format") - sql("INSERT INTO t SELECT struct(null)") - checkAnswer(spark.table("t"), Row(Row(null))) - val e = intercept[RuntimeException] { - sql("INSERT INTO t SELECT struct('123456')") - } - assert(e.getMessage.contains(ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in array") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c ARRAY<$typeName(5)>) USING $format") - sql("INSERT INTO t VALUES (array(null))") - checkAnswer(spark.table("t"), Row(Seq(null))) - val e = intercept[SparkException] { - sql("INSERT INTO t VALUES (array('a', '123456'))") - } - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in map key") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c MAP<$typeName(5), STRING>) USING $format") - val e = intercept[SparkException](sql("INSERT INTO t VALUES (map('123456', 'a'))")) - // Gluten exception differs from Spark - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in map value") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c MAP) USING $format") - sql("INSERT INTO t VALUES (map('a', null))") - checkAnswer(spark.table("t"), Row(Map("a" -> null))) - val e = intercept[SparkException](sql("INSERT INTO t VALUES (map('a', '123456'))")) - // Gluten exception differs from Spark - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in both map key and value") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c MAP<$typeName(5), $typeName(5)>) USING $format") - val e1 = intercept[SparkException](sql("INSERT INTO t VALUES (map('123456', 'a'))")) - // Gluten exception differs from Spark - assert(e1.getMessage.contains(VELOX_ERROR_MESSAGE)) - val e2 = intercept[SparkException](sql("INSERT INTO t VALUES (map('a', '123456'))")) - // Gluten exception differs from Spark - assert(e2.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in struct of array") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c STRUCT>) USING $format") - sql("INSERT INTO t SELECT struct(array(null))") - checkAnswer(spark.table("t"), Row(Row(Seq(null)))) - val e = intercept[SparkException](sql("INSERT INTO t SELECT struct(array('123456'))")) - assert(e.getCause.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in array of struct") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c ARRAY>) USING $format") - sql("INSERT INTO t VALUES (array(struct(null)))") - checkAnswer(spark.table("t"), Row(Seq(Row(null)))) - val e = intercept[SparkException](sql("INSERT INTO t VALUES (array(struct('123456')))")) - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in array of array") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c ARRAY>) USING $format") - sql("INSERT INTO t VALUES (array(array(null)))") - checkAnswer(spark.table("t"), Row(Seq(Seq(null)))) - val e = intercept[SparkException](sql("INSERT INTO t VALUES (array(array('123456')))")) - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: top-level columns") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c $typeName(5)) USING $format") - sql("INSERT INTO t VALUES (null)") - checkAnswer(spark.table("t"), Row(null)) - val e = intercept[SparkException](sql("INSERT INTO t VALUES ('123456')")) - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } testGluten("length check for input string values: partitioned columns") { // DS V2 doesn't support partitioned table. @@ -147,23 +40,11 @@ class GlutenFileSourceCharVarcharTestSuite sql(s"INSERT INTO $tableName VALUES (1, null)") checkAnswer(spark.table(tableName), Row(1, null)) val e = intercept[SparkException](sql(s"INSERT INTO $tableName VALUES (1, '123456')")) - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) + assert(e.getCause.getMessage.contains(ERROR_MESSAGE)) } } } - testGluten("length check for input string values: with implicit cast") { - withTable("t") { - sql(s"CREATE TABLE t(c1 CHAR(5), c2 VARCHAR(5)) USING $format") - sql("INSERT INTO t VALUES (1234, 1234)") - checkAnswer(spark.table("t"), Row("1234 ", "1234")) - val e1 = intercept[SparkException](sql("INSERT INTO t VALUES (123456, 1)")) - assert(e1.getMessage.contains(VELOX_ERROR_MESSAGE)) - val e2 = intercept[SparkException](sql("INSERT INTO t VALUES (1, 123456)")) - assert(e2.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - testGluten("char/varchar type values length check: partitioned columns of other types") { val tableName = "t" Seq("CHAR(5)", "VARCHAR(5)").foreach { @@ -180,194 +61,13 @@ class GlutenFileSourceCharVarcharTestSuite val e1 = intercept[SparkException](sql(s"INSERT OVERWRITE $tableName VALUES ('1', 100000)")) - assert(e1.getMessage.contains(VELOX_ERROR_MESSAGE)) + assert(e1.getCause.getMessage.contains(ERROR_MESSAGE)) val e2 = intercept[RuntimeException](sql("ALTER TABLE t DROP PARTITION(c=100000)")) assert(e2.getMessage.contains(ERROR_MESSAGE)) } } } - } -class GlutenDSV2CharVarcharTestSuite extends DSV2CharVarcharTestSuite with GlutenSQLTestsTrait { - private val ERROR_MESSAGE = - "Exceeds char/varchar type length limitation: 5" - private val VELOX_ERROR_MESSAGE = - "Exceeds allowed length limitation: 5" - - private def testTableWrite(f: String => Unit): Unit = { - withTable("t")(f("char")) - withTable("t")(f("varchar")) - } - - testGluten("length check for input string values: top-level columns") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c $typeName(5)) USING $format") - sql("INSERT INTO t VALUES (null)") - checkAnswer(spark.table("t"), Row(null)) - val e = intercept[SparkException](sql("INSERT INTO t VALUES ('123456')")) - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in array") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c ARRAY<$typeName(5)>) USING $format") - sql("INSERT INTO t VALUES (array(null))") - checkAnswer(spark.table("t"), Row(Seq(null))) - val e = intercept[SparkException] { - sql("INSERT INTO t VALUES (array('a', '123456'))") - } - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in struct of array") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c STRUCT>) USING $format") - sql("INSERT INTO t SELECT struct(array(null))") - checkAnswer(spark.table("t"), Row(Row(Seq(null)))) - val e = intercept[SparkException](sql("INSERT INTO t SELECT struct(array('123456'))")) - assert(e.getCause.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in array of struct") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c ARRAY>) USING $format") - sql("INSERT INTO t VALUES (array(struct(null)))") - checkAnswer(spark.table("t"), Row(Seq(Row(null)))) - val e = intercept[SparkException](sql("INSERT INTO t VALUES (array(struct('123456')))")) - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in array of array") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c ARRAY>) USING $format") - sql("INSERT INTO t VALUES (array(array(null)))") - checkAnswer(spark.table("t"), Row(Seq(Seq(null)))) - val e = intercept[SparkException](sql("INSERT INTO t VALUES (array(array('123456')))")) - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: with implicit cast") { - withTable("t") { - sql(s"CREATE TABLE t(c1 CHAR(5), c2 VARCHAR(5)) USING $format") - sql("INSERT INTO t VALUES (1234, 1234)") - checkAnswer(spark.table("t"), Row("1234 ", "1234")) - val e1 = intercept[SparkException](sql("INSERT INTO t VALUES (123456, 1)")) - assert(e1.getMessage.contains(VELOX_ERROR_MESSAGE)) - val e2 = intercept[SparkException](sql("INSERT INTO t VALUES (1, 123456)")) - assert(e2.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("char/varchar type values length check: partitioned columns of other types") { - val tableName = "t" - Seq("CHAR(5)", "VARCHAR(5)").foreach { - typ => - withTable(tableName) { - sql(s"CREATE TABLE $tableName(i STRING, c $typ) USING $format PARTITIONED BY (c)") - Seq(1, 10, 100, 1000, 10000).foreach { - v => - sql(s"INSERT OVERWRITE $tableName VALUES ('1', $v)") - checkPlainResult(spark.table(tableName), typ, v.toString) - sql(s"ALTER TABLE $tableName DROP PARTITION(c=$v)") - checkAnswer(spark.table(tableName), Nil) - } - - val e1 = - intercept[SparkException](sql(s"INSERT OVERWRITE $tableName VALUES ('1', 100000)")) - assert(e1.getMessage.contains(VELOX_ERROR_MESSAGE)) - - val e2 = intercept[RuntimeException](sql("ALTER TABLE t DROP PARTITION(c=100000)")) - assert(e2.getMessage.contains(ERROR_MESSAGE)) - } - } - } - - testGluten("SPARK-42611: check char/varchar length in reordered structs within arrays") { - Seq("CHAR(5)", "VARCHAR(5)").foreach { - typ => - withTable("t") { - sql(s"CREATE TABLE t(a ARRAY>) USING $format") - val inputDF = sql("SELECT array(named_struct('n_i', 1, 'n_c', '123456')) AS a") - val e = intercept[SparkException](inputDF.writeTo("t").append()) - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - } - - testGluten("length check for input string values: nested in map key") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c MAP<$typeName(5), STRING>) USING $format") - val e = intercept[SparkException](sql("INSERT INTO t VALUES (map('123456', 'a'))")) - // Gluten exception differs from Spark - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in map value") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c MAP) USING $format") - sql("INSERT INTO t VALUES (map('a', null))") - checkAnswer(spark.table("t"), Row(Map("a" -> null))) - val e = intercept[SparkException](sql("INSERT INTO t VALUES (map('a', '123456'))")) - // Gluten exception differs from Spark - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in both map key and value") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c MAP<$typeName(5), $typeName(5)>) USING $format") - val e1 = intercept[SparkException](sql("INSERT INTO t VALUES (map('123456', 'a'))")) - // Gluten exception differs from Spark - assert(e1.getMessage.contains(VELOX_ERROR_MESSAGE)) - val e2 = intercept[SparkException](sql("INSERT INTO t VALUES (map('a', '123456'))")) - // Gluten exception differs from Spark - assert(e2.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("SPARK-42611: check char/varchar length in reordered structs within map keys") { - Seq("CHAR(5)", "VARCHAR(5)").foreach { - typ => - withTable("t") { - sql(s"CREATE TABLE t(m MAP, INT>) USING $format") - - val inputDF = sql("SELECT map(named_struct('n_i', 1, 'n_c', '123456'), 1) AS m") - - val e = intercept[SparkException](inputDF.writeTo("t").append()) - // Gluten exception differs from Spark - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - } - - testGluten("SPARK-42611: check char/varchar length in reordered structs within map values") { - Seq("CHAR(5)", "VARCHAR(5)").foreach { - typ => - withTable("t") { - sql(s"CREATE TABLE t(m MAP>) USING $format") - - val inputDF = sql("SELECT map(1, named_struct('n_i', 1, 'n_c', '123456')) AS m") - - val e = intercept[SparkException](inputDF.writeTo("t").append()) - // Gluten exception differs from Spark - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - } -} +class GlutenDSV2CharVarcharTestSuite extends DSV2CharVarcharTestSuite with GlutenSQLTestsTrait {} diff --git a/gluten-ut/spark35/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala b/gluten-ut/spark35/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala index f65652d5223..6f00e6dcd7a 100644 --- a/gluten-ut/spark35/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala +++ b/gluten-ut/spark35/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala @@ -609,43 +609,11 @@ class VeloxTestSettings extends BackendTestSettings { // Rewrite for different cache size. .exclude("SPARK-36120: Support cache/uncache table with TimestampNTZ type") enableSuite[GlutenFileSourceCharVarcharTestSuite] - .exclude("length check for input string values: nested in array") - .exclude("length check for input string values: nested in array") - .exclude("length check for input string values: nested in map key") - .exclude("length check for input string values: nested in map value") - .exclude("length check for input string values: nested in both map key and value") - .exclude("length check for input string values: nested in array of struct") - .exclude("length check for input string values: nested in array of array") - // Following tests are excluded as these are overridden in Gluten test suite.. - // The overridden tests assert against Velox-specific error messages for char/varchar - // length validation, which differ from the original vanilla Spark tests. - .exclude("length check for input string values: top-level columns") + // Spark expects the length error of these partitioned inserts wrapped in TASK_WRITE_FAILED, + // but Gluten throws it unwrapped. Rewritten in GlutenCharVarcharTestSuite. .exclude("length check for input string values: partitioned columns") - .exclude("length check for input string values: nested in struct of array") - .exclude("length check for input string values: with implicit cast") .exclude("char/varchar type values length check: partitioned columns of other types") enableSuite[GlutenDSV2CharVarcharTestSuite] - // Following tests are excluded as these are overridden in Gluten test suite.. - // The overridden tests assert against Velox-specific error messages for char/varchar - // length validation, which differ from the original vanilla Spark tests. - .exclude("length check for input string values: top-level columns") - .exclude("length check for input string values: nested in array") - .exclude("length check for input string values: nested in struct of array") - .exclude("length check for input string values: nested in array of struct") - .exclude("length check for input string values: nested in array of array") - .exclude("length check for input string values: with implicit cast") - .exclude("char/varchar type values length check: partitioned columns of other types") - .exclude("SPARK-42611: check char/varchar length in reordered structs within arrays") - // Overridden. - .exclude("length check for input string values: nested in map key") - // Overridden. - .exclude("length check for input string values: nested in map value") - // Overridden. - .exclude("length check for input string values: nested in both map key and value") - // Overridden. - .exclude("SPARK-42611: check char/varchar length in reordered structs within map keys") - // Overridden. - .exclude("SPARK-42611: check char/varchar length in reordered structs within map values") enableSuite[GlutenColumnExpressionSuite] // Velox raise_error('errMsg') throws a velox_user_error exception with the message 'errMsg'. // The final caught Spark exception's getCause().getMessage() contains 'errMsg' but does not diff --git a/gluten-ut/spark35/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala b/gluten-ut/spark35/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala index af23dc8a1e1..331517cf16a 100644 --- a/gluten-ut/spark35/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala +++ b/gluten-ut/spark35/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala @@ -16,7 +16,7 @@ */ package org.apache.spark.sql -import org.apache.spark.SparkException +import org.apache.spark.{SparkException, SparkRuntimeException} import org.apache.spark.sql.internal.SQLConf class GlutenFileSourceCharVarcharTestSuite @@ -27,116 +27,6 @@ class GlutenFileSourceCharVarcharTestSuite withTable("t")(f("varchar")) } - private val ERROR_MESSAGE = - "Exceeds char/varchar type length limitation: 5" - private val VELOX_ERROR_MESSAGE = - "Exceeds allowed length limitation: 5" - - testGluten("length check for input string values: nested in struct") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c STRUCT) USING $format") - sql("INSERT INTO t SELECT struct(null)") - checkAnswer(spark.table("t"), Row(Row(null))) - val e = intercept[RuntimeException] { - sql("INSERT INTO t SELECT struct('123456')") - } - assert(e.getMessage.contains(ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in array") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c ARRAY<$typeName(5)>) USING $format") - sql("INSERT INTO t VALUES (array(null))") - checkAnswer(spark.table("t"), Row(Seq(null))) - val e = intercept[SparkException] { - sql("INSERT INTO t VALUES (array('a', '123456'))") - } - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in map key") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c MAP<$typeName(5), STRING>) USING $format") - val e = intercept[SparkException](sql("INSERT INTO t VALUES (map('123456', 'a'))")) - // Gluten exception differs from Spark - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in map value") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c MAP) USING $format") - sql("INSERT INTO t VALUES (map('a', null))") - checkAnswer(spark.table("t"), Row(Map("a" -> null))) - val e = intercept[SparkException](sql("INSERT INTO t VALUES (map('a', '123456'))")) - // Gluten exception differs from Spark - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in both map key and value") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c MAP<$typeName(5), $typeName(5)>) USING $format") - val e1 = intercept[SparkException](sql("INSERT INTO t VALUES (map('123456', 'a'))")) - // Gluten exception differs from Spark - assert(e1.getMessage.contains(VELOX_ERROR_MESSAGE)) - val e2 = intercept[SparkException](sql("INSERT INTO t VALUES (map('a', '123456'))")) - // Gluten exception differs from Spark - assert(e2.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in struct of array") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c STRUCT>) USING $format") - sql("INSERT INTO t SELECT struct(array(null))") - checkAnswer(spark.table("t"), Row(Row(Seq(null)))) - val e = intercept[SparkException](sql("INSERT INTO t SELECT struct(array('123456'))")) - assert(e.getCause.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in array of struct") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c ARRAY>) USING $format") - sql("INSERT INTO t VALUES (array(struct(null)))") - checkAnswer(spark.table("t"), Row(Seq(Row(null)))) - val e = intercept[SparkException](sql("INSERT INTO t VALUES (array(struct('123456')))")) - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in array of array") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c ARRAY>) USING $format") - sql("INSERT INTO t VALUES (array(array(null)))") - checkAnswer(spark.table("t"), Row(Seq(Seq(null)))) - val e = intercept[SparkException](sql("INSERT INTO t VALUES (array(array('123456')))")) - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: top-level columns") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c $typeName(5)) USING $format") - sql("INSERT INTO t VALUES (null)") - checkAnswer(spark.table("t"), Row(null)) - val e = intercept[SparkException](sql("INSERT INTO t VALUES ('123456')")) - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - testGluten("length check for input string values: partitioned columns") { // DS V2 doesn't support partitioned table. if (!conf.contains(SQLConf.DEFAULT_CATALOG.key)) { @@ -147,23 +37,15 @@ class GlutenFileSourceCharVarcharTestSuite sql(s"INSERT INTO $tableName VALUES (1, null)") checkAnswer(spark.table(tableName), Row(1, null)) val e = intercept[SparkException](sql(s"INSERT INTO $tableName VALUES (1, '123456')")) - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) + checkError( + exception = e.getCause.asInstanceOf[SparkRuntimeException], + errorClass = "EXCEED_LIMIT_LENGTH", + parameters = Map("limit" -> "5") + ) } } } - testGluten("length check for input string values: with implicit cast") { - withTable("t") { - sql(s"CREATE TABLE t(c1 CHAR(5), c2 VARCHAR(5)) USING $format") - sql("INSERT INTO t VALUES (1234, 1234)") - checkAnswer(spark.table("t"), Row("1234 ", "1234")) - val e1 = intercept[SparkException](sql("INSERT INTO t VALUES (123456, 1)")) - assert(e1.getMessage.contains(VELOX_ERROR_MESSAGE)) - val e2 = intercept[SparkException](sql("INSERT INTO t VALUES (1, 123456)")) - assert(e2.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - testGluten("char/varchar type values length check: partitioned columns of other types") { val tableName = "t" Seq("CHAR(5)", "VARCHAR(5)").foreach { @@ -180,193 +62,22 @@ class GlutenFileSourceCharVarcharTestSuite val e1 = intercept[SparkException](sql(s"INSERT OVERWRITE $tableName VALUES ('1', 100000)")) - assert(e1.getMessage.contains(VELOX_ERROR_MESSAGE)) - - val e2 = intercept[RuntimeException](sql("ALTER TABLE t DROP PARTITION(c=100000)")) - assert(e2.getMessage.contains(ERROR_MESSAGE)) + checkError( + exception = e1.getCause.asInstanceOf[SparkRuntimeException], + errorClass = "EXCEED_LIMIT_LENGTH", + parameters = Map("limit" -> "5") + ) + + checkError( + exception = intercept[SparkRuntimeException] { + sql("ALTER TABLE t DROP PARTITION(c=100000)") + }, + errorClass = "EXCEED_LIMIT_LENGTH", + parameters = Map("limit" -> "5") + ) } } } } -class GlutenDSV2CharVarcharTestSuite extends DSV2CharVarcharTestSuite with GlutenSQLTestsTrait { - private val ERROR_MESSAGE = - "Exceeds char/varchar type length limitation: 5" - private val VELOX_ERROR_MESSAGE = - "Exceeds allowed length limitation: 5" - - private def testTableWrite(f: String => Unit): Unit = { - withTable("t")(f("char")) - withTable("t")(f("varchar")) - } - - testGluten("length check for input string values: top-level columns") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c $typeName(5)) USING $format") - sql("INSERT INTO t VALUES (null)") - checkAnswer(spark.table("t"), Row(null)) - val e = intercept[SparkException](sql("INSERT INTO t VALUES ('123456')")) - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in array") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c ARRAY<$typeName(5)>) USING $format") - sql("INSERT INTO t VALUES (array(null))") - checkAnswer(spark.table("t"), Row(Seq(null))) - val e = intercept[SparkException] { - sql("INSERT INTO t VALUES (array('a', '123456'))") - } - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in struct of array") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c STRUCT>) USING $format") - sql("INSERT INTO t SELECT struct(array(null))") - checkAnswer(spark.table("t"), Row(Row(Seq(null)))) - val e = intercept[SparkException](sql("INSERT INTO t SELECT struct(array('123456'))")) - assert(e.getCause.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in array of struct") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c ARRAY>) USING $format") - sql("INSERT INTO t VALUES (array(struct(null)))") - checkAnswer(spark.table("t"), Row(Seq(Row(null)))) - val e = intercept[SparkException](sql("INSERT INTO t VALUES (array(struct('123456')))")) - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in array of array") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c ARRAY>) USING $format") - sql("INSERT INTO t VALUES (array(array(null)))") - checkAnswer(spark.table("t"), Row(Seq(Seq(null)))) - val e = intercept[SparkException](sql("INSERT INTO t VALUES (array(array('123456')))")) - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: with implicit cast") { - withTable("t") { - sql(s"CREATE TABLE t(c1 CHAR(5), c2 VARCHAR(5)) USING $format") - sql("INSERT INTO t VALUES (1234, 1234)") - checkAnswer(spark.table("t"), Row("1234 ", "1234")) - val e1 = intercept[SparkException](sql("INSERT INTO t VALUES (123456, 1)")) - assert(e1.getMessage.contains(VELOX_ERROR_MESSAGE)) - val e2 = intercept[SparkException](sql("INSERT INTO t VALUES (1, 123456)")) - assert(e2.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("char/varchar type values length check: partitioned columns of other types") { - val tableName = "t" - Seq("CHAR(5)", "VARCHAR(5)").foreach { - typ => - withTable(tableName) { - sql(s"CREATE TABLE $tableName(i STRING, c $typ) USING $format PARTITIONED BY (c)") - Seq(1, 10, 100, 1000, 10000).foreach { - v => - sql(s"INSERT OVERWRITE $tableName VALUES ('1', $v)") - checkPlainResult(spark.table(tableName), typ, v.toString) - sql(s"ALTER TABLE $tableName DROP PARTITION(c=$v)") - checkAnswer(spark.table(tableName), Nil) - } - - val e1 = - intercept[SparkException](sql(s"INSERT OVERWRITE $tableName VALUES ('1', 100000)")) - assert(e1.getMessage.contains(VELOX_ERROR_MESSAGE)) - - val e2 = intercept[RuntimeException](sql("ALTER TABLE t DROP PARTITION(c=100000)")) - assert(e2.getMessage.contains(ERROR_MESSAGE)) - } - } - } - - testGluten("SPARK-42611: check char/varchar length in reordered structs within arrays") { - Seq("CHAR(5)", "VARCHAR(5)").foreach { - typ => - withTable("t") { - sql(s"CREATE TABLE t(a ARRAY>) USING $format") - val inputDF = sql("SELECT array(named_struct('n_i', 1, 'n_c', '123456')) AS a") - val e = intercept[SparkException](inputDF.writeTo("t").append()) - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - } - - testGluten("length check for input string values: nested in map key") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c MAP<$typeName(5), STRING>) USING $format") - val e = intercept[SparkException](sql("INSERT INTO t VALUES (map('123456', 'a'))")) - // Gluten exception differs from Spark - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in map value") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c MAP) USING $format") - sql("INSERT INTO t VALUES (map('a', null))") - checkAnswer(spark.table("t"), Row(Map("a" -> null))) - val e = intercept[SparkException](sql("INSERT INTO t VALUES (map('a', '123456'))")) - // Gluten exception differs from Spark - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("length check for input string values: nested in both map key and value") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c MAP<$typeName(5), $typeName(5)>) USING $format") - val e1 = intercept[SparkException](sql("INSERT INTO t VALUES (map('123456', 'a'))")) - // Gluten exception differs from Spark - assert(e1.getMessage.contains(VELOX_ERROR_MESSAGE)) - val e2 = intercept[SparkException](sql("INSERT INTO t VALUES (map('a', '123456'))")) - // Gluten exception differs from Spark - assert(e2.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - - testGluten("SPARK-42611: check char/varchar length in reordered structs within map keys") { - Seq("CHAR(5)", "VARCHAR(5)").foreach { - typ => - withTable("t") { - sql(s"CREATE TABLE t(m MAP, INT>) USING $format") - - val inputDF = sql("SELECT map(named_struct('n_i', 1, 'n_c', '123456'), 1) AS m") - - val e = intercept[SparkException](inputDF.writeTo("t").append()) - // Gluten exception differs from Spark - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - } - - testGluten("SPARK-42611: check char/varchar length in reordered structs within map values") { - Seq("CHAR(5)", "VARCHAR(5)").foreach { - typ => - withTable("t") { - sql(s"CREATE TABLE t(m MAP>) USING $format") - - val inputDF = sql("SELECT map(1, named_struct('n_i', 1, 'n_c', '123456')) AS m") - - val e = intercept[SparkException](inputDF.writeTo("t").append()) - // Gluten exception differs from Spark - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } - } -} +class GlutenDSV2CharVarcharTestSuite extends DSV2CharVarcharTestSuite with GlutenSQLTestsTrait {} diff --git a/gluten-ut/spark40/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala b/gluten-ut/spark40/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala index ed40918de6b..84502ace511 100644 --- a/gluten-ut/spark40/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala +++ b/gluten-ut/spark40/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala @@ -16,55 +16,8 @@ */ package org.apache.spark.sql -import org.apache.spark.{SparkException, SparkRuntimeException, SparkThrowable} - -trait GlutenCharVarcharTestSuite extends CharVarcharTestSuite with GlutenSQLTestsTrait { - protected val ERROR_MESSAGE = - "Exceeds char/varchar type length limitation: 5" - - protected val VELOX_ERROR_MESSAGE = - "Exceeds allowed length limitation: 5" - - override def assertLengthCheckFailure(func: () => Unit): Unit = { - val e = intercept[SparkThrowable](func()) - e match { - // Spark throws exception - case _: SparkRuntimeException => - checkError( - exception = e, - condition = "EXCEED_LIMIT_LENGTH", - parameters = Map("limit" -> "5") - ) - // Gluten throws exception. but sometimes, Spark exception is wrapped in GlutenException. - case e: SparkException => - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE) || e.getMessage.contains(ERROR_MESSAGE)) - case _ => throw new RuntimeException(s"Unexpected exception: $e") - } - } -} - class GlutenFileSourceCharVarcharTestSuite extends FileSourceCharVarcharTestSuite - with GlutenCharVarcharTestSuite { - private def testTableWrite(f: String => Unit): Unit = { - withTable("t")(f("char")) - withTable("t")(f("varchar")) - } - - testGluten("length check for input string values: nested in array") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c ARRAY<$typeName(5)>) USING $format") - sql("INSERT INTO t VALUES (array(null))") - checkAnswer(spark.table("t"), Row(Seq(null))) - val e = intercept[SparkException] { - sql("INSERT INTO t VALUES (array('a', '123456'))") - } - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } -} + with GlutenSQLTestsTrait {} -class GlutenDSV2CharVarcharTestSuite - extends DSV2CharVarcharTestSuite - with GlutenCharVarcharTestSuite {} +class GlutenDSV2CharVarcharTestSuite extends DSV2CharVarcharTestSuite with GlutenSQLTestsTrait {} diff --git a/gluten-ut/spark41/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala b/gluten-ut/spark41/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala index ed40918de6b..84502ace511 100644 --- a/gluten-ut/spark41/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala +++ b/gluten-ut/spark41/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala @@ -16,55 +16,8 @@ */ package org.apache.spark.sql -import org.apache.spark.{SparkException, SparkRuntimeException, SparkThrowable} - -trait GlutenCharVarcharTestSuite extends CharVarcharTestSuite with GlutenSQLTestsTrait { - protected val ERROR_MESSAGE = - "Exceeds char/varchar type length limitation: 5" - - protected val VELOX_ERROR_MESSAGE = - "Exceeds allowed length limitation: 5" - - override def assertLengthCheckFailure(func: () => Unit): Unit = { - val e = intercept[SparkThrowable](func()) - e match { - // Spark throws exception - case _: SparkRuntimeException => - checkError( - exception = e, - condition = "EXCEED_LIMIT_LENGTH", - parameters = Map("limit" -> "5") - ) - // Gluten throws exception. but sometimes, Spark exception is wrapped in GlutenException. - case e: SparkException => - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE) || e.getMessage.contains(ERROR_MESSAGE)) - case _ => throw new RuntimeException(s"Unexpected exception: $e") - } - } -} - class GlutenFileSourceCharVarcharTestSuite extends FileSourceCharVarcharTestSuite - with GlutenCharVarcharTestSuite { - private def testTableWrite(f: String => Unit): Unit = { - withTable("t")(f("char")) - withTable("t")(f("varchar")) - } - - testGluten("length check for input string values: nested in array") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c ARRAY<$typeName(5)>) USING $format") - sql("INSERT INTO t VALUES (array(null))") - checkAnswer(spark.table("t"), Row(Seq(null))) - val e = intercept[SparkException] { - sql("INSERT INTO t VALUES (array('a', '123456'))") - } - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } -} + with GlutenSQLTestsTrait {} -class GlutenDSV2CharVarcharTestSuite - extends DSV2CharVarcharTestSuite - with GlutenCharVarcharTestSuite {} +class GlutenDSV2CharVarcharTestSuite extends DSV2CharVarcharTestSuite with GlutenSQLTestsTrait {} diff --git a/gluten-ut/spark42/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala b/gluten-ut/spark42/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala index 2a14b80479f..a47fe5969c5 100644 --- a/gluten-ut/spark42/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala +++ b/gluten-ut/spark42/src/test/scala/org/apache/gluten/utils/velox/VeloxTestSettings.scala @@ -1289,10 +1289,6 @@ class VeloxTestSettings extends BackendTestSettings { enableSuite[GlutenLegacyParameterSubstitutionSuite] enableSuite[GlutenParametersSuite] enableSuite[GlutenResolveDefaultColumnsSuite] - // Velox char/varchar write-side check throws VeloxUserError instead of SparkRuntimeException. - // Rewritten in GlutenResolveDefaultColumnsSuite. - .exclude( - "SPARK-57187: non-foldable default exceeding CHAR/VARCHAR length fails at INSERT time (explicit DEFAULT keyword)") enableSuite[GlutenSubqueryHintPropagationSuite] enableSuite[GlutenUrlFunctionsSuite] enableSuite[GlutenParquetRowIndexSuite] diff --git a/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala b/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala index ed40918de6b..84502ace511 100644 --- a/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala +++ b/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/GlutenCharVarcharTestSuite.scala @@ -16,55 +16,8 @@ */ package org.apache.spark.sql -import org.apache.spark.{SparkException, SparkRuntimeException, SparkThrowable} - -trait GlutenCharVarcharTestSuite extends CharVarcharTestSuite with GlutenSQLTestsTrait { - protected val ERROR_MESSAGE = - "Exceeds char/varchar type length limitation: 5" - - protected val VELOX_ERROR_MESSAGE = - "Exceeds allowed length limitation: 5" - - override def assertLengthCheckFailure(func: () => Unit): Unit = { - val e = intercept[SparkThrowable](func()) - e match { - // Spark throws exception - case _: SparkRuntimeException => - checkError( - exception = e, - condition = "EXCEED_LIMIT_LENGTH", - parameters = Map("limit" -> "5") - ) - // Gluten throws exception. but sometimes, Spark exception is wrapped in GlutenException. - case e: SparkException => - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE) || e.getMessage.contains(ERROR_MESSAGE)) - case _ => throw new RuntimeException(s"Unexpected exception: $e") - } - } -} - class GlutenFileSourceCharVarcharTestSuite extends FileSourceCharVarcharTestSuite - with GlutenCharVarcharTestSuite { - private def testTableWrite(f: String => Unit): Unit = { - withTable("t")(f("char")) - withTable("t")(f("varchar")) - } - - testGluten("length check for input string values: nested in array") { - testTableWrite { - typeName => - sql(s"CREATE TABLE t(c ARRAY<$typeName(5)>) USING $format") - sql("INSERT INTO t VALUES (array(null))") - checkAnswer(spark.table("t"), Row(Seq(null))) - val e = intercept[SparkException] { - sql("INSERT INTO t VALUES (array('a', '123456'))") - } - assert(e.getMessage.contains(VELOX_ERROR_MESSAGE)) - } - } -} + with GlutenSQLTestsTrait {} -class GlutenDSV2CharVarcharTestSuite - extends DSV2CharVarcharTestSuite - with GlutenCharVarcharTestSuite {} +class GlutenDSV2CharVarcharTestSuite extends DSV2CharVarcharTestSuite with GlutenSQLTestsTrait {} diff --git a/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/GlutenResolveDefaultColumnsSuite.scala b/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/GlutenResolveDefaultColumnsSuite.scala index 7d11c7dcebe..2d1570be26c 100644 --- a/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/GlutenResolveDefaultColumnsSuite.scala +++ b/gluten-ut/spark42/src/test/scala/org/apache/spark/sql/GlutenResolveDefaultColumnsSuite.scala @@ -16,24 +16,6 @@ */ package org.apache.spark.sql -import org.apache.spark.SparkException - class GlutenResolveDefaultColumnsSuite extends ResolveDefaultColumnsSuite - with GlutenSQLTestsTrait { - - // The explicit DEFAULT value is checked by the native project, so the INSERT fails with Velox's - // error wrapped in a SparkException instead of Spark's EXCEED_LIMIT_LENGTH SparkRuntimeException. - testGluten( - "SPARK-57187: non-foldable default exceeding CHAR/VARCHAR length fails at INSERT time " + - "(explicit DEFAULT keyword)") { - Seq("CHAR", "VARCHAR").foreach { - typeName => - withTable("t") { - sql(s"CREATE TABLE t(i INT, s $typeName(1) DEFAULT current_user()) USING parquet") - val e = intercept[SparkException](sql("INSERT INTO t VALUES (1, DEFAULT)")) - assert(e.getMessage.contains("Exceeds allowed length limitation: 1")) - } - } - } -} + with GlutenSQLTestsTrait {} diff --git a/shims/common/src/main/scala/org/apache/gluten/sql/shims/SparkShims.scala b/shims/common/src/main/scala/org/apache/gluten/sql/shims/SparkShims.scala index aad7a2d347c..c6acc659a41 100644 --- a/shims/common/src/main/scala/org/apache/gluten/sql/shims/SparkShims.scala +++ b/shims/common/src/main/scala/org/apache/gluten/sql/shims/SparkShims.scala @@ -264,4 +264,12 @@ trait SparkShims { def getShuffleBlockFetcherIterator(params: ShuffleBlockFetcherIteratorParams) : GlutenShuffleBlockFetcherIteratorBase + + /** + * Returns the exception Spark throws when a char or varchar value is longer than its declared + * length, with the native error as its cause. Spark 3.5 and later override this with the + * EXCEED_LIMIT_LENGTH error. + */ + def charVarcharLengthExceededError(limit: Int, cause: Throwable): RuntimeException = + new RuntimeException(s"Exceeds char/varchar type length limitation: $limit", cause) } diff --git a/shims/spark35/src/main/scala/org/apache/gluten/sql/shims/spark35/Spark35Shims.scala b/shims/spark35/src/main/scala/org/apache/gluten/sql/shims/spark35/Spark35Shims.scala index b986fd2ce6d..1b78c3bad56 100644 --- a/shims/spark35/src/main/scala/org/apache/gluten/sql/shims/spark35/Spark35Shims.scala +++ b/shims/spark35/src/main/scala/org/apache/gluten/sql/shims/spark35/Spark35Shims.scala @@ -32,6 +32,7 @@ import org.apache.spark.sql.catalyst.plans.physical.{KeyGroupedPartitioning, Par import org.apache.spark.sql.catalyst.util.InternalRowComparableWrapper import org.apache.spark.sql.catalyst.util.RebaseDateTime.RebaseSpec import org.apache.spark.sql.connector.read.{HasPartitionKey, InputPartition, Scan} +import org.apache.spark.sql.errors.GlutenQueryExecutionErrors import org.apache.spark.sql.execution._ import org.apache.spark.sql.execution.datasources._ import org.apache.spark.sql.execution.datasources.parquet.{ParquetFileFormat, ParquetFilters} @@ -440,4 +441,7 @@ class Spark35Shims extends SparkShims { params.clock ) } + + override def charVarcharLengthExceededError(limit: Int, cause: Throwable): RuntimeException = + GlutenQueryExecutionErrors.exceedMaxLimit(limit, cause) } diff --git a/shims/spark35/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala b/shims/spark35/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala new file mode 100644 index 00000000000..6caf4641905 --- /dev/null +++ b/shims/spark35/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.spark.sql.errors + +import org.apache.spark.SparkRuntimeException + +object GlutenQueryExecutionErrors { + + // Builds the same exception as QueryExecutionErrors.exceedMaxLimit, with the native error as its + // cause. SparkRuntimeException is private[spark] and takes its cause only in its constructor. + def exceedMaxLimit(limit: Int, cause: Throwable): SparkRuntimeException = + new SparkRuntimeException( + errorClass = "EXCEED_LIMIT_LENGTH", + messageParameters = Map("limit" -> limit.toString), + cause = cause) +} diff --git a/shims/spark40/src/main/scala/org/apache/gluten/sql/shims/spark40/Spark40Shims.scala b/shims/spark40/src/main/scala/org/apache/gluten/sql/shims/spark40/Spark40Shims.scala index c189367411f..6e709fec1a8 100644 --- a/shims/spark40/src/main/scala/org/apache/gluten/sql/shims/spark40/Spark40Shims.scala +++ b/shims/spark40/src/main/scala/org/apache/gluten/sql/shims/spark40/Spark40Shims.scala @@ -35,6 +35,7 @@ import org.apache.spark.sql.catalyst.util.RebaseDateTime.RebaseSpec import org.apache.spark.sql.classic.ClassicConversions._ import org.apache.spark.sql.connector.read.{HasPartitionKey, InputPartition, Scan} import org.apache.spark.sql.connector.read.streaming.SparkDataStream +import org.apache.spark.sql.errors.GlutenQueryExecutionErrors import org.apache.spark.sql.execution._ import org.apache.spark.sql.execution.datasources._ import org.apache.spark.sql.execution.datasources.parquet.{ParquetFileFormat, ParquetFilters} @@ -514,4 +515,7 @@ class Spark40Shims extends SparkShims { params.clock ) } + + override def charVarcharLengthExceededError(limit: Int, cause: Throwable): RuntimeException = + GlutenQueryExecutionErrors.exceedMaxLimit(limit, cause) } diff --git a/shims/spark40/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala b/shims/spark40/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala new file mode 100644 index 00000000000..6caf4641905 --- /dev/null +++ b/shims/spark40/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.spark.sql.errors + +import org.apache.spark.SparkRuntimeException + +object GlutenQueryExecutionErrors { + + // Builds the same exception as QueryExecutionErrors.exceedMaxLimit, with the native error as its + // cause. SparkRuntimeException is private[spark] and takes its cause only in its constructor. + def exceedMaxLimit(limit: Int, cause: Throwable): SparkRuntimeException = + new SparkRuntimeException( + errorClass = "EXCEED_LIMIT_LENGTH", + messageParameters = Map("limit" -> limit.toString), + cause = cause) +} diff --git a/shims/spark41/src/main/scala/org/apache/gluten/sql/shims/spark41/Spark41Shims.scala b/shims/spark41/src/main/scala/org/apache/gluten/sql/shims/spark41/Spark41Shims.scala index c4c4a2e52f2..975c05c61b9 100644 --- a/shims/spark41/src/main/scala/org/apache/gluten/sql/shims/spark41/Spark41Shims.scala +++ b/shims/spark41/src/main/scala/org/apache/gluten/sql/shims/spark41/Spark41Shims.scala @@ -34,6 +34,7 @@ import org.apache.spark.sql.catalyst.util.{CollationFactory, InternalRowComparab import org.apache.spark.sql.catalyst.util.RebaseDateTime.RebaseSpec import org.apache.spark.sql.connector.read.{HasPartitionKey, InputPartition, Scan} import org.apache.spark.sql.connector.read.streaming.SparkDataStream +import org.apache.spark.sql.errors.GlutenQueryExecutionErrors import org.apache.spark.sql.execution._ import org.apache.spark.sql.execution.datasources._ import org.apache.spark.sql.execution.datasources.parquet.{ParquetFileFormat, ParquetFilters} @@ -544,4 +545,7 @@ class Spark41Shims extends SparkShims { params.clock ) } + + override def charVarcharLengthExceededError(limit: Int, cause: Throwable): RuntimeException = + GlutenQueryExecutionErrors.exceedMaxLimit(limit, cause) } diff --git a/shims/spark41/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala b/shims/spark41/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala new file mode 100644 index 00000000000..6caf4641905 --- /dev/null +++ b/shims/spark41/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.spark.sql.errors + +import org.apache.spark.SparkRuntimeException + +object GlutenQueryExecutionErrors { + + // Builds the same exception as QueryExecutionErrors.exceedMaxLimit, with the native error as its + // cause. SparkRuntimeException is private[spark] and takes its cause only in its constructor. + def exceedMaxLimit(limit: Int, cause: Throwable): SparkRuntimeException = + new SparkRuntimeException( + errorClass = "EXCEED_LIMIT_LENGTH", + messageParameters = Map("limit" -> limit.toString), + cause = cause) +} diff --git a/shims/spark42/src/main/scala/org/apache/gluten/sql/shims/spark42/Spark42Shims.scala b/shims/spark42/src/main/scala/org/apache/gluten/sql/shims/spark42/Spark42Shims.scala index d729d2fd971..3c139fe2b7f 100644 --- a/shims/spark42/src/main/scala/org/apache/gluten/sql/shims/spark42/Spark42Shims.scala +++ b/shims/spark42/src/main/scala/org/apache/gluten/sql/shims/spark42/Spark42Shims.scala @@ -34,6 +34,7 @@ import org.apache.spark.sql.catalyst.util.{CollationFactory, InternalRowComparab import org.apache.spark.sql.catalyst.util.RebaseDateTime.RebaseSpec import org.apache.spark.sql.connector.read.{HasPartitionKey, InputPartition, Scan} import org.apache.spark.sql.connector.read.streaming.SparkDataStream +import org.apache.spark.sql.errors.GlutenQueryExecutionErrors import org.apache.spark.sql.execution._ import org.apache.spark.sql.execution.datasources._ import org.apache.spark.sql.execution.datasources.parquet.{ParquetFileFormat, ParquetFilters} @@ -490,4 +491,7 @@ class Spark42Shims extends SparkShims { params.clock ) } + + override def charVarcharLengthExceededError(limit: Int, cause: Throwable): RuntimeException = + GlutenQueryExecutionErrors.exceedMaxLimit(limit, cause) } diff --git a/shims/spark42/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala b/shims/spark42/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala new file mode 100644 index 00000000000..6caf4641905 --- /dev/null +++ b/shims/spark42/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.spark.sql.errors + +import org.apache.spark.SparkRuntimeException + +object GlutenQueryExecutionErrors { + + // Builds the same exception as QueryExecutionErrors.exceedMaxLimit, with the native error as its + // cause. SparkRuntimeException is private[spark] and takes its cause only in its constructor. + def exceedMaxLimit(limit: Int, cause: Throwable): SparkRuntimeException = + new SparkRuntimeException( + errorClass = "EXCEED_LIMIT_LENGTH", + messageParameters = Map("limit" -> limit.toString), + cause = cause) +} From 5178ddb40762c4dee13678085d51a68187a7ab15 Mon Sep 17 00:00:00 2001 From: Pedrum Jalali Date: Thu, 19 Nov 2026 11:15:32 -0800 Subject: [PATCH 2/4] Build the char/varchar length exception with reflection Drop the SparkShims method and the GlutenQueryExecutionErrors helpers. ColumnarBatchOutIterator now builds SparkRuntimeException reflectively and falls back to the plain RuntimeException Spark 3.4 throws. Generated-by: Co-authored with Claude Code (claude-opus-5-5) --- .../vectorized/ColumnarBatchOutIterator.java | 27 +++++++++++++++-- .../apache/gluten/sql/shims/SparkShims.scala | 8 ----- .../sql/shims/spark35/Spark35Shims.scala | 4 --- .../errors/GlutenQueryExecutionErrors.scala | 30 ------------------- .../sql/shims/spark40/Spark40Shims.scala | 4 --- .../errors/GlutenQueryExecutionErrors.scala | 30 ------------------- .../sql/shims/spark41/Spark41Shims.scala | 4 --- .../errors/GlutenQueryExecutionErrors.scala | 30 ------------------- .../sql/shims/spark42/Spark42Shims.scala | 4 --- .../errors/GlutenQueryExecutionErrors.scala | 30 ------------------- 10 files changed, 24 insertions(+), 147 deletions(-) delete mode 100644 shims/spark35/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala delete mode 100644 shims/spark40/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala delete mode 100644 shims/spark41/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala delete mode 100644 shims/spark42/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala diff --git a/gluten-arrow/src/main/java/org/apache/gluten/vectorized/ColumnarBatchOutIterator.java b/gluten-arrow/src/main/java/org/apache/gluten/vectorized/ColumnarBatchOutIterator.java index 6410832a77d..3f6a400debb 100644 --- a/gluten-arrow/src/main/java/org/apache/gluten/vectorized/ColumnarBatchOutIterator.java +++ b/gluten-arrow/src/main/java/org/apache/gluten/vectorized/ColumnarBatchOutIterator.java @@ -21,8 +21,8 @@ import org.apache.gluten.iterator.ClosableIterator; import org.apache.gluten.runtime.Runtime; import org.apache.gluten.runtime.RuntimeAware; -import org.apache.gluten.sql.shims.SparkShimLoader; +import org.apache.spark.QueryContext; import org.apache.spark.sql.execution.datasources.SchemaColumnConvertNotSupportedException; import org.apache.spark.sql.vectorized.ColumnarBatch; @@ -30,6 +30,9 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import scala.collection.immutable.Map; +import scala.collection.immutable.Map$; + public class ColumnarBatchOutIterator extends ClosableIterator implements RuntimeAware { private final Runtime runtime; @@ -159,8 +162,26 @@ private static RuntimeException translateToCharVarcharLengthException(String msg if (!matcher.find()) { return null; } - int limit = Integer.parseInt(matcher.group(1)); - return SparkShimLoader.getSparkShims().charVarcharLengthExceededError(limit, e); + String limit = matcher.group(1); + try { + // Builds the exception QueryExecutionErrors.exceedMaxLimit builds, with the Velox error as + // its cause. SparkRuntimeException is private[spark], and its cause can only be set through + // its constructor. + return (RuntimeException) + Class.forName("org.apache.spark.SparkRuntimeException") + .getConstructor( + String.class, Map.class, Throwable.class, QueryContext[].class, String.class) + .newInstance( + "EXCEED_LIMIT_LENGTH", + Map$.MODULE$.empty().updated("limit", limit), + e, + new QueryContext[0], + ""); + } catch (ReflectiveOperationException ignored) { + // Spark 3.4 has no EXCEED_LIMIT_LENGTH error class, so the constructor throws there. Spark + // 3.4 throws this plain RuntimeException itself. + return new RuntimeException("Exceeds char/varchar type length limitation: " + limit, e); + } } @Override diff --git a/shims/common/src/main/scala/org/apache/gluten/sql/shims/SparkShims.scala b/shims/common/src/main/scala/org/apache/gluten/sql/shims/SparkShims.scala index c6acc659a41..aad7a2d347c 100644 --- a/shims/common/src/main/scala/org/apache/gluten/sql/shims/SparkShims.scala +++ b/shims/common/src/main/scala/org/apache/gluten/sql/shims/SparkShims.scala @@ -264,12 +264,4 @@ trait SparkShims { def getShuffleBlockFetcherIterator(params: ShuffleBlockFetcherIteratorParams) : GlutenShuffleBlockFetcherIteratorBase - - /** - * Returns the exception Spark throws when a char or varchar value is longer than its declared - * length, with the native error as its cause. Spark 3.5 and later override this with the - * EXCEED_LIMIT_LENGTH error. - */ - def charVarcharLengthExceededError(limit: Int, cause: Throwable): RuntimeException = - new RuntimeException(s"Exceeds char/varchar type length limitation: $limit", cause) } diff --git a/shims/spark35/src/main/scala/org/apache/gluten/sql/shims/spark35/Spark35Shims.scala b/shims/spark35/src/main/scala/org/apache/gluten/sql/shims/spark35/Spark35Shims.scala index 1b78c3bad56..b986fd2ce6d 100644 --- a/shims/spark35/src/main/scala/org/apache/gluten/sql/shims/spark35/Spark35Shims.scala +++ b/shims/spark35/src/main/scala/org/apache/gluten/sql/shims/spark35/Spark35Shims.scala @@ -32,7 +32,6 @@ import org.apache.spark.sql.catalyst.plans.physical.{KeyGroupedPartitioning, Par import org.apache.spark.sql.catalyst.util.InternalRowComparableWrapper import org.apache.spark.sql.catalyst.util.RebaseDateTime.RebaseSpec import org.apache.spark.sql.connector.read.{HasPartitionKey, InputPartition, Scan} -import org.apache.spark.sql.errors.GlutenQueryExecutionErrors import org.apache.spark.sql.execution._ import org.apache.spark.sql.execution.datasources._ import org.apache.spark.sql.execution.datasources.parquet.{ParquetFileFormat, ParquetFilters} @@ -441,7 +440,4 @@ class Spark35Shims extends SparkShims { params.clock ) } - - override def charVarcharLengthExceededError(limit: Int, cause: Throwable): RuntimeException = - GlutenQueryExecutionErrors.exceedMaxLimit(limit, cause) } diff --git a/shims/spark35/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala b/shims/spark35/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala deleted file mode 100644 index 6caf4641905..00000000000 --- a/shims/spark35/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.spark.sql.errors - -import org.apache.spark.SparkRuntimeException - -object GlutenQueryExecutionErrors { - - // Builds the same exception as QueryExecutionErrors.exceedMaxLimit, with the native error as its - // cause. SparkRuntimeException is private[spark] and takes its cause only in its constructor. - def exceedMaxLimit(limit: Int, cause: Throwable): SparkRuntimeException = - new SparkRuntimeException( - errorClass = "EXCEED_LIMIT_LENGTH", - messageParameters = Map("limit" -> limit.toString), - cause = cause) -} diff --git a/shims/spark40/src/main/scala/org/apache/gluten/sql/shims/spark40/Spark40Shims.scala b/shims/spark40/src/main/scala/org/apache/gluten/sql/shims/spark40/Spark40Shims.scala index 6e709fec1a8..c189367411f 100644 --- a/shims/spark40/src/main/scala/org/apache/gluten/sql/shims/spark40/Spark40Shims.scala +++ b/shims/spark40/src/main/scala/org/apache/gluten/sql/shims/spark40/Spark40Shims.scala @@ -35,7 +35,6 @@ import org.apache.spark.sql.catalyst.util.RebaseDateTime.RebaseSpec import org.apache.spark.sql.classic.ClassicConversions._ import org.apache.spark.sql.connector.read.{HasPartitionKey, InputPartition, Scan} import org.apache.spark.sql.connector.read.streaming.SparkDataStream -import org.apache.spark.sql.errors.GlutenQueryExecutionErrors import org.apache.spark.sql.execution._ import org.apache.spark.sql.execution.datasources._ import org.apache.spark.sql.execution.datasources.parquet.{ParquetFileFormat, ParquetFilters} @@ -515,7 +514,4 @@ class Spark40Shims extends SparkShims { params.clock ) } - - override def charVarcharLengthExceededError(limit: Int, cause: Throwable): RuntimeException = - GlutenQueryExecutionErrors.exceedMaxLimit(limit, cause) } diff --git a/shims/spark40/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala b/shims/spark40/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala deleted file mode 100644 index 6caf4641905..00000000000 --- a/shims/spark40/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.spark.sql.errors - -import org.apache.spark.SparkRuntimeException - -object GlutenQueryExecutionErrors { - - // Builds the same exception as QueryExecutionErrors.exceedMaxLimit, with the native error as its - // cause. SparkRuntimeException is private[spark] and takes its cause only in its constructor. - def exceedMaxLimit(limit: Int, cause: Throwable): SparkRuntimeException = - new SparkRuntimeException( - errorClass = "EXCEED_LIMIT_LENGTH", - messageParameters = Map("limit" -> limit.toString), - cause = cause) -} diff --git a/shims/spark41/src/main/scala/org/apache/gluten/sql/shims/spark41/Spark41Shims.scala b/shims/spark41/src/main/scala/org/apache/gluten/sql/shims/spark41/Spark41Shims.scala index 975c05c61b9..c4c4a2e52f2 100644 --- a/shims/spark41/src/main/scala/org/apache/gluten/sql/shims/spark41/Spark41Shims.scala +++ b/shims/spark41/src/main/scala/org/apache/gluten/sql/shims/spark41/Spark41Shims.scala @@ -34,7 +34,6 @@ import org.apache.spark.sql.catalyst.util.{CollationFactory, InternalRowComparab import org.apache.spark.sql.catalyst.util.RebaseDateTime.RebaseSpec import org.apache.spark.sql.connector.read.{HasPartitionKey, InputPartition, Scan} import org.apache.spark.sql.connector.read.streaming.SparkDataStream -import org.apache.spark.sql.errors.GlutenQueryExecutionErrors import org.apache.spark.sql.execution._ import org.apache.spark.sql.execution.datasources._ import org.apache.spark.sql.execution.datasources.parquet.{ParquetFileFormat, ParquetFilters} @@ -545,7 +544,4 @@ class Spark41Shims extends SparkShims { params.clock ) } - - override def charVarcharLengthExceededError(limit: Int, cause: Throwable): RuntimeException = - GlutenQueryExecutionErrors.exceedMaxLimit(limit, cause) } diff --git a/shims/spark41/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala b/shims/spark41/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala deleted file mode 100644 index 6caf4641905..00000000000 --- a/shims/spark41/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.spark.sql.errors - -import org.apache.spark.SparkRuntimeException - -object GlutenQueryExecutionErrors { - - // Builds the same exception as QueryExecutionErrors.exceedMaxLimit, with the native error as its - // cause. SparkRuntimeException is private[spark] and takes its cause only in its constructor. - def exceedMaxLimit(limit: Int, cause: Throwable): SparkRuntimeException = - new SparkRuntimeException( - errorClass = "EXCEED_LIMIT_LENGTH", - messageParameters = Map("limit" -> limit.toString), - cause = cause) -} diff --git a/shims/spark42/src/main/scala/org/apache/gluten/sql/shims/spark42/Spark42Shims.scala b/shims/spark42/src/main/scala/org/apache/gluten/sql/shims/spark42/Spark42Shims.scala index 3c139fe2b7f..d729d2fd971 100644 --- a/shims/spark42/src/main/scala/org/apache/gluten/sql/shims/spark42/Spark42Shims.scala +++ b/shims/spark42/src/main/scala/org/apache/gluten/sql/shims/spark42/Spark42Shims.scala @@ -34,7 +34,6 @@ import org.apache.spark.sql.catalyst.util.{CollationFactory, InternalRowComparab import org.apache.spark.sql.catalyst.util.RebaseDateTime.RebaseSpec import org.apache.spark.sql.connector.read.{HasPartitionKey, InputPartition, Scan} import org.apache.spark.sql.connector.read.streaming.SparkDataStream -import org.apache.spark.sql.errors.GlutenQueryExecutionErrors import org.apache.spark.sql.execution._ import org.apache.spark.sql.execution.datasources._ import org.apache.spark.sql.execution.datasources.parquet.{ParquetFileFormat, ParquetFilters} @@ -491,7 +490,4 @@ class Spark42Shims extends SparkShims { params.clock ) } - - override def charVarcharLengthExceededError(limit: Int, cause: Throwable): RuntimeException = - GlutenQueryExecutionErrors.exceedMaxLimit(limit, cause) } diff --git a/shims/spark42/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala b/shims/spark42/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala deleted file mode 100644 index 6caf4641905..00000000000 --- a/shims/spark42/src/main/scala/org/apache/spark/sql/errors/GlutenQueryExecutionErrors.scala +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.spark.sql.errors - -import org.apache.spark.SparkRuntimeException - -object GlutenQueryExecutionErrors { - - // Builds the same exception as QueryExecutionErrors.exceedMaxLimit, with the native error as its - // cause. SparkRuntimeException is private[spark] and takes its cause only in its constructor. - def exceedMaxLimit(limit: Int, cause: Throwable): SparkRuntimeException = - new SparkRuntimeException( - errorClass = "EXCEED_LIMIT_LENGTH", - messageParameters = Map("limit" -> limit.toString), - cause = cause) -} From 6c6d5ea162fbbcda42c598d9f991fea6fa941a87 Mon Sep 17 00:00:00 2001 From: Pedrum Jalali Date: Thu, 19 Nov 2026 15:02:58 -0800 Subject: [PATCH 3/4] Construct SparkRuntimeException directly instead of through reflection Java code can call SparkRuntimeException's constructor from any package, because its private[spark] modifier is enforced only by the Scala compiler. On Spark 3.4, which has no EXCEED_LIMIT_LENGTH error class, SparkVersionUtil.gteSpark35 selects the plain RuntimeException that Spark 3.4 throws itself. Generated-by: Co-authored with Claude Code (claude-opus-5-5) --- .../vectorized/ColumnarBatchOutIterator.java | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/gluten-arrow/src/main/java/org/apache/gluten/vectorized/ColumnarBatchOutIterator.java b/gluten-arrow/src/main/java/org/apache/gluten/vectorized/ColumnarBatchOutIterator.java index 3f6a400debb..4ed3f8ca963 100644 --- a/gluten-arrow/src/main/java/org/apache/gluten/vectorized/ColumnarBatchOutIterator.java +++ b/gluten-arrow/src/main/java/org/apache/gluten/vectorized/ColumnarBatchOutIterator.java @@ -23,14 +23,15 @@ import org.apache.gluten.runtime.RuntimeAware; import org.apache.spark.QueryContext; +import org.apache.spark.SparkRuntimeException; import org.apache.spark.sql.execution.datasources.SchemaColumnConvertNotSupportedException; import org.apache.spark.sql.vectorized.ColumnarBatch; +import org.apache.spark.util.SparkVersionUtil; import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; -import scala.collection.immutable.Map; import scala.collection.immutable.Map$; public class ColumnarBatchOutIterator extends ClosableIterator @@ -163,25 +164,18 @@ private static RuntimeException translateToCharVarcharLengthException(String msg return null; } String limit = matcher.group(1); - try { - // Builds the exception QueryExecutionErrors.exceedMaxLimit builds, with the Velox error as - // its cause. SparkRuntimeException is private[spark], and its cause can only be set through - // its constructor. - return (RuntimeException) - Class.forName("org.apache.spark.SparkRuntimeException") - .getConstructor( - String.class, Map.class, Throwable.class, QueryContext[].class, String.class) - .newInstance( - "EXCEED_LIMIT_LENGTH", - Map$.MODULE$.empty().updated("limit", limit), - e, - new QueryContext[0], - ""); - } catch (ReflectiveOperationException ignored) { - // Spark 3.4 has no EXCEED_LIMIT_LENGTH error class, so the constructor throws there. Spark - // 3.4 throws this plain RuntimeException itself. + if (!SparkVersionUtil.gteSpark35()) { + // Spark 3.4 has no EXCEED_LIMIT_LENGTH error class and throws this plain RuntimeException. return new RuntimeException("Exceeds char/varchar type length limitation: " + limit, e); } + // Builds the exception QueryExecutionErrors.exceedMaxLimit builds, with the Velox error as its + // cause. SparkRuntimeException's cause can only be set through its constructor. + return new SparkRuntimeException( + "EXCEED_LIMIT_LENGTH", + Map$.MODULE$.empty().updated("limit", limit), + e, + new QueryContext[0], + ""); } @Override From 21eef10b5427ae59dffd53637ce0db70445efa5e Mon Sep 17 00:00:00 2001 From: Pedrum Jalali Date: Thu, 19 Nov 2026 16:57:48 -0800 Subject: [PATCH 4/4] Build the error's parameter map with Map.Map1 Map.Map1 is Scala's one-entry immutable map, and Java can create it directly, so the parameter map no longer goes through Map$.MODULE$. It also removes the unchecked warnings javac reported on the Scala 2.13 builds, where Map.updated reaches Java as a raw Map. Generated-by: Co-authored with Claude Code (claude-opus-5-5) --- .../gluten/vectorized/ColumnarBatchOutIterator.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gluten-arrow/src/main/java/org/apache/gluten/vectorized/ColumnarBatchOutIterator.java b/gluten-arrow/src/main/java/org/apache/gluten/vectorized/ColumnarBatchOutIterator.java index 4ed3f8ca963..ea6a0db843f 100644 --- a/gluten-arrow/src/main/java/org/apache/gluten/vectorized/ColumnarBatchOutIterator.java +++ b/gluten-arrow/src/main/java/org/apache/gluten/vectorized/ColumnarBatchOutIterator.java @@ -32,7 +32,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import scala.collection.immutable.Map$; +import scala.collection.immutable.Map; public class ColumnarBatchOutIterator extends ClosableIterator implements RuntimeAware { @@ -171,11 +171,7 @@ private static RuntimeException translateToCharVarcharLengthException(String msg // Builds the exception QueryExecutionErrors.exceedMaxLimit builds, with the Velox error as its // cause. SparkRuntimeException's cause can only be set through its constructor. return new SparkRuntimeException( - "EXCEED_LIMIT_LENGTH", - Map$.MODULE$.empty().updated("limit", limit), - e, - new QueryContext[0], - ""); + "EXCEED_LIMIT_LENGTH", new Map.Map1<>("limit", limit), e, new QueryContext[0], ""); } @Override