manishmalhotrawork commented on a change in pull request #365: test cases for 
parquetMetrics with multiple rowgroup
URL: https://github.com/apache/incubator-iceberg/pull/365#discussion_r312770851
 
 

 ##########
 File path: core/src/test/java/org/apache/iceberg/TestMetrics.java
 ##########
 @@ -270,6 +276,141 @@ public void testMetricsForNullColumns() throws 
IOException {
     assertBounds(1, IntegerType.get(), null, null, metrics);
   }
 
+  @Test
+  public void testMetricsForTopLevelWithMultipleRG() throws Exception {
+    Schema schema = getSimpleSchema();
+    int minimumRowGroupRecordCount = 100;
+    List<GenericData.Record> records = new ArrayList<>(201);
+
+    GenericData.Record firstRecord = new 
GenericData.Record(AvroSchemaUtil.convert(schema.asStruct()));
+    firstRecord.put("booleanCol", true);
+    firstRecord.put("intCol", 1);
+    // adding 1st element as null
+    firstRecord.put("longCol", null);
+    firstRecord.put("floatCol", 1.0F);
+    // adding 1st element as null
+    firstRecord.put("doubleCol", null);
+    // adding 1st element as null
+    firstRecord.put("decimalCol", null);
+    firstRecord.put("stringCol", "AAA");
+    firstRecord.put("dateCol", 1);
+    firstRecord.put("timeCol", 1L);
+    firstRecord.put("timestampCol", 1L);
+    firstRecord.put("uuidCol", uuid);
+    firstRecord.put("fixedCol", fixed);
+    firstRecord.put("binaryCol", "S".getBytes());
+    records.add(firstRecord);
+
+    for (int i = 0; i < minimumRowGroupRecordCount * 2; i++) {
+      GenericData.Record newRecord = new 
GenericData.Record(AvroSchemaUtil.convert(schema.asStruct()));
+      newRecord.put("booleanCol", false);
+      newRecord.put("intCol", i + 1);
+      newRecord.put("longCol", i + 1L);
+      newRecord.put("floatCol", i + 1.0F);
+      newRecord.put("doubleCol", i + 1.0D);
+      newRecord.put("decimalCol", new BigDecimal(i + "").add(new 
BigDecimal("1.00")));
+      newRecord.put("stringCol", "AAA");
+      newRecord.put("dateCol", i + 1);
+      newRecord.put("timeCol", i + 1L);
+      newRecord.put("timestampCol", i + 1L);
+      newRecord.put("uuidCol", uuid);
+      newRecord.put("fixedCol", fixed);
+      newRecord.put("binaryCol", "S".getBytes());
+      records.add(newRecord);
+    }
+
+    // create parquet file with multiple row groups. by using smaller number 
of bytes
+    File parquetFile = writeRecords(
+        schema,
+        ImmutableMap.of(PARQUET_ROW_GROUP_SIZE_BYTES, 
Integer.toString(minimumRowGroupRecordCount * Integer.BYTES)),
+        records.toArray(new GenericData.Record[] {}));
+
+    Assert.assertNotNull(parquetFile);
+    // rowgroup size should be > 1
+    Assert.assertEquals(3, getRowGroupSize(parquetFile));
+
+    Metrics metrics = getMetrics(localInput(parquetFile));
+    Assert.assertEquals(201L, (long) metrics.recordCount());
+    assertCounts(1, 201L, 0L, metrics);
+    assertBounds(1, Types.BooleanType.get(), false, true, metrics);
+    assertBounds(2, Types.IntegerType.get(), 1, 200, metrics);
+    assertCounts(3, 201L, 1L, metrics);
+    assertBounds(3, Types.LongType.get(), 1L, 200L, metrics);
+    assertCounts(4, 201L, 0L, metrics);
+    assertBounds(4, Types.FloatType.get(), 1.0F, 200.0F, metrics);
+    assertCounts(5, 201L, 1L, metrics);
+    assertBounds(5, Types.DoubleType.get(), 1.0D, 200.0D, metrics);
+    assertCounts(6, 201L, 1L, metrics);
+    assertBounds(6, Types.DecimalType.of(10, 2), new BigDecimal("1.00"),
+        new BigDecimal("200.00"), metrics);
+  }
+
+  @Test
+  public void testMetricsForNestedStructFieldsWithMultipleRG() throws 
IOException {
+    StructType leafStructType = getLeafStructType();
 
 Review comment:
   refactored as per suggestion, please check.

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