-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bobby Wang <[email protected]>
- Loading branch information
Showing
8 changed files
with
268 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...ugin/src/main/301+-nondb/scala/com/nvidia/spark/rapids/shims/v2/TypeSigUtilUntil320.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright (c) 2021, 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 com.nvidia.spark.rapids.shims.v2 | ||
|
||
import com.nvidia.spark.rapids.{TypeEnum, TypeSig, TypeSigUtil} | ||
|
||
import org.apache.spark.sql.types.DataType | ||
|
||
/** | ||
* This TypeSigUtil is for [spark 3.0.1, spark 3.2.0) | ||
*/ | ||
object TypeSigUtilUntil320 extends TypeSigUtil { | ||
/** | ||
* Check if this type of Spark-specific is supported by the plugin or not. | ||
* | ||
* @param check the Supported Types | ||
* @param dataType the data type to be checked | ||
* @param allowDecimal whether decimal support is enabled or not | ||
* @return true if it is allowed else false. | ||
*/ | ||
override def isSupported( | ||
check: TypeEnum.ValueSet, | ||
dataType: DataType, | ||
allowDecimal: Boolean): Boolean = false | ||
|
||
/** | ||
* Get all supported types for the spark-specific | ||
* | ||
* @return the all supported typ | ||
*/ | ||
override def getAllSupportedTypes(): TypeEnum.ValueSet = | ||
TypeEnum.values - TypeEnum.DAYTIME - TypeEnum.YEARMONTH | ||
|
||
/** | ||
* Return the reason why this type is not supported.\ | ||
* | ||
* @param check the Supported Types | ||
* @param dataType the data type to be checked | ||
* @param allowDecimal whether decimal support is enabled or not | ||
* @param notSupportedReason the reason for not supporting | ||
* @return the reason | ||
*/ | ||
override def reasonNotSupported( | ||
check: TypeEnum.ValueSet, | ||
dataType: DataType, | ||
allowDecimal: Boolean, notSupportedReason: Seq[String]): Seq[String] = notSupportedReason | ||
|
||
/** | ||
* Get checks from TypeEnum | ||
* | ||
* @param from the TypeEnum to be matched | ||
* @return the TypeSigs | ||
*/ | ||
override def getCastChecksAndSigs(from: TypeEnum.Value): (TypeSig, TypeSig) = | ||
throw new RuntimeException("Unsupported " + from) | ||
|
||
/** | ||
* Get TypeSigs from DataType | ||
* | ||
* @param from the data type to be matched | ||
* @param default the default TypeSig | ||
* @param sparkDefault the default Spark TypeSig | ||
* @return the TypeSigs | ||
*/ | ||
override def getCastChecksAndSigs( | ||
from: DataType, | ||
default: TypeSig, | ||
sparkDefault: TypeSig): (TypeSig, TypeSig) = (default, sparkDefault) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 0 additions & 75 deletions
75
sql-plugin/src/main/320/scala/com/nvidia/spark/rapids/shims/v2/TypeSig320.scala
This file was deleted.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
sql-plugin/src/main/320/scala/com/nvidia/spark/rapids/shims/v2/TypeSigUtilFrom320.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright (c) 2021, 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 com.nvidia.spark.rapids.shims.v2 | ||
|
||
import com.nvidia.spark.rapids.{TypeEnum, TypeSig, TypeSigUtil} | ||
|
||
import org.apache.spark.sql.types.{DataType, DayTimeIntervalType, YearMonthIntervalType} | ||
|
||
/** | ||
* Add DayTimeIntervalType and YearMonthIntervalType support | ||
*/ | ||
object TypeSigUtilFrom320 extends TypeSigUtil { | ||
|
||
override def isSupported( | ||
check: TypeEnum.ValueSet, | ||
dataType: DataType, | ||
allowDecimal: Boolean): Boolean = { | ||
dataType match { | ||
case _: DayTimeIntervalType => check.contains(TypeEnum.DAYTIME) | ||
case _: YearMonthIntervalType => check.contains(TypeEnum.YEARMONTH) | ||
case _ => false | ||
} | ||
} | ||
|
||
override def getAllSupportedTypes(): TypeEnum.ValueSet = TypeEnum.values | ||
|
||
override def reasonNotSupported( | ||
check: TypeEnum.ValueSet, | ||
dataType: DataType, | ||
allowDecimal: Boolean, | ||
notSupportedReason: Seq[String]): Seq[String] = { | ||
dataType match { | ||
case _: DayTimeIntervalType => | ||
if (check.contains(TypeEnum.DAYTIME)) Seq.empty else notSupportedReason | ||
case _: YearMonthIntervalType => | ||
if (check.contains(TypeEnum.YEARMONTH)) Seq.empty else notSupportedReason | ||
case _ => notSupportedReason | ||
} | ||
} | ||
|
||
override def getCastChecksAndSigs( | ||
from: DataType, | ||
default: TypeSig, | ||
sparkDefault: TypeSig): (TypeSig, TypeSig) = { | ||
from match { | ||
case _: DayTimeIntervalType => (daytimeChecks, sparkDaytimeSig) | ||
case _: YearMonthIntervalType =>(yearmonthChecks, sparkYearmonthSig) | ||
case _ => (default, sparkDefault) | ||
} | ||
} | ||
|
||
override def getCastChecksAndSigs(from: TypeEnum.Value): (TypeSig, TypeSig) = { | ||
from match { | ||
case TypeEnum.DAYTIME => (daytimeChecks, sparkDaytimeSig) | ||
case TypeEnum.YEARMONTH => (yearmonthChecks, sparkYearmonthSig) | ||
} | ||
} | ||
|
||
def daytimeChecks: TypeSig = TypeSig.none | ||
def sparkDaytimeSig: TypeSig = TypeSig.DAYTIME + TypeSig.STRING | ||
|
||
def yearmonthChecks: TypeSig = TypeSig.none | ||
def sparkYearmonthSig: TypeSig = TypeSig.YEARMONTH + TypeSig.STRING | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.