diff --git a/common/src/main/scala/org/apache/spark/sql/comet/CometArithmeticException.scala b/common/src/main/scala/org/apache/spark/sql/comet/CometArithmeticException.scala new file mode 100644 index 000000000..41a671538 --- /dev/null +++ b/common/src/main/scala/org/apache/spark/sql/comet/CometArithmeticException.scala @@ -0,0 +1,25 @@ +/* + * 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.comet + +import org.apache.spark.SparkArithmeticException + +class CometArithmeticException(message: String) + extends SparkArithmeticException("CAST_OVERFLOW", Map(), Array(), message) {} diff --git a/dev/diffs/4.0.0-preview1.diff b/dev/diffs/4.0.0-preview1.diff index dfd57ce8f..dedf0bf1c 100644 --- a/dev/diffs/4.0.0-preview1.diff +++ b/dev/diffs/4.0.0-preview1.diff @@ -846,7 +846,7 @@ index 34c6c49bc49..f5dea07a213 100644 protected val baseResourcePath = { // use the same way as `SQLQueryTestSuite` to get the resource path diff --git a/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala -index 56c364e2084..11779ee3b4b 100644 +index 56c364e2084..fc3abd7cdc4 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala @@ -1510,7 +1510,8 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark @@ -889,16 +889,6 @@ index 56c364e2084..11779ee3b4b 100644 withSQLConf(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key -> "false", SQLConf.ANSI_ENABLED.key -> "true") { withTable("t") { -@@ -4639,7 +4643,8 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark - Row(1, 2, 3, 1, 2, 3, 1, 1)) - } - -- test("SPARK-40389: Don't eliminate a cast which can cause overflow") { -+ test("SPARK-40389: Don't eliminate a cast which can cause overflow", -+ IgnoreComet("TODO: https://github.com/apache/datafusion-comet/issues/551")) { - withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") { - withTable("dt") { - sql("create table dt using parquet as select 9000000000BD as d") diff --git a/sql/core/src/test/scala/org/apache/spark/sql/SubquerySuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/SubquerySuite.scala index 68f14f13bbd..4b8e967102f 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/SubquerySuite.scala diff --git a/native/core/src/errors.rs b/native/core/src/errors.rs index ff89e77d2..3f7ba0a21 100644 --- a/native/core/src/errors.rs +++ b/native/core/src/errors.rs @@ -234,6 +234,13 @@ impl jni::errors::ToException for CometError { class: "org/apache/comet/ParquetRuntimeException".to_string(), msg: self.to_string(), }, + CometError::DataFusion { + msg: _, + source: DataFusionError::External(e), + } if matches!(e.downcast_ref(), Some(SparkError::CastOverFlow { .. })) => Exception { + class: "org/apache/spark/sql/comet/CometArithmeticException".to_string(), + msg: self.to_string(), + }, _other => Exception { class: "org/apache/comet/CometNativeException".to_string(), msg: self.to_string(),