diff --git a/common/src/main/scala/org/apache/spark/sql/comet/CastOverflowException.scala b/common/src/main/scala/org/apache/spark/sql/comet/CastOverflowException.scala new file mode 100644 index 000000000..a5d674de2 --- /dev/null +++ b/common/src/main/scala/org/apache/spark/sql/comet/CastOverflowException.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.sql.comet.shims.ShimCastOverflowException + +class CastOverflowException(t: String, from: String, to: String) + extends ShimCastOverflowException(t, from, to) {} diff --git a/common/src/main/scala/org/apache/spark/sql/comet/CometCastOverflowException.scala b/common/src/main/spark-3.3/org/apache/spark/sql/comet/shims/ShimCastOverflowException.scala similarity index 72% rename from common/src/main/scala/org/apache/spark/sql/comet/CometCastOverflowException.scala rename to common/src/main/spark-3.3/org/apache/spark/sql/comet/shims/ShimCastOverflowException.scala index 93b633307..43a4bff9c 100644 --- a/common/src/main/scala/org/apache/spark/sql/comet/CometCastOverflowException.scala +++ b/common/src/main/spark-3.3/org/apache/spark/sql/comet/shims/ShimCastOverflowException.scala @@ -17,19 +17,16 @@ * under the License. */ -package org.apache.spark.sql.comet +package org.apache.spark.sql.comet.shims import org.apache.spark.SparkArithmeticException import org.apache.spark.sql.errors.QueryExecutionErrors.toSQLConf import org.apache.spark.sql.internal.SQLConf -class CometCastOverflowException(t: String, from: String, to: String) - extends SparkArithmeticException( - "CAST_OVERFLOW", - Map( - "value" -> t, - "sourceType" -> from, - "targetType" -> to, - "ansiConfig" -> toSQLConf(SQLConf.ANSI_ENABLED.key)), - Array.empty, - "") {} +// TODO: Only the Spark 3.3 version of this class is different from the others. +// Remove this class after dropping Spark 3.3 support. +class ShimCastOverflowException(t: String, from: String, to: String) + extends SparkArithmeticException( + "CAST_OVERFLOW", + Array(t, from, to, toSQLConf(SQLConf.ANSI_ENABLED.key)) + ) {} diff --git a/common/src/main/spark-3.4/org/apache/spark/sql/comet/shims/ShimCastOverflowException.scala b/common/src/main/spark-3.4/org/apache/spark/sql/comet/shims/ShimCastOverflowException.scala new file mode 100644 index 000000000..c27335321 --- /dev/null +++ b/common/src/main/spark-3.4/org/apache/spark/sql/comet/shims/ShimCastOverflowException.scala @@ -0,0 +1,37 @@ +/* + * 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.shims + +import org.apache.spark.SparkArithmeticException +import org.apache.spark.sql.errors.QueryExecutionErrors.toSQLConf +import org.apache.spark.sql.internal.SQLConf + +// TODO: Only the Spark 3.3 version of this class is different from the others. +// Remove this class after dropping Spark 3.3 support. +class ShimCastOverflowException(t: String, from: String, to: String) + extends SparkArithmeticException( + "CAST_OVERFLOW", + Map( + "value" -> t, + "sourceType" -> from, + "targetType" -> to, + "ansiConfig" -> toSQLConf(SQLConf.ANSI_ENABLED.key)), + Array.empty, + "") {} diff --git a/common/src/main/spark-3.5/org/apache/spark/sql/comet/shims/ShimCastOverflowException.scala b/common/src/main/spark-3.5/org/apache/spark/sql/comet/shims/ShimCastOverflowException.scala new file mode 100644 index 000000000..c27335321 --- /dev/null +++ b/common/src/main/spark-3.5/org/apache/spark/sql/comet/shims/ShimCastOverflowException.scala @@ -0,0 +1,37 @@ +/* + * 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.shims + +import org.apache.spark.SparkArithmeticException +import org.apache.spark.sql.errors.QueryExecutionErrors.toSQLConf +import org.apache.spark.sql.internal.SQLConf + +// TODO: Only the Spark 3.3 version of this class is different from the others. +// Remove this class after dropping Spark 3.3 support. +class ShimCastOverflowException(t: String, from: String, to: String) + extends SparkArithmeticException( + "CAST_OVERFLOW", + Map( + "value" -> t, + "sourceType" -> from, + "targetType" -> to, + "ansiConfig" -> toSQLConf(SQLConf.ANSI_ENABLED.key)), + Array.empty, + "") {} diff --git a/common/src/main/spark-4.0/org/apache/spark/sql/comet/shims/ShimCastOverflowException.scala b/common/src/main/spark-4.0/org/apache/spark/sql/comet/shims/ShimCastOverflowException.scala new file mode 100644 index 000000000..c27335321 --- /dev/null +++ b/common/src/main/spark-4.0/org/apache/spark/sql/comet/shims/ShimCastOverflowException.scala @@ -0,0 +1,37 @@ +/* + * 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.shims + +import org.apache.spark.SparkArithmeticException +import org.apache.spark.sql.errors.QueryExecutionErrors.toSQLConf +import org.apache.spark.sql.internal.SQLConf + +// TODO: Only the Spark 3.3 version of this class is different from the others. +// Remove this class after dropping Spark 3.3 support. +class ShimCastOverflowException(t: String, from: String, to: String) + extends SparkArithmeticException( + "CAST_OVERFLOW", + Map( + "value" -> t, + "sourceType" -> from, + "targetType" -> to, + "ansiConfig" -> toSQLConf(SQLConf.ANSI_ENABLED.key)), + Array.empty, + "") {} diff --git a/native/core/src/errors.rs b/native/core/src/errors.rs index f0e910f75..3ed402d1a 100644 --- a/native/core/src/errors.rs +++ b/native/core/src/errors.rs @@ -395,7 +395,7 @@ fn throw_exception(env: &mut JNIEnv, error: &CometError, backtrace: Option { let throwable: JThrowable = env .new_object( - "org/apache/spark/sql/comet/CometCastOverflowException", + "org/apache/spark/sql/comet/CastOverflowException", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", &[ JValue::Object(&env.new_string(value).unwrap()),