-
Notifications
You must be signed in to change notification settings - Fork 303
[FEA] Add GPU low shuffle merge for Databricks 17.3 [databricks] #15916
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
26ed958
bb6859a
5ce3e91
125c827
671d38a
2fb0190
08b4e1e
15ddbd1
46a9e4c
9c3acce
a8ed9be
b873db0
3dfbd2d
a18416c
6b69ead
45a7bc3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| package com.nvidia.spark.rapids.delta | ||
|
|
||
| import java.net.URI | ||
| import java.util.UUID | ||
| import java.util.concurrent.ConcurrentHashMap | ||
|
|
||
| import org.apache.spark.broadcast.Broadcast | ||
|
|
||
| /** Driver-side information needed to build a low-shuffle target scan. */ | ||
| case class GpuLowShuffleMergeScanInfo( | ||
| rowIndexMaps: Option[Broadcast[Map[URI, Array[Byte]]]]) | ||
|
|
||
| /** | ||
| * Bridges information created by the low-shuffle command into Delta file-format conversion. | ||
| * Only a small opaque ID is placed in the logical relation. The broadcast itself is attached to | ||
| * the GPU file format when the scan is converted and is therefore sent to executors normally. | ||
| */ | ||
| object GpuLowShuffleMergeScanRegistry { | ||
| val OPTION_KEY: String = "spark.rapids.internal.delta.lowShuffleMerge.scanId" | ||
|
|
||
| private val scans = new ConcurrentHashMap[String, GpuLowShuffleMergeScanInfo]() | ||
|
|
||
| def register(info: GpuLowShuffleMergeScanInfo): String = { | ||
| val id = UUID.randomUUID().toString | ||
| scans.put(id, info) | ||
| id | ||
| } | ||
|
|
||
| def lookup(options: Map[String, String]): Option[GpuLowShuffleMergeScanInfo] = { | ||
| options.get(OPTION_KEY).flatMap(id => Option(scans.get(id))) | ||
| } | ||
|
|
||
| def remove(id: String): Unit = scans.remove(id) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,8 @@ package com.nvidia.spark.rapids.delta.shims | |
| import com.databricks.sql.transaction.tahoe.DeltaLog | ||
| import com.databricks.sql.transaction.tahoe.commands.{DeletionVectorUtils, MergeIntoCommand, | ||
| MergeIntoCommandBase, MergeIntoCommandEdge} | ||
| import com.databricks.sql.transaction.tahoe.rapids.{GpuDeltaLog, GpuMergeIntoCommand} | ||
| import com.databricks.sql.transaction.tahoe.rapids.{GpuDeltaLog, GpuLowShuffleMergeCommand, | ||
| GpuMergeIntoCommand} | ||
| import com.databricks.sql.transaction.tahoe.sources.DeltaSQLConf | ||
| import com.nvidia.spark.rapids.{RapidsConf, RapidsMeta} | ||
| import com.nvidia.spark.rapids.delta.{MergeIntoCommandEdgeMeta, MergeIntoCommandMeta} | ||
|
|
@@ -59,38 +60,71 @@ object MergeIntoCommandMetaShim { | |
| } | ||
|
|
||
| def convertToGpu(mergeCmd: MergeIntoCommand, conf: RapidsConf): RunnableCommand = { | ||
| GpuMergeIntoCommand( | ||
| mergeCmd.source, | ||
| mergeCmd.target, | ||
| mergeCmd.catalogTable, | ||
| mergeCmd.targetFileIndex, | ||
| new GpuDeltaLog(mergeCmd.targetFileIndex.deltaLog, conf), | ||
| mergeCmd.condition, | ||
| mergeCmd.matchedClauses, | ||
| mergeCmd.notMatchedClauses, | ||
| mergeCmd.notMatchedBySourceClauses, | ||
| mergeCmd.migratedSchema, | ||
| mergeCmd.trackHighWaterMarks, | ||
| mergeCmd.schemaEvolutionEnabled)(conf) | ||
| if (conf.isDeltaLowShuffleMergeEnabled && conf.isParquetPerFileReadEnabled) { | ||
| GpuLowShuffleMergeCommand( | ||
| mergeCmd.source, | ||
| mergeCmd.target, | ||
| mergeCmd.catalogTable, | ||
| mergeCmd.targetFileIndex, | ||
| new GpuDeltaLog(mergeCmd.targetFileIndex.deltaLog, conf), | ||
| mergeCmd.condition, | ||
| mergeCmd.matchedClauses, | ||
| mergeCmd.notMatchedClauses, | ||
| mergeCmd.notMatchedBySourceClauses, | ||
| mergeCmd.migratedSchema, | ||
| mergeCmd.trackHighWaterMarks, | ||
| mergeCmd.schemaEvolutionEnabled)(conf) | ||
|
Comment on lines
58
to
+73
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Rule Used: Report Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| } else { | ||
| GpuMergeIntoCommand( | ||
| mergeCmd.source, | ||
| mergeCmd.target, | ||
| mergeCmd.catalogTable, | ||
| mergeCmd.targetFileIndex, | ||
| new GpuDeltaLog(mergeCmd.targetFileIndex.deltaLog, conf), | ||
| mergeCmd.condition, | ||
| mergeCmd.matchedClauses, | ||
| mergeCmd.notMatchedClauses, | ||
| mergeCmd.notMatchedBySourceClauses, | ||
| mergeCmd.migratedSchema, | ||
| mergeCmd.trackHighWaterMarks, | ||
| mergeCmd.schemaEvolutionEnabled)(conf) | ||
| } | ||
| } | ||
|
|
||
| def convertToGpu(mergeCmd: MergeIntoCommandEdge, conf: RapidsConf): RunnableCommand = { | ||
| GpuMergeIntoCommand( | ||
| mergeCmd.source, | ||
| mergeCmd.target, | ||
| mergeCmd.catalogTable, | ||
| mergeCmd.targetFileIndex, | ||
| new GpuDeltaLog(mergeCmd.targetFileIndex.deltaLog, conf), | ||
| mergeCmd.condition, | ||
| mergeCmd.matchedClauses, | ||
| mergeCmd.notMatchedClauses, | ||
| mergeCmd.notMatchedBySourceClauses, | ||
| mergeCmd.migratedSchema, | ||
| mergeCmd.trackHighWaterMarks, | ||
| mergeCmd.schemaEvolutionEnabled, | ||
| // This is safe to forward as-is because DBR analysis has already encoded snapshot reuse | ||
| // eligibility in this Option: Some(snapshot) means the Edge command may reuse the analyzed | ||
| // snapshot, while None makes GpuDeltaLog open the transaction on the latest snapshot. | ||
| mergeCmd.snapshotAtAnalysis)(conf) | ||
| if (conf.isDeltaLowShuffleMergeEnabled && conf.isParquetPerFileReadEnabled) { | ||
| GpuLowShuffleMergeCommand( | ||
| mergeCmd.source, | ||
| mergeCmd.target, | ||
| mergeCmd.catalogTable, | ||
| mergeCmd.targetFileIndex, | ||
| new GpuDeltaLog(mergeCmd.targetFileIndex.deltaLog, conf), | ||
| mergeCmd.condition, | ||
| mergeCmd.matchedClauses, | ||
| mergeCmd.notMatchedClauses, | ||
| mergeCmd.notMatchedBySourceClauses, | ||
| mergeCmd.migratedSchema, | ||
| mergeCmd.trackHighWaterMarks, | ||
| mergeCmd.schemaEvolutionEnabled, | ||
| mergeCmd.snapshotAtAnalysis)(conf) | ||
| } else { | ||
| GpuMergeIntoCommand( | ||
| mergeCmd.source, | ||
| mergeCmd.target, | ||
| mergeCmd.catalogTable, | ||
| mergeCmd.targetFileIndex, | ||
| new GpuDeltaLog(mergeCmd.targetFileIndex.deltaLog, conf), | ||
| mergeCmd.condition, | ||
| mergeCmd.matchedClauses, | ||
| mergeCmd.notMatchedClauses, | ||
| mergeCmd.notMatchedBySourceClauses, | ||
| mergeCmd.migratedSchema, | ||
| mergeCmd.trackHighWaterMarks, | ||
| mergeCmd.schemaEvolutionEnabled, | ||
| // This is safe to forward as-is because DBR analysis has already encoded snapshot reuse | ||
| // eligibility in this Option: Some(snapshot) means the Edge command may reuse the analyzed | ||
| // snapshot, while None makes GpuDeltaLog open the transaction on the latest snapshot. | ||
| mergeCmd.snapshotAtAnalysis)(conf) | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.