Skip to content

Commit e4f3ab7

Browse files
committed
Remove old Spark 3.3.1 through 3.4 shim sources
Signed-off-by: Gera Shegalov <gshegalov@nvidia.com>
1 parent b930032 commit e4f3ab7

30 files changed

Lines changed: 179 additions & 691 deletions

File tree

sql-plugin/src/main/spark331/scala/com/nvidia/spark/rapids/shims/Spark331PlusNonDBShims.scala

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,12 @@
4040
spark-rapids-shim-json-lines ***/
4141
package com.nvidia.spark.rapids.shims
4242

43-
import com.nvidia.spark.rapids.{ExprChecks, ExprRule, GpuCast, GpuExpression, GpuOverrides, TypeSig, UnaryExprMeta}
43+
import com.nvidia.spark.rapids.ExprRule
4444

45-
import org.apache.spark.sql.catalyst.expressions.{CheckOverflowInTableInsert, Expression}
46-
import org.apache.spark.sql.rapids.GpuCheckOverflowInTableInsert
45+
import org.apache.spark.sql.catalyst.expressions.Expression
4746

4847
trait Spark331PlusNonDBShims extends Spark330PlusNonDBShims {
4948
override def getExprs: Map[Class[_ <: Expression], ExprRule[_ <: Expression]] = {
50-
val map: Map[Class[_ <: Expression], ExprRule[_ <: Expression]] = Seq(
51-
// Add expression CheckOverflowInTableInsert starting Spark-3.3.1+
52-
// Accepts all types as input as the child Cast does the type checking and the calculations.
53-
GpuOverrides.expr[CheckOverflowInTableInsert](
54-
"Casting a numeric value as another numeric type in store assignment",
55-
ExprChecks.unaryProjectInputMatchesOutput(
56-
TypeSig.all,
57-
TypeSig.all),
58-
(t, conf, p, r) => new UnaryExprMeta[CheckOverflowInTableInsert](t, conf, p, r) {
59-
override def convertToGpu(child: Expression): GpuExpression = {
60-
child match {
61-
case c: GpuCast => GpuCheckOverflowInTableInsert(c, t.columnName)
62-
case _ =>
63-
throw new IllegalStateException("Expression child is not of Type GpuCast")
64-
}
65-
}
66-
})
67-
).map(r => (r.getClassFor.asSubclass(classOf[Expression]), r)).toMap
68-
super.getExprs ++ map
49+
super.getExprs ++ CheckOverflowInTableInsertShims.exprs
6950
}
7051
}

sql-plugin/src/main/spark331/scala/com/nvidia/spark/rapids/shims/SparkShims.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
2+
* Copyright (c) 2022-2026, NVIDIA CORPORATION.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,14 +24,15 @@ package com.nvidia.spark.rapids.shims
2424

2525
import com.nvidia.spark.rapids._
2626

27-
import org.apache.spark.sql.execution.command.{CreateDataSourceTableAsSelectCommand, DataWritingCommand, RunnableCommand}
27+
import org.apache.spark.sql.execution.command.{DataWritingCommand, RunnableCommand}
2828

2929
object SparkShimImpl extends Spark331PlusNonDBShims with AnsiCastRuleShims {
3030
override def getDataWriteCmds: Map[Class[_ <: DataWritingCommand],
3131
DataWritingCommandRule[_ <: DataWritingCommand]] = {
32-
Seq(GpuOverrides.dataWriteCmd[CreateDataSourceTableAsSelectCommand](
33-
"Create table with select command",
34-
(a, conf, p, r) => new CreateDataSourceTableAsSelectCommandMeta(a, conf, p, r))
32+
Seq(
33+
GpuOverrides.dataWriteCmdFromShim(
34+
CreateDataSourceTableAsSelectRules.dataWriteCmd,
35+
(a, conf, p, r) => new CreateDataSourceTableAsSelectCommandMeta(a, conf, p, r))
3536
).map(r => (r.getClassFor.asSubclass(classOf[DataWritingCommand]), r)).toMap
3637
}
3738

sql-plugin/src/main/spark331/scala/com/nvidia/spark/rapids/shims/spark331/SparkShimServiceProvider.scala

Lines changed: 0 additions & 36 deletions
This file was deleted.

sql-plugin/src/main/spark332/scala/com/nvidia/spark/rapids/shims/spark332/SparkShimServiceProvider.scala

Lines changed: 0 additions & 36 deletions
This file was deleted.

sql-plugin/src/main/spark332db/scala/com/nvidia/spark/rapids/shims/Spark332PlusDBShims.scala

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ import com.nvidia.spark.rapids._
2626

2727
import org.apache.spark.sql.catalyst.expressions._
2828
import org.apache.spark.sql.execution.SparkPlan
29-
import org.apache.spark.sql.execution.command.{CreateDataSourceTableAsSelectCommand, DataWritingCommand, RunnableCommand}
30-
import org.apache.spark.sql.execution.datasources._
29+
import org.apache.spark.sql.execution.command.{DataWritingCommand, RunnableCommand}
3130

3231
trait Spark332PlusDBShims extends Spark330PlusDBShims {
3332
// AnsiCast is removed from Spark3.4.0
@@ -47,19 +46,8 @@ trait Spark332PlusDBShims extends Spark330PlusDBShims {
4746
super.getExprs ++ shimExprs
4847
}
4948

50-
private val shimExecs: Map[Class[_ <: SparkPlan], ExecRule[_ <: SparkPlan]] = Seq(
51-
GpuOverrides.exec[WriteFilesExec](
52-
"v1 write files",
53-
// WriteFilesExec always has patterns:
54-
// InsertIntoHadoopFsRelationCommand(WriteFilesExec) or InsertIntoHiveTable(WriteFilesExec)
55-
// The parent node of `WriteFilesExec` will check the types, here just let type check pass
56-
ExecChecks(TypeSig.all, TypeSig.all),
57-
(write, conf, p, r) => new GpuWriteFilesMeta(write, conf, p, r)
58-
)
59-
).map(r => (r.getClassFor.asSubclass(classOf[SparkPlan]), r)).toMap
60-
6149
override def getExecs: Map[Class[_ <: SparkPlan], ExecRule[_ <: SparkPlan]] =
62-
super.getExecs ++ shimExecs
50+
super.getExecs ++ WriteFilesExecRule.execs
6351

6452
override def getDataWriteCmds: Map[Class[_ <: DataWritingCommand],
6553
DataWritingCommandRule[_ <: DataWritingCommand]] = {
@@ -71,8 +59,8 @@ trait Spark332PlusDBShims extends Spark330PlusDBShims {
7159
override def getRunnableCmds: Map[Class[_ <: RunnableCommand],
7260
RunnableCommandRule[_ <: RunnableCommand]] = {
7361
Seq(
74-
GpuOverrides.runnableCmd[CreateDataSourceTableAsSelectCommand](
75-
"Write to a data source",
62+
GpuOverrides.runnableCmdFromShim(
63+
CreateDataSourceTableAsSelectRules.runnableCmd,
7664
(a, conf, p, r) => new CreateDataSourceTableAsSelectCommandMeta(a, conf, p, r))
7765
).map(r => (r.getClassFor.asSubclass(classOf[RunnableCommand]), r)).toMap
7866
}

sql-plugin/src/main/spark332db/scala/org/apache/spark/sql/rapids/shims/SparkUpgradeExceptionShims.scala renamed to sql-plugin/src/main/spark332db/scala/com/nvidia/spark/rapids/shims/WriteFilesExecRule.scala

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022-2026, NVIDIA CORPORATION.
2+
* Copyright (c) 2026, NVIDIA CORPORATION.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,25 +38,25 @@
3838
{"spark": "402"}
3939
{"spark": "411"}
4040
spark-rapids-shim-json-lines ***/
41-
package org.apache.spark.sql.rapids.shims
41+
package com.nvidia.spark.rapids.shims
4242

43-
import org.apache.spark.SparkUpgradeException
43+
import com.nvidia.spark.rapids.{ExecChecks, ExecRule, GpuOverrides, TypeSig}
4444

45-
object SparkUpgradeExceptionShims {
45+
import org.apache.spark.sql.execution.SparkPlan
46+
import org.apache.spark.sql.execution.datasources.GpuWriteFilesMeta
4647

47-
def newSparkUpgradeException(
48-
version: String,
49-
message: String,
50-
cause: Throwable): SparkUpgradeException = {
51-
new SparkUpgradeException(
52-
"INCONSISTENT_BEHAVIOR_CROSS_VERSION",
53-
Map(version -> message),
54-
cause)
55-
}
56-
57-
// Used in tests to compare the class seen in an exception to
58-
// `SparkUpgradeException` which is private in Spark
59-
def getSparkUpgradeExceptionClass: Class[_] = {
60-
classOf[SparkUpgradeException]
48+
object WriteFilesExecRule {
49+
val execs: Map[Class[_ <: SparkPlan], ExecRule[_ <: SparkPlan]] = {
50+
Seq(
51+
GpuOverrides.execFromShim(
52+
WriteFilesExecShims.exec,
53+
// WriteFilesExec always has patterns:
54+
// InsertIntoHadoopFsRelationCommand(WriteFilesExec) or
55+
// InsertIntoHiveTable(WriteFilesExec)
56+
// The parent node of `WriteFilesExec` will check the types, here just let type check pass.
57+
ExecChecks(TypeSig.all, TypeSig.all),
58+
(write, conf, p, r) => new GpuWriteFilesMeta(write, conf, p, r)
59+
)
60+
).map(r => (r.getClassFor.asSubclass(classOf[SparkPlan]), r)).toMap
6161
}
6262
}

sql-plugin/src/main/spark332db/scala/com/nvidia/spark/rapids/shims/spark332db/SparkShimServiceProvider.scala

Lines changed: 0 additions & 37 deletions
This file was deleted.

sql-plugin/src/main/spark332db/scala/org/apache/spark/sql/hive/rapids/shims/HiveFileUtil.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,15 @@ import scala.util.control.NonFatal
4545
import org.apache.hadoop.conf.Configuration
4646
import org.apache.hadoop.fs.Path
4747

48-
import org.apache.spark.internal.Logging
48+
object HiveFileUtil {
49+
private val log = org.slf4j.LoggerFactory.getLogger(HiveFileUtil.getClass)
50+
51+
private def logWarning(msg: => String): Unit = {
52+
if (log.isWarnEnabled) {
53+
log.warn(msg)
54+
}
55+
}
4956

50-
object HiveFileUtil extends Logging {
5157

5258
// prior to Spark 3.4.0, this method was accessible via the SaveAsHiveFile trait, but
5359
// was removed in https://github.com/apache/spark/pull/39277

sql-plugin/src/main/spark332db/scala/org/apache/spark/sql/rapids/GpuFileFormatWriter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ trait GpuFileFormatWriterBase extends Serializable with Logging {
533533
private def verifySchema(format: ColumnarFileFormat, schema: StructType): Unit = {
534534
schema.foreach { field =>
535535
if (!format.supportDataType(field.dataType)) {
536-
throw new RapidsAnalysisException(
536+
throw RapidsAnalysisException(
537537
s"$format data source does not support ${field.dataType.catalogString} data type.")
538538
}
539539
}

sql-plugin/src/main/spark332db/scala/org/apache/spark/sql/rapids/shims/SparkDateTimeExceptionShims.scala

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)