ryanrupp commented on a change in pull request #183: Fix reading of Iceberg 
Parquet write properties for row group, page a…
URL: https://github.com/apache/incubator-iceberg/pull/183#discussion_r282900032
 
 

 ##########
 File path: parquet/src/test/java/org/apache/iceberg/parquet/TestParquet.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.parquet;
+
+import com.google.common.collect.ImmutableMap;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.Function;
+import org.apache.avro.generic.GenericData;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.avro.AvroSchemaUtil;
+import org.apache.iceberg.types.Types.IntegerType;
+import org.apache.parquet.hadoop.ParquetFileReader;
+import org.apache.parquet.schema.MessageType;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.apache.iceberg.Files.localInput;
+import static org.apache.iceberg.TableProperties.PARQUET_ROW_GROUP_SIZE_BYTES;
+import static org.apache.iceberg.types.Types.NestedField.optional;
+
+public class TestParquet extends BaseParquetWritingTest {
+
+  @Test
+  public void testRowGroupSizeConfigurable() throws IOException {
+    // Without an explicit writer function
+    File parquetFile = generateFileWithTwoRowGroups(null);
+
+    try (ParquetFileReader reader = 
ParquetFileReader.open(ParquetIO.file(localInput(parquetFile)))) {
+      Assert.assertEquals(2, reader.getRowGroups().size());
+    }
+  }
+
+  @Test
+  public void testRowGroupSizeConfigurableWithWriter() throws IOException {
+    File parquetFile = 
generateFileWithTwoRowGroups(ParquetAvroWriter::buildWriter);
+
+    try (ParquetFileReader reader = 
ParquetFileReader.open(ParquetIO.file(localInput(parquetFile)))) {
+      Assert.assertEquals(2, reader.getRowGroups().size());
+    }
+  }
+
+  private File generateFileWithTwoRowGroups(Function<MessageType, 
ParquetValueWriter<?>> createWriterFunc)
 
 Review comment:
   Yeah I actually ran into this issue when writing a test for #132. I'll 
probably pull it down to the base class added here as part of the change of the 
change for #132. Not sure how generic it needs to be, the original test I wrote 
was the same logic basically and just validated the max int was 101 after the 
metrics rolled up row groups. Relies a bit on understanding the actual data 
being added e.g. originally I just set the rowGroup size to 1 byte and then 
internally there's another threshold to only check this every 100 records, 
there is some warning logging that happens though if after 100 records the 
bytes consumed are 3x the desired row group size (this is why I did int size * 
100) - it's just log noise though really.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to