-
Notifications
You must be signed in to change notification settings - Fork 288
Add Spark 3.3.0 SQL shim module sources #15043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gerashegalov
wants to merge
1
commit into
codex/unshim-stack-02b-fileio
from
codex/unshim-stack-02c-shims-330
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
sql-plugin-shims/src/main/scala/org/apache/spark/sql/errors/ConvUtils.scala
This file contains hidden or 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,40 @@ | ||
| /* | ||
| * Copyright (c) 2025-2026, 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.errors | ||
|
|
||
| import java.lang.reflect.InvocationTargetException | ||
|
|
||
| object ConvUtils { | ||
| private val queryExecutionErrorsCompanion = | ||
| "org.apache.spark.sql.errors.QueryExecutionErrors$" | ||
|
|
||
| def overflowInConvError(): Unit = { | ||
| try { | ||
| val companion = Class.forName(queryExecutionErrorsCompanion).getField("MODULE$").get(null) | ||
| val method = companion.getClass.getMethods.find { method => | ||
| method.getName == "overflowInConvError" && method.getParameterCount == 1 | ||
| }.getOrElse { | ||
| throw new UnsupportedOperationException() | ||
| } | ||
| throw method.invoke(companion, null.asInstanceOf[AnyRef]).asInstanceOf[Throwable] | ||
| } catch { | ||
| case _: ClassNotFoundException | _: NoSuchFieldException => | ||
| throw new UnsupportedOperationException() | ||
| case e: InvocationTargetException => | ||
| throw e.getCause | ||
| } | ||
| } | ||
| } | ||
42 changes: 42 additions & 0 deletions
42
sql-plugin-shims/src/main/scala/org/apache/spark/sql/rapids/shims/SparkSessionUtils.scala
This file contains hidden or 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,42 @@ | ||
| /* | ||
| * Copyright (c) 2025-2026, 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.shims | ||
|
|
||
| import java.lang.reflect.InvocationTargetException | ||
|
|
||
| import org.apache.spark.sql.SparkSession | ||
| import org.apache.spark.sql.execution.SparkPlan | ||
|
|
||
| object SparkSessionUtils { | ||
|
|
||
| def sessionFromPlan(plan: SparkPlan): SparkSession = { | ||
| invokeNoArg(plan, "session").asInstanceOf[SparkSession] | ||
| } | ||
|
|
||
| def leafNodeDefaultParallelism(ss: SparkSession): Int = { | ||
| invokeNoArg(ss, "leafNodeDefaultParallelism").asInstanceOf[Int] | ||
| } | ||
|
|
||
| private def invokeNoArg(target: AnyRef, methodName: String): AnyRef = { | ||
| try { | ||
| target.getClass.getMethod(methodName).invoke(target) | ||
| } catch { | ||
| case e: InvocationTargetException => | ||
| throw e.getCause | ||
| } | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
...ain/spark330/scala/com/nvidia/spark/rapids/shims/CreateDataSourceTableAsSelectRules.scala
This file contains hidden or 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,35 @@ | ||
| /* | ||
| * Copyright (c) 2026, 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. | ||
| */ | ||
|
|
||
| /*** spark-rapids-shim-json-lines | ||
| {"spark": "330"} | ||
| {"spark": "330db"} | ||
| {"spark": "331"} | ||
| {"spark": "332"} | ||
| {"spark": "333"} | ||
| {"spark": "334"} | ||
| spark-rapids-shim-json-lines ***/ | ||
| package com.nvidia.spark.rapids.shims | ||
|
|
||
| import com.nvidia.spark.rapids.ShimDataWritingCommandRule | ||
|
|
||
| import org.apache.spark.sql.execution.command.CreateDataSourceTableAsSelectCommand | ||
|
|
||
| object CreateDataSourceTableAsSelectRules { | ||
| val dataWriteCmd: ShimDataWritingCommandRule[CreateDataSourceTableAsSelectCommand] = | ||
| ShimDataWritingCommandRule[CreateDataSourceTableAsSelectCommand]( | ||
| "Create table with select command") | ||
| } |
41 changes: 41 additions & 0 deletions
41
...c/main/spark330/scala/com/nvidia/spark/rapids/shims/SequenceSizeTooLongErrorBuilder.scala
This file contains hidden or 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,41 @@ | ||
| /* | ||
| * Copyright (c) 2024-2026, 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. | ||
| */ | ||
|
|
||
| /*** spark-rapids-shim-json-lines | ||
| {"spark": "330"} | ||
| {"spark": "330db"} | ||
| {"spark": "331"} | ||
| {"spark": "332"} | ||
| {"spark": "332db"} | ||
| {"spark": "333"} | ||
| {"spark": "340"} | ||
| {"spark": "341"} | ||
| {"spark": "341db"} | ||
| {"spark": "350"} | ||
| {"spark": "350db143"} | ||
| spark-rapids-shim-json-lines ***/ | ||
| package org.apache.spark.sql.rapids.shims | ||
|
|
||
| import org.apache.spark.unsafe.array.ByteArrayMethods.MAX_ROUNDED_ARRAY_LENGTH | ||
|
|
||
| trait SequenceSizeTooLongErrorBuilder { | ||
|
|
||
| def getTooLongSequenceErrorString(sequenceSize: Int, functionName: String): String = { | ||
| // For these Spark versions, the sequence length and function name | ||
| // do not appear in the exception message. | ||
| s"Too long sequence found. Should be <= $MAX_ROUNDED_ARRAY_LENGTH" | ||
| } | ||
| } |
36 changes: 36 additions & 0 deletions
36
...main/spark330/scala/com/nvidia/spark/rapids/shims/spark330/SparkShimServiceProvider.scala
This file contains hidden or 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,36 @@ | ||
| /* | ||
| * Copyright (c) 2021-2026, 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. | ||
| */ | ||
|
|
||
| /*** spark-rapids-shim-json-lines | ||
| {"spark": "330"} | ||
| spark-rapids-shim-json-lines ***/ | ||
| package com.nvidia.spark.rapids.shims.spark330 | ||
|
|
||
| import com.nvidia.spark.rapids.SparkShimVersion | ||
|
|
||
| object SparkShimServiceProvider { | ||
| val VERSION = SparkShimVersion(3, 3, 0) | ||
| val VERSIONNAMES = Seq(s"$VERSION") | ||
| } | ||
|
|
||
| class SparkShimServiceProvider extends com.nvidia.spark.rapids.SparkShimServiceProvider { | ||
|
|
||
| override def getShimVersion: SparkShimVersion = SparkShimServiceProvider.VERSION | ||
|
|
||
| def matchesVersion(version: String): Boolean = { | ||
| SparkShimServiceProvider.VERSIONNAMES.contains(version) | ||
| } | ||
| } |
71 changes: 71 additions & 0 deletions
71
...lugin-shims/src/main/spark330/scala/org/apache/spark/sql/rapids/ShuffleManagerShims.scala
This file contains hidden or 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,71 @@ | ||
| /* | ||
| * Copyright (c) 2026, 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. | ||
| */ | ||
|
|
||
| /*** spark-rapids-shim-json-lines | ||
| {"spark": "330"} | ||
| {"spark": "330db"} | ||
| {"spark": "331"} | ||
| {"spark": "332"} | ||
| {"spark": "332db"} | ||
| {"spark": "333"} | ||
| {"spark": "334"} | ||
| {"spark": "340"} | ||
| {"spark": "341"} | ||
| {"spark": "341db"} | ||
| {"spark": "342"} | ||
| {"spark": "343"} | ||
| {"spark": "344"} | ||
| {"spark": "350"} | ||
| {"spark": "350db143"} | ||
| {"spark": "351"} | ||
| {"spark": "352"} | ||
| {"spark": "353"} | ||
| {"spark": "354"} | ||
| {"spark": "355"} | ||
| {"spark": "356"} | ||
| {"spark": "357"} | ||
| {"spark": "358"} | ||
| {"spark": "400"} | ||
| {"spark": "401"} | ||
| {"spark": "402"} | ||
| {"spark": "411"} | ||
| spark-rapids-shim-json-lines ***/ | ||
| package org.apache.spark.sql.rapids | ||
|
|
||
| import org.apache.spark.TaskContext | ||
| import org.apache.spark.shuffle.{ShuffleHandle, ShuffleManager, ShuffleReader, ShuffleReadMetricsReporter} | ||
|
|
||
| /** | ||
| * Shim object to handle version-specific differences in ShuffleManager APIs. | ||
| */ | ||
| object ShuffleManagerShims { | ||
| /** | ||
| * Call ShuffleManager.getReader with the appropriate signature for this Spark version. | ||
| * This method is overridden in version-specific shims. | ||
| */ | ||
| def getReader[K, C]( | ||
| manager: ShuffleManager, | ||
| handle: ShuffleHandle, | ||
| startMapIndex: Int, | ||
| endMapIndex: Int, | ||
| startPartition: Int, | ||
| endPartition: Int, | ||
| context: TaskContext, | ||
| metrics: ShuffleReadMetricsReporter): ShuffleReader[K, C] = { | ||
| manager.getReader(handle, startMapIndex, endMapIndex, startPartition, | ||
| endPartition, context, metrics) | ||
| } | ||
| } |
79 changes: 79 additions & 0 deletions
79
...s/src/main/spark330/scala/org/apache/spark/sql/rapids/shims/FileCommitProtocolShims.scala
This file contains hidden or 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,79 @@ | ||
| /* | ||
| * Copyright (c) 2026, 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. | ||
| */ | ||
|
|
||
| /*** spark-rapids-shim-json-lines | ||
| {"spark": "330"} | ||
| {"spark": "330db"} | ||
| {"spark": "331"} | ||
| {"spark": "332"} | ||
| {"spark": "332db"} | ||
| {"spark": "333"} | ||
| {"spark": "334"} | ||
| {"spark": "340"} | ||
| {"spark": "341"} | ||
| {"spark": "341db"} | ||
| {"spark": "342"} | ||
| {"spark": "343"} | ||
| {"spark": "344"} | ||
| {"spark": "350"} | ||
| {"spark": "350db143"} | ||
| {"spark": "351"} | ||
| {"spark": "352"} | ||
| {"spark": "353"} | ||
| {"spark": "354"} | ||
| {"spark": "355"} | ||
| {"spark": "356"} | ||
| {"spark": "357"} | ||
| {"spark": "358"} | ||
| {"spark": "400"} | ||
| {"spark": "400db173"} | ||
| {"spark": "401"} | ||
| {"spark": "402"} | ||
| spark-rapids-shim-json-lines ***/ | ||
| package org.apache.spark.sql.rapids.shims | ||
|
|
||
| import org.apache.hadoop.mapreduce.TaskAttemptContext | ||
|
|
||
| import org.apache.spark.internal.io.FileCommitProtocol | ||
|
|
||
| /** | ||
| * Shim for FileCommitProtocol.newTaskTempFile API. | ||
| * In Spark <= 4.0.x, we use the deprecated (ext: String) signature. | ||
| * In Spark 4.1.0+, we use the new (spec: FileNameSpec) signature. | ||
| */ | ||
| object FileCommitProtocolShims { | ||
| @scala.annotation.nowarn( | ||
| "msg=method newTaskTempFile in class FileCommitProtocol is deprecated" | ||
| ) | ||
| def newTaskTempFile( | ||
| committer: FileCommitProtocol, | ||
| taskContext: TaskAttemptContext, | ||
| dir: Option[String], | ||
| ext: String): String = { | ||
| committer.newTaskTempFile(taskContext, dir, ext) | ||
| } | ||
|
|
||
| @scala.annotation.nowarn( | ||
| "msg=method newTaskTempFileAbsPath in class FileCommitProtocol is deprecated" | ||
| ) | ||
| def newTaskTempFileAbsPath( | ||
| committer: FileCommitProtocol, | ||
| taskContext: TaskAttemptContext, | ||
| absoluteDir: String, | ||
| ext: String): String = { | ||
| committer.newTaskTempFileAbsPath(taskContext, absoluteDir, ext) | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
...n-shims/src/main/spark330/scala/org/apache/spark/sql/rapids/shims/OriginContextShim.scala
This file contains hidden or 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,32 @@ | ||
| /* | ||
| * Copyright (c) 2026, 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. | ||
| */ | ||
|
|
||
| /*** spark-rapids-shim-json-lines | ||
| {"spark": "330"} | ||
| {"spark": "331"} | ||
| {"spark": "332"} | ||
| {"spark": "333"} | ||
| {"spark": "334"} | ||
| spark-rapids-shim-json-lines ***/ | ||
| package org.apache.spark.sql.rapids.shims | ||
|
|
||
| import org.apache.spark.sql.catalyst.trees.Origin | ||
|
|
||
| // Apache Spark 3.3.x carries SPARK-39175 with `Origin.context: String`. | ||
| object OriginContextShim { | ||
| def queryContext(origin: Origin): String = origin.context | ||
| def contextSummary(origin: Origin): String = origin.context | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nullpassed to unknown parameter typeThe code finds any
overflowInConvErroroverload with exactly one parameter and invokes it withnull. If that parameter is a primitive-boxed type, JVM unboxing will throw aNullPointerExceptioninsideinvoke, masking the intended error. Either matching the exact parameter type in thefindpredicate or adding a comment documenting the nullable assumption would reduce the ambiguity.