nssalian commented on code in PR #16292: URL: https://github.com/apache/iceberg/pull/16292#discussion_r3335531026
########## 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 great call out. I was able to test this out as well. I added the fix and a test. Without the fix, I was able to reproduce the following: ``` TestSparkVariantRead > testVariantReadAfterDelete(boolean) > [2] true FAILED org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 10.0 failed 1 times, most recent failure: Lost task 0.0 in stage 10.0 (TID 9) (192.168.1.139 executor driver): java.lang.UnsupportedOperationException: Unsupported nested type: VariantType at org.apache.iceberg.spark.data.vectorized.ColumnVectorWithFilter.getChild(ColumnVectorWithFilter.java:147) ``` -- 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]
