|
| 1 | +/* |
| 2 | + * Copyright (c) 2025, NVIDIA CORPORATION. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.nvidia.spark.rapids.delta.delta33x |
| 18 | + |
| 19 | +import com.nvidia.spark.rapids.{DataFromReplacementRule, RapidsConf, RapidsMeta, RunnableCommandMeta} |
| 20 | +import com.nvidia.spark.rapids.delta.RapidsDeltaUtils |
| 21 | + |
| 22 | +import org.apache.spark.sql.delta.commands.{DeletionVectorUtils, UpdateCommand} |
| 23 | +import org.apache.spark.sql.delta.rapids.GpuDeltaLog |
| 24 | +import org.apache.spark.sql.delta.rapids.delta33x.GpuUpdateCommand |
| 25 | +import org.apache.spark.sql.delta.sources.DeltaSQLConf |
| 26 | +import org.apache.spark.sql.execution.command.RunnableCommand |
| 27 | + |
| 28 | +class UpdateCommandMeta( |
| 29 | + updateCmd: UpdateCommand, |
| 30 | + conf: RapidsConf, |
| 31 | + parent: Option[RapidsMeta[_, _, _]], |
| 32 | + rule: DataFromReplacementRule) |
| 33 | + extends RunnableCommandMeta[UpdateCommand](updateCmd, conf, parent, rule) { |
| 34 | + |
| 35 | + override def tagSelfForGpu(): Unit = { |
| 36 | + if (!conf.isDeltaWriteEnabled) { |
| 37 | + willNotWorkOnGpu("Delta Lake output acceleration has been disabled. To enable set " + |
| 38 | + s"${RapidsConf.ENABLE_DELTA_WRITE} to true") |
| 39 | + } |
| 40 | + |
| 41 | + val dvFeatureEnabled = DeletionVectorUtils.deletionVectorsWritable( |
| 42 | + updateCmd.tahoeFileIndex.deltaLog.unsafeVolatileSnapshot) |
| 43 | + |
| 44 | + if (dvFeatureEnabled && updateCmd.conf.getConf( |
| 45 | + DeltaSQLConf.DELETE_USE_PERSISTENT_DELETION_VECTORS)) { |
| 46 | + // https://github.com/NVIDIA/spark-rapids/issues/8554 |
| 47 | + willNotWorkOnGpu("Deletion vectors are not supported on GPU") |
| 48 | + } |
| 49 | + |
| 50 | + RapidsDeltaUtils.tagForDeltaWrite(this, updateCmd.target.schema, |
| 51 | + Some(updateCmd.tahoeFileIndex.deltaLog), |
| 52 | + Map.empty, updateCmd.tahoeFileIndex.spark) |
| 53 | + } |
| 54 | + |
| 55 | + override def convertToGpu(): RunnableCommand = { |
| 56 | + GpuUpdateCommand( |
| 57 | + new GpuDeltaLog(updateCmd.tahoeFileIndex.deltaLog, conf), |
| 58 | + updateCmd.tahoeFileIndex, |
| 59 | + updateCmd.catalogTable, |
| 60 | + updateCmd.target, |
| 61 | + updateCmd.updateExpressions, |
| 62 | + updateCmd.condition |
| 63 | + ) |
| 64 | + } |
| 65 | +} |
0 commit comments