huaxingao commented on code in PR #16292:
URL: https://github.com/apache/iceberg/pull/16292#discussion_r3327007024


##########
spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/data/vectorized/VariantColumnVector.java:
##########
@@ -0,0 +1,141 @@
+/*
+ * 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.iceberg.spark.data.vectorized;
+
+import org.apache.iceberg.arrow.vectorized.VectorHolder;
+import org.apache.spark.sql.types.DataTypes;
+import org.apache.spark.sql.types.Decimal;
+import org.apache.spark.sql.vectorized.ColumnVector;
+import org.apache.spark.sql.vectorized.ColumnarArray;
+import org.apache.spark.sql.vectorized.ColumnarMap;
+import org.apache.spark.unsafe.types.UTF8String;
+
+public class VariantColumnVector extends ColumnVector {
+  private final ColumnVector valueChild;
+  private final ColumnVector metadataChild;
+
+  VariantColumnVector(VectorHolder.VariantVectorHolder holder) {
+    super(DataTypes.VariantType);
+    this.valueChild = new IcebergArrowColumnVector(holder.valueHolder());
+    this.metadataChild = new IcebergArrowColumnVector(holder.metadataHolder());
+  }
+
+  @Override
+  public void close() {
+    valueChild.close();
+    metadataChild.close();
+  }
+
+  @Override
+  public void closeIfFreeable() {
+    // See SPARK-50235, SPARK-50463
+  }
+
+  @Override
+  public boolean hasNull() {
+    return valueChild.hasNull();
+  }
+
+  @Override
+  public int numNulls() {
+    return valueChild.numNulls();
+  }
+
+  @Override
+  public boolean isNullAt(int rowId) {
+    return valueChild.isNullAt(rowId);
+  }
+
+  // getChild is what getVariant() calls: child(0) = value, child(1) = metadata
+  @Override
+  public ColumnVector getChild(int ordinal) {
+    if (ordinal == 0) {

Review Comment:
   This is a real bug. When a batch has deletes, BaseBatchReader wraps every 
column (including this VariantColumnVector) in ColumnVectorWithFilter, whose 
getChild only handles StructType and throws for variant. So a v3 table with a 
variant column and a DV/position/equality delete will fail with vectorization 
on. We should extend ColumnVectorWithFilter.getChild to handle VariantType and 
add a variant + deletes test.



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