Skip to content

Commit

Permalink
fix: Spark-4.0 SparkArithmeticException
Browse files Browse the repository at this point in the history
  • Loading branch information
kazuyukitanimura committed Jul 18, 2024
1 parent 64b5f3c commit 94afd51
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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) {}
12 changes: 1 addition & 11 deletions dev/diffs/4.0.0-preview1.diff
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions native/core/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 94afd51

Please sign in to comment.