Skip to content

Commit

Permalink
Spark-3.3 build fix - Move QueryExecutionErrors to sql package (#5742)
Browse files Browse the repository at this point in the history
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 <nartal@nvidia.com>
  • Loading branch information
nartal1 authored Jun 4, 2022
1 parent ee638d5 commit 2cc7136
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@
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)
}
}

def mapKeyNotExistError(
key: String,
keyType: DataType,
origin: Origin): NoSuchElementException = {
QueryExecutionErrors.mapKeyNotExistError(key, keyType, origin.context)
TrampolineErrorUtils.mapKeyNotExistError(key, keyType, origin)
}

def sqlArrayIndexNotStartAtOneError(): ArrayIndexOutOfBoundsException = {
new ArrayIndexOutOfBoundsException("SQL array indices start at 1")
}

def divByZeroError(origin: Origin): ArithmeticException = {
QueryExecutionErrors.divideByZeroError(origin.context)
TrampolineErrorUtils.divByZeroError(origin)
}

def divOverflowError(origin: Origin): ArithmeticException = {
QueryExecutionErrors.overflowInIntegralDivideError(origin.context)
TrampolineErrorUtils.divOverflowError(origin)
}
}
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit 2cc7136

Please sign in to comment.