kbendick commented on a change in pull request #3723: URL: https://github.com/apache/iceberg/pull/3723#discussion_r767371571
########## File path: spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/data/TestParquetReader.java ########## @@ -0,0 +1,90 @@ +/* + * 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 java.io.IOException; +import java.util.List; +import org.apache.iceberg.Files; +import org.apache.iceberg.Schema; +import org.apache.iceberg.io.CloseableIterable; +import org.apache.iceberg.parquet.Parquet; +import org.apache.iceberg.relocated.com.google.common.collect.Lists; +import org.apache.iceberg.types.Types; +import org.apache.spark.sql.catalyst.InternalRow; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import static org.apache.iceberg.types.Types.NestedField.optional; + +public class TestParquetReader { + + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + + @Test + public void testParquet2LevelList() throws IOException { + Schema icebergSchema = new Schema( + optional(1, "key", Types.StringType.get()), + optional(2, "val", Types.ListType.ofRequired(3, Types.StructType.of( + optional(4, "a1", Types.StringType.get()), + optional(5, "a2", Types.StringType.get()) + ) + ))); + List<InternalRow> rows; + + /* Using a static file rather than generating test data in test, as parquet writers in Iceberg only supports + * three level lists. The twoLevelList.pq is a parquet file that contains following Parquet schema. + * message hive_schema { + * optional binary key (STRING); + * optional group val (LIST) { + * repeated group bag { + * optional group array_element { + * optional binary a1 (STRING); + * optional binary a2 (STRING); + * } + * } + * } + * } + * + * It contains only one row. Below is the json dump of the file. + * {"key":"k1","val":{"bag":[{"array_element":{"a1":"a","a2":"b"}}]}} + */ Review comment: I think your schema is off vs your JSON element: It looks like `val` should be a list, but val in the JSON is a struct. I might have that wrong though. I'm still working on a reproduction. -- 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]
