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


##########
spark/v4.2/spark/src/test/java/org/apache/iceberg/spark/data/TestSparkVectorizedFormatModel.java:
##########
@@ -0,0 +1,200 @@
+/*
+ * 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 static org.assertj.core.api.Assumptions.assumeThat;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+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.DataGenerator;
+import org.apache.iceberg.data.DataGenerators;
+import org.apache.iceberg.data.ReadFormatModelTests;
+import org.apache.iceberg.data.Record;
+import org.apache.iceberg.io.CloseableIterable;
+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.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.FieldSource;
+
+class TestSparkVectorizedFormatModel extends 
ReadFormatModelTests<ColumnarBatch> {
+
+  private static final FileFormat[] FILE_FORMATS = {FileFormat.ORC, 
FileFormat.PARQUET};
+
+  // Spark has no TIME or TIMESTAMP_NANO type. The Arrow-based Parquet reader 
also cannot read
+  // nested or geospatial columns, the vectorized ORC reader can.

Review Comment:
   No sorry, ORC doesn’t support geospatial, hence it isn’t tested. Fixed the 
comment.



##########
spark/v4.2/spark/src/test/java/org/apache/iceberg/spark/data/TestSparkVectorizedFormatModel.java:
##########
@@ -0,0 +1,200 @@
+/*
+ * 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 static org.assertj.core.api.Assumptions.assumeThat;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+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.DataGenerator;
+import org.apache.iceberg.data.DataGenerators;
+import org.apache.iceberg.data.ReadFormatModelTests;
+import org.apache.iceberg.data.Record;
+import org.apache.iceberg.io.CloseableIterable;
+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.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.FieldSource;
+
+class TestSparkVectorizedFormatModel extends 
ReadFormatModelTests<ColumnarBatch> {
+
+  private static final FileFormat[] FILE_FORMATS = {FileFormat.ORC, 
FileFormat.PARQUET};
+
+  // Spark has no TIME or TIMESTAMP_NANO type. The Arrow-based Parquet reader 
also cannot read
+  // nested or geospatial columns, the vectorized ORC reader can.
+  private static final Map<FileFormat, Set<Type.TypeID>> UNSUPPORTED_TYPE_IDS =
+      Map.of(
+          FileFormat.ORC,
+          Set.of(Type.TypeID.TIME, Type.TypeID.TIMESTAMP_NANO),
+          FileFormat.PARQUET,
+          Set.of(
+              Type.TypeID.TIME,
+              Type.TypeID.TIMESTAMP_NANO,
+              Type.TypeID.STRUCT,
+              Type.TypeID.LIST,
+              Type.TypeID.MAP,
+              Type.TypeID.GEOMETRY,
+              Type.TypeID.GEOGRAPHY));
+
+  private static final List<Arguments> FORMAT_AND_GENERATOR =
+      Arrays.stream(FILE_FORMATS)
+          .flatMap(
+              format ->
+                  Arrays.stream(DataGenerators.ALL)
+                      .filter(generator -> supportsVectorized(format, 
generator))
+                      .map(generator -> Arguments.of(format, generator)))
+          .toList();
+
+  private static boolean supportsVectorized(FileFormat format, DataGenerator 
generator) {
+    return supportsGenerator(format, generator)
+        && !containsType(generator.schema(), UNSUPPORTED_TYPE_IDS.get(format));

Review Comment:
   Went with your second option. Filtering `TIME` per column 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]

Reply via email to