Copilot commented on code in PR #12269:
URL: https://github.com/apache/gluten/pull/12269#discussion_r3391405209


##########
gluten-substrait/src/main/java/org/apache/gluten/substrait/rel/DeltaLocalFilesNode.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * 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.substrait.rel;
+
+import com.google.protobuf.ByteString;
+import io.substrait.proto.ReadRel;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class DeltaLocalFilesNode extends LocalFilesNode {
+  private final List<DeltaFileReadOptions> deltaReadOptions = new 
ArrayList<>();
+
+  DeltaLocalFilesNode(
+      Integer index,
+      List<String> paths,
+      List<Long> starts,
+      List<Long> lengths,
+      List<Long> fileSizes,
+      List<Long> modificationTimes,
+      List<Map<String, String>> partitionColumns,
+      List<Map<String, String>> metadataColumns,
+      ReadFileFormat fileFormat,
+      List<String> preferredLocations,
+      Map<String, String> properties,
+      List<Map<String, Object>> otherMetadataColumns,
+      List<DeltaFileReadOptions> deltaReadOptions) {
+    super(
+        index,
+        paths,
+        starts,
+        lengths,
+        fileSizes,
+        modificationTimes,
+        partitionColumns,
+        metadataColumns,
+        fileFormat,
+        preferredLocations,
+        properties,
+        otherMetadataColumns);
+    this.deltaReadOptions.addAll(deltaReadOptions);
+  }

Review Comment:
   DeltaLocalFilesNode assumes deltaReadOptions is non-null and has the same 
cardinality as paths; otherwise processFileBuilder can throw 
(NPE/IndexOutOfBounds) at runtime. Since this is a public node type, it should 
defensively validate inputs and fail fast with a clear error.



##########
gluten-delta/src/main/scala/org/apache/gluten/extension/DeltaPostTransformRules.scala:
##########
@@ -273,20 +372,9 @@ object DeltaPostTransformRules {
       scanExecTransformer.copyTagsFrom(plan)
       tagColumnMappingRule(scanExecTransformer)
 
-      // Alias physical names back to logical names. For struct-typed columns, 
Delta column
-      // mapping renames internal field names to physical UUIDs. A top-level 
Alias only restores
-      // the column name, not the struct's internal field names. We rebuild 
the struct with
-      // logical field names using positional extraction 
(GetStructField/CreateNamedStruct)
-      // instead of Cast, so correctness does not depend on any Velox cast 
config.
-      val expr = columnMappings.map {
-        cm =>
-          val projectedExpr: Expression =
-            if (nestedFieldNamesDiffer(cm.logicalType, 
cm.physicalAttr.dataType)) {
-              reconcileFieldNames(cm.physicalAttr, cm.logicalType, 
cm.physicalAttr.dataType)
-            } else {
-              cm.physicalAttr
-            }
-          Alias(projectedExpr, cm.logicalName)(exprId = cm.physicalAttr.exprId)
+      // alias physicalName into tableName
+      val expr = (transformedAttrs, originColumnNames).zipped.map {
+        (attr, columnName) => Alias(attr, columnName)(exprId = attr.exprId)
       }
       val projectExecTransformer = ProjectExecTransformer(expr.toSeq, 
scanExecTransformer)

Review Comment:
   Delta Column Mapping: the new alias-back projection only restores the 
*top-level* column name, but it no longer reconciles nested struct field names 
(Delta column mapping can rename nested struct fields to physical UUIDs). This 
can break downstream Spark expressions that access nested fields by name (e.g., 
col("s.a")). The previous implementation rebuilt structs via positional 
GetStructField/CreateNamedStruct to restore logical nested names; that logic 
appears to have been removed here and should be reinstated (or an equivalent 
nested-field reconciliation added) when logical vs physical nested field names 
differ.



##########
cpp/velox/compute/VeloxPlanConverter.cc:
##########
@@ -48,6 +53,80 @@ VeloxPlanConverter::VeloxPlanConverter(
 }
 
 namespace {
+std::optional<std::string> unpackMetadataValue(const google::protobuf::Any& 
value) {
+  google::protobuf::BytesValue bytesValue;
+  if (value.UnpackTo(&bytesValue)) {
+    return bytesValue.value();
+  }
+
+  google::protobuf::StringValue stringValue;
+  if (value.UnpackTo(&stringValue)) {
+    return stringValue.value();
+  }
+
+  google::protobuf::Int32Value int32Value;
+  if (value.UnpackTo(&int32Value)) {
+    return std::to_string(int32Value.value());
+  }
+
+  google::protobuf::Int64Value int64Value;
+  if (value.UnpackTo(&int64Value)) {
+    return std::to_string(int64Value.value());
+  }
+
+  google::protobuf::DoubleValue doubleValue;
+  if (value.UnpackTo(&doubleValue)) {
+    return std::to_string(doubleValue.value());
+  }
+
+  return std::nullopt;
+}

Review Comment:
   unpackMetadataValue ignores google.protobuf.BoolValue (and will silently 
drop boolean entries from other_const_metadata_columns). Since LocalFilesNode 
encodes arbitrary JVM metadata via Any wrappers, missing BoolValue support can 
cause metadata loss and hard-to-debug behavior differences.



-- 
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