From 2cc713679516cef4f79496d47993d8892c2ec7b0 Mon Sep 17 00:00:00 2001 From: Niranjan Artal <50492963+nartal1@users.noreply.github.com> Date: Fri, 3 Jun 2022 22:07:13 -0700 Subject: [PATCH] Spark-3.3 build fix - Move QueryExecutionErrors to sql package (#5742) This PR fixes #5739 As mentioned in the issue QueryExecutionErrors is changed to private scope now. Updated the code to fix build errors. Calling QueryExecutionErrors methods from org.apache.spark.sql scope. Signed-off-by: Niranjan Artal --- .../spark/rapids/shims/RapidsErrorUtils.scala | 12 ++--- .../sql/rapids/TrampolineErrorUtils.scala | 46 +++++++++++++++++++ 2 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 sql-plugin/src/main/330+/scala/org/apache/spark/sql/rapids/TrampolineErrorUtils.scala diff --git a/sql-plugin/src/main/330+/scala/com/nvidia/spark/rapids/shims/RapidsErrorUtils.scala b/sql-plugin/src/main/330+/scala/com/nvidia/spark/rapids/shims/RapidsErrorUtils.scala index 8a2e55df00a..b74c286bb78 100644 --- a/sql-plugin/src/main/330+/scala/com/nvidia/spark/rapids/shims/RapidsErrorUtils.scala +++ b/sql-plugin/src/main/330+/scala/com/nvidia/spark/rapids/shims/RapidsErrorUtils.scala @@ -17,16 +17,16 @@ package com.nvidia.spark.rapids.shims import org.apache.spark.sql.catalyst.trees.Origin -import org.apache.spark.sql.errors.QueryExecutionErrors +import org.apache.spark.sql.rapids.TrampolineErrorUtils import org.apache.spark.sql.types.DataType object RapidsErrorUtils { def invalidArrayIndexError(index: Int, numElements: Int, isElementAtF: Boolean = false): ArrayIndexOutOfBoundsException = { if (isElementAtF) { - QueryExecutionErrors.invalidElementAtIndexError(index, numElements) + TrampolineErrorUtils.invalidElementAtIndexError(index, numElements) } else { - QueryExecutionErrors.invalidArrayIndexError(index, numElements) + TrampolineErrorUtils.invalidArrayIndexError(index, numElements) } } @@ -34,7 +34,7 @@ object RapidsErrorUtils { key: String, keyType: DataType, origin: Origin): NoSuchElementException = { - QueryExecutionErrors.mapKeyNotExistError(key, keyType, origin.context) + TrampolineErrorUtils.mapKeyNotExistError(key, keyType, origin) } def sqlArrayIndexNotStartAtOneError(): ArrayIndexOutOfBoundsException = { @@ -42,10 +42,10 @@ object RapidsErrorUtils { } def divByZeroError(origin: Origin): ArithmeticException = { - QueryExecutionErrors.divideByZeroError(origin.context) + TrampolineErrorUtils.divByZeroError(origin) } def divOverflowError(origin: Origin): ArithmeticException = { - QueryExecutionErrors.overflowInIntegralDivideError(origin.context) + TrampolineErrorUtils.divOverflowError(origin) } } diff --git a/sql-plugin/src/main/330+/scala/org/apache/spark/sql/rapids/TrampolineErrorUtils.scala b/sql-plugin/src/main/330+/scala/org/apache/spark/sql/rapids/TrampolineErrorUtils.scala new file mode 100644 index 00000000000..400e0425fd0 --- /dev/null +++ b/sql-plugin/src/main/330+/scala/org/apache/spark/sql/rapids/TrampolineErrorUtils.scala @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022, NVIDIA CORPORATION. + * + * Licensed 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.rapids + +import org.apache.spark.sql.catalyst.trees.Origin +import org.apache.spark.sql.errors.QueryExecutionErrors +import org.apache.spark.sql.types.DataType + +object TrampolineErrorUtils { + def invalidElementAtIndexError(index: Int, numElements: Int) = { + QueryExecutionErrors.invalidElementAtIndexError(index, numElements) + } + + def invalidArrayIndexError(index: Int, numElements: Int) = { + QueryExecutionErrors.invalidArrayIndexError(index, numElements) + } + + def mapKeyNotExistError( + key: String, + keyType: DataType, + origin: Origin): NoSuchElementException = { + QueryExecutionErrors.mapKeyNotExistError(key, keyType, origin.context) + } + + def divByZeroError(origin: Origin): ArithmeticException = { + QueryExecutionErrors.divideByZeroError(origin.context) + } + + def divOverflowError(origin: Origin): ArithmeticException = { + QueryExecutionErrors.overflowInIntegralDivideError(origin.context) + } +}