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 19, 2024
1 parent 11cd4b1 commit d020ae1
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 12 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.sql.comet.shims.ShimCastOverflowException

class CastOverflowException(t: String, from: String, to: String)
extends ShimCastOverflowException(t, from, to) {}
Original file line number Diff line number Diff line change
Expand Up @@ -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))
) {}
Original file line number Diff line number Diff line change
@@ -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,
"") {}
Original file line number Diff line number Diff line change
@@ -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,
"") {}
Original file line number Diff line number Diff line change
@@ -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,
"") {}
2 changes: 1 addition & 1 deletion native/core/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ fn throw_exception(env: &mut JNIEnv, error: &CometError, backtrace: Option<Strin
}) => {
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()),
Expand Down

0 comments on commit d020ae1

Please sign in to comment.