pvary commented on code in PR #17610:
URL: https://github.com/apache/iceberg/pull/17610#discussion_r4324696935


##########
spark/v4.2/spark/src/test/java/org/apache/iceberg/spark/data/TestSparkVectorizedFormatModel.java:
##########
@@ -0,0 +1,142 @@
+/*
+ * 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;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import org.apache.arrow.vector.ValueVector;
+import org.apache.iceberg.FileFormat;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.data.DataGenerators;
+import org.apache.iceberg.data.ReadFormatModelTests;
+import org.apache.iceberg.data.Record;
+import org.apache.iceberg.spark.SparkSchemaUtil;
+import org.apache.iceberg.spark.SparkUtil;
+import org.apache.iceberg.spark.data.vectorized.IcebergArrowColumnVector;
+import org.apache.iceberg.types.Type;
+import org.apache.spark.sql.vectorized.ColumnarBatch;
+import org.junit.jupiter.params.provider.Arguments;
+
+class TestSparkVectorizedFormatModel extends 
ReadFormatModelTests<ColumnarBatch> {
+
+  private static final FileFormat[] FILE_FORMATS = {FileFormat.ORC, 
FileFormat.PARQUET};
+
+  private static final List<Arguments> FORMAT_AND_GENERATOR =
+      Arrays.stream(FILE_FORMATS)
+          .flatMap(
+              format ->
+                  Arrays.stream(DataGenerators.ALL)
+                      .filter(generator -> supportsGenerator(format, 
generator))
+                      .map(generator -> Arguments.of(format, generator)))
+          .toList();
+
+  private static final Set<Type.TypeID> UNSUPPORTED_TYPE_IDS =
+      Set.of(
+          Type.TypeID.TIME,
+          Type.TypeID.TIMESTAMP_NANO,
+          Type.TypeID.STRUCT,
+          Type.TypeID.LIST,
+          Type.TypeID.MAP,
+          Type.TypeID.UUID,
+          Type.TypeID.GEOMETRY,
+          Type.TypeID.GEOGRAPHY);
+
+  @Override
+  protected Collection<Type.TypeID> unsupportedTypeIds() {
+    return UNSUPPORTED_TYPE_IDS;
+  }
+
+  @Override
+  protected boolean supportsBatchReads() {
+    return true;
+  }
+
+  @Override
+  protected int countRows(List<ColumnarBatch> batches) {
+    return batches.stream().mapToInt(ColumnarBatch::numRows).sum();
+  }
+
+  @Override
+  protected void assertContainersReused(ColumnarBatch first, ColumnarBatch 
second) {
+    assertThat(second.numCols()).isEqualTo(first.numCols());
+
+    for (int i = 0; i < first.numCols(); i++) {
+      assertThat(arrowVector(second, i)).isSameAs(arrowVector(first, i));
+    }
+  }
+
+  private ValueVector arrowVector(ColumnarBatch batch, int col) {
+    IcebergArrowColumnVector vector = (IcebergArrowColumnVector) 
batch.column(col);

Review Comment:
   Are we sure about this? At least an instanceof please



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