malinjawi commented on code in PR #12269: URL: https://github.com/apache/gluten/pull/12269#discussion_r3399433664
########## backends-velox/src-delta33/main/scala/org/apache/gluten/extension/PreprocessDeltaScanWithDeletionVectors.scala: ########## @@ -0,0 +1,36 @@ +/* + * 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.spark.sql.SparkSession +import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan +import org.apache.spark.sql.catalyst.rules.Rule +import org.apache.spark.sql.delta.GlutenPreprocessTableWithDVs + +/** + * Delta 3.3 compatibility rule for DV scan metadata. + * + * Delta's own PrepareDeltaScan still runs normally. This Gluten-scoped rule only adds the + * backend-visible DV metadata columns after Delta has prepared the scan, so the physical Delta scan + * handoff can materialize the per-file DV payload for Velox without replacing Delta classes. + */ +class PreprocessDeltaScanWithDeletionVectors(protected val spark: SparkSession) + extends Rule[LogicalPlan] + with GlutenPreprocessTableWithDVs { + + override def apply(plan: LogicalPlan): LogicalPlan = preprocessTablesWithDVs(plan) +} Review Comment: You didn't miss anything @zhztheplayer , I dug into this and the filter turned out to be unnecessary, so I just removed it. What I found: `injectOptimizerRule` rules run before `PrepareDeltaScan` (pre-CBO), so when this rule ran the scan still had a `TahoeLogFileIndex` and it bailed out — it was basically a no-op. The DV shape we actually see comes from Delta's own `PreprocessTableWithDVsStrategy` at planning time. From there, if the scan offloads, `nativeDeletionVectorRule` strips the skip-row column/filter and Velox does the filtering natively with the per-file mask. If it doesn't offload (`useMetadataRowIndex=false`, Spark < 3.5, or validation fails), the vanilla filter just runs on the JVM like before. Since the class is gone I put the input/output plan example on `nativeDeletionVectorRule` instead, that's where the rewrite actually happens now. Nice bonus: this also removes the `GlutenPreprocessTableWithDVs` copy from the shadowing discussion, so Delta 3.3 works the same way as Delta 4.0 in this PR now. -- 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]
