liuneng1994 commented on code in PR #13379:
URL: https://github.com/apache/gluten/pull/13379#discussion_r4345085014


##########
backends-bolt/src-delta/main/scala/org/apache/gluten/extension/BoltOffloadDeltaScan.scala:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.gluten.extension
+
+import org.apache.gluten.extension.columnar.FallbackTags
+import org.apache.gluten.extension.columnar.offload.OffloadSingleNode
+
+import org.apache.spark.sql.delta.files.{TahoeBatchFileIndex, TahoeFileIndex, 
TahoeRemoveFileIndex}
+import org.apache.spark.sql.delta.stats.PreparedDeltaFileIndex
+import org.apache.spark.sql.execution.{FileSourceScanExec, SparkPlan}
+
+/** Keeps actual Delta deletion-vector reads on Spark until Bolt supports the 
DV split protocol. */
+case class BoltOffloadDeltaScan() extends OffloadSingleNode {
+  private val delegate = OffloadDeltaScan(enableNativeDmlRowIndexScan = true)

Review Comment:
   `enableNativeDmlRowIndexScan` is hardcoded to `true`, while Velox derives it 
from `new VeloxDeltaConfig(c.sqlConf).enableNativeDmlRowIndexScan` 
(`VeloxDeltaComponent.scala:56-58`). Since this delegate is only reached for 
DV-free scans, `true` may be fine, but please state the rationale (or add a 
Bolt config) so the divergence is intentional.



##########
backends-bolt/src-delta/main/scala/org/apache/gluten/extension/BoltOffloadDeltaScan.scala:
##########
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.gluten.extension
+
+import org.apache.gluten.extension.columnar.FallbackTags
+import org.apache.gluten.extension.columnar.offload.OffloadSingleNode
+
+import org.apache.spark.sql.delta.files.{TahoeBatchFileIndex, TahoeFileIndex, 
TahoeRemoveFileIndex}
+import org.apache.spark.sql.delta.stats.PreparedDeltaFileIndex
+import org.apache.spark.sql.execution.{FileSourceScanExec, SparkPlan}
+
+/** Keeps actual Delta deletion-vector reads on Spark until Bolt supports the 
DV split protocol. */
+case class BoltOffloadDeltaScan() extends OffloadSingleNode {
+  private val delegate = OffloadDeltaScan(enableNativeDmlRowIndexScan = true)
+
+  override def offload(plan: SparkPlan): SparkPlan = plan match {
+    case scan: FileSourceScanExec if readsDeletionVector(scan) =>
+      FallbackTags.add(scan, "Bolt does not support native Delta 
deletion-vector reads")
+      scan
+    case other => delegate.offload(other)
+  }
+
+  private def readsDeletionVector(scan: FileSourceScanExec): Boolean = {
+    scan.relation.location match {
+      case index: TahoeRemoveFileIndex =>
+        index.filesByVersion.exists(_.actions.exists(_.deletionVector != null))
+      case index: PreparedDeltaFileIndex =>
+        index.preparedScan.files.exists(_.deletionVector != null)
+      case index: TahoeBatchFileIndex =>
+        index.addFiles.exists(_.deletionVector != null)
+      case index: TahoeFileIndex =>
+        index.matchingFiles(scan.partitionFilters, scan.dataFilters)

Review Comment:
   `matchingFiles(...)` enumerates the Delta log on the driver for every 
`FileSourceScanExec` during offload. On large tables this duplicates the 
listing Spark will do later and can be a noticeable planning-time cost. Could 
this reuse the scan's already-resolved files, or be cached per 
`TahoeFileIndex`? Please also confirm `matchingFiles` is safe for every 
`TahoeFileIndex` subclass that can reach this branch.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to