rdblue commented on a change in pull request #131: Fix collection of bounds for 
small decimals in ParquetMetrics
URL: https://github.com/apache/incubator-iceberg/pull/131#discussion_r266665994
 
 

 ##########
 File path: 
parquet/src/test/java/com/netflix/iceberg/parquet/TestParquetMetrics.java
 ##########
 @@ -0,0 +1,214 @@
+/*
+ * 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 com.netflix.iceberg.parquet;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.netflix.iceberg.FileFormat;
+import com.netflix.iceberg.Metrics;
+import com.netflix.iceberg.Schema;
+import com.netflix.iceberg.avro.AvroSchemaUtil;
+import com.netflix.iceberg.io.FileAppender;
+import org.apache.avro.generic.GenericData;
+import org.apache.avro.generic.GenericData.Record;
+import org.apache.avro.generic.GenericFixed;
+import org.apache.commons.io.Charsets;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import java.io.File;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.util.Map;
+import java.util.UUID;
+
+import static com.netflix.iceberg.Files.localInput;
+import static com.netflix.iceberg.Files.localOutput;
+import static com.netflix.iceberg.types.Conversions.fromByteBuffer;
+import static com.netflix.iceberg.types.Types.*;
+import static com.netflix.iceberg.types.Types.NestedField.optional;
+import static com.netflix.iceberg.types.Types.NestedField.required;
+
+public class TestParquetMetrics {
+
+  @Rule
+  public TemporaryFolder temp = new TemporaryFolder();
+  private final UUID uuid = UUID.randomUUID();
+  private final GenericFixed fixed = new GenericData.Fixed(
+    org.apache.avro.Schema.createFixed("fixedCol", null, null, 4),
+    "abcd".getBytes(Charsets.UTF_8));
+
+  @Test
+  public void testMetricsForTopLevelFields() throws IOException {
+    Schema schema = new Schema(
+      optional(1, "booleanCol", BooleanType.get()),
+      required(2, "intCol", IntegerType.get()),
+      optional(3, "longCol", LongType.get()),
+      required(4, "floatCol", FloatType.get()),
+      optional(5, "doubleCol", DoubleType.get()),
+      optional(6, "decimalCol", DecimalType.of(10, 2)),
+      required(7, "stringCol", StringType.get()),
+      optional(8, "dateCol", DateType.get()),
+      required(9, "timeCol", TimeType.get()),
+      required(10, "timestampCol", TimestampType.withoutZone()),
+      optional(11, "uuidCol", UUIDType.get()),
+      required(12, "fixedCol", FixedType.ofLength(4)),
+      required(13, "binaryCol", BinaryType.get())
+    );
+
+    Record firstRecord = new Record(AvroSchemaUtil.convert(schema.asStruct()));
+    firstRecord.put("booleanCol", true);
+    firstRecord.put("intCol", 3);
+    firstRecord.put("longCol", 5L);
+    firstRecord.put("floatCol", 2.0F);
+    firstRecord.put("doubleCol", 2.0D);
+    firstRecord.put("decimalCol", new BigDecimal("3.50"));
 
 Review comment:
   The storage is determined by the decimal precision. Here's how we do it in 
other tests: 
https://github.com/apache/incubator-iceberg/blob/master/spark/src/test/java/com/netflix/iceberg/spark/data/AvroDataTest.java#L55-L57

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