You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/12/07 18:42:47 UTC

[GitHub] [iceberg] stevenzwu opened a new pull request, #6377: Flink: add util class to generate test data with extensive coverage d…

stevenzwu opened a new pull request, #6377:
URL: https://github.com/apache/iceberg/pull/6377

   …ifferent field types: from primitives to complex nested types


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] stevenzwu commented on pull request #6377: Flink: add util class to generate test data with extensive coverage d…

Posted by GitBox <gi...@apache.org>.
stevenzwu commented on PR #6377:
URL: https://github.com/apache/iceberg/pull/6377#issuecomment-1341416995

   We had this util class internally for testing Avro GenericRecord to Flink RowData converter. It can be useful for writing unit test for the `StructRowData` class from PR #6222.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] stevenzwu commented on pull request #6377: Flink: add util class to generate test data with extensive coverage d…

Posted by GitBox <gi...@apache.org>.
stevenzwu commented on PR #6377:
URL: https://github.com/apache/iceberg/pull/6377#issuecomment-1345457933

   @hililiwei @chenjunjiedada don't want to use random data. The purpose of this util class is to generate Flink `RowData`, Iceberg `GenericRecord`, and Avro `GenericRecord` (internal code) with the same schema and values. Then we can compare the expected and actual values after applying converter. With random values, we can not do `assertEquals`. The goal the util class is to cover different field types (primitives and complex nested). Random values are really important for that purpose.
   
   ```
     protected void testConverter(DataGenerator dataGenerator) throws Exception {
       RowDataToAvroGenericRecordConverter converter =
           RowDataToAvroGenericRecordConverter.fromAvroSchema(dataGenerator.avroSchema());
       GenericRecord expected = dataGenerator.generateAvroGenericRecord();
       GenericRecord actual = converter.apply(dataGenerator.generateFlinkRowData());
       Assert.assertEquals(expected, actual);
     }
   ```


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] hililiwei commented on pull request #6377: Flink: add util class to generate test data with extensive coverage d…

Posted by GitBox <gi...@apache.org>.
hililiwei commented on PR #6377:
URL: https://github.com/apache/iceberg/pull/6377#issuecomment-1342356510

   > @hililiwei it will probably be easier if StructRowData implements equals method to compare with the expected value from data generators.
   
   Sounds great. I will try it ASAP. Thx.
   
   


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] stevenzwu commented on pull request #6377: Flink: add util class to generate test data with extensive coverage d…

Posted by GitBox <gi...@apache.org>.
stevenzwu commented on PR #6377:
URL: https://github.com/apache/iceberg/pull/6377#issuecomment-1348974325

   thanks @hililiwei and @pvary for reviewing. will follow up on Peter's comment with a separate PR


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] hililiwei commented on pull request #6377: Flink: add util class to generate test data with extensive coverage d…

Posted by GitBox <gi...@apache.org>.
hililiwei commented on PR #6377:
URL: https://github.com/apache/iceberg/pull/6377#issuecomment-1345189569

   Could we have a class that generates random data according to the schema passed in by user?


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] hililiwei commented on a diff in pull request #6377: Flink: add util class to generate test data with extensive coverage d…

Posted by GitBox <gi...@apache.org>.
hililiwei commented on code in PR #6377:
URL: https://github.com/apache/iceberg/pull/6377#discussion_r1045850345


##########
flink/v1.16/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java:
##########
@@ -0,0 +1,746 @@
+/*
+ * 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.flink;
+
+import static org.apache.iceberg.types.Types.NestedField.required;
+
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
+import org.apache.flink.table.data.DecimalData;
+import org.apache.flink.table.data.GenericArrayData;
+import org.apache.flink.table.data.GenericMapData;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.StringData;
+import org.apache.flink.table.data.TimestampData;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.data.GenericRecord;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.types.Types;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.joda.time.Days;
+
+/**
+ * Util class to generate test data with extensive coverage different field types: from primitives
+ * to complex nested types.
+ */
+public class DataGenerators {
+
+  public static class Primitives implements DataGenerator {
+    private static final DateTime JODA_DATETIME_EPOC =
+        new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
+    private static final DateTime JODA_DATETIME_20220110 =
+        new DateTime(2022, 1, 10, 0, 0, 0, 0, DateTimeZone.UTC);
+    private static final int DAYS_BTW_EPOC_AND_20220110 =
+        Days.daysBetween(JODA_DATETIME_EPOC, JODA_DATETIME_20220110).getDays();
+    private static final int HOUR_8_IN_MILLI = (int) TimeUnit.HOURS.toMillis(8);
+
+    private static final LocalDate JAVA_LOCAL_DATE_20220110 = LocalDate.of(2022, 1, 10);
+    private static final LocalTime JAVA_LOCAL_TIME_HOUR8 = LocalTime.of(8, 0);
+    private static final OffsetDateTime JAVA_OFFSET_DATE_TIME_20220110 =
+        OffsetDateTime.of(2022, 1, 10, 0, 0, 0, 0, ZoneOffset.UTC);
+    private static final LocalDateTime JAVA_LOCAL_DATE_TIME_20220110 =
+        LocalDateTime.of(2022, 1, 10, 0, 0, 0);

Review Comment:
   Add time to JAVA_LOCAL_DATE_TIME_20220110? 
   e.g. 
   ```
    private static final LocalDateTime JAVA_LOCAL_DATE_TIME_2022011008 =
           LocalDateTime.of(JAVA_LOCAL_DATE_20220110, JAVA_LOCAL_TIME_HOUR8);
   ```
   or
   ```
       private static final LocalDateTime JAVA_LOCAL_DATE_TIME_2022011008 =
           LocalDateTime.of(2022, 1, 10, 8, 0, 0);
   ```
   
   



##########
flink/v1.16/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java:
##########
@@ -0,0 +1,746 @@
+/*
+ * 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.flink;
+
+import static org.apache.iceberg.types.Types.NestedField.required;
+
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
+import org.apache.flink.table.data.DecimalData;
+import org.apache.flink.table.data.GenericArrayData;
+import org.apache.flink.table.data.GenericMapData;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.StringData;
+import org.apache.flink.table.data.TimestampData;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.data.GenericRecord;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.types.Types;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.joda.time.Days;
+
+/**
+ * Util class to generate test data with extensive coverage different field types: from primitives
+ * to complex nested types.
+ */
+public class DataGenerators {
+
+  public static class Primitives implements DataGenerator {
+    private static final DateTime JODA_DATETIME_EPOC =
+        new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
+    private static final DateTime JODA_DATETIME_20220110 =
+        new DateTime(2022, 1, 10, 0, 0, 0, 0, DateTimeZone.UTC);
+    private static final int DAYS_BTW_EPOC_AND_20220110 =
+        Days.daysBetween(JODA_DATETIME_EPOC, JODA_DATETIME_20220110).getDays();
+    private static final int HOUR_8_IN_MILLI = (int) TimeUnit.HOURS.toMillis(8);
+
+    private static final LocalDate JAVA_LOCAL_DATE_20220110 = LocalDate.of(2022, 1, 10);
+    private static final LocalTime JAVA_LOCAL_TIME_HOUR8 = LocalTime.of(8, 0);
+    private static final OffsetDateTime JAVA_OFFSET_DATE_TIME_20220110 =
+        OffsetDateTime.of(2022, 1, 10, 0, 0, 0, 0, ZoneOffset.UTC);
+    private static final LocalDateTime JAVA_LOCAL_DATE_TIME_20220110 =
+        LocalDateTime.of(2022, 1, 10, 0, 0, 0);
+
+    private final Schema icebergSchema =
+        new Schema(
+            Types.NestedField.required(1, "partition_field", Types.StringType.get()),
+            // primitive types
+            Types.NestedField.optional(2, "boolean_field", Types.BooleanType.get()),
+            Types.NestedField.optional(3, "int_field", Types.IntegerType.get()),
+            Types.NestedField.optional(4, "long_field", Types.LongType.get()),
+            Types.NestedField.optional(5, "float_field", Types.FloatType.get()),
+            Types.NestedField.optional(6, "double_field", Types.DoubleType.get()),
+            Types.NestedField.required(7, "string_field", Types.StringType.get()),
+            Types.NestedField.required(8, "date_field", Types.DateType.get()),
+            Types.NestedField.required(9, "time_field", Types.TimeType.get()),
+            Types.NestedField.required(10, "ts_with_zone_field", Types.TimestampType.withZone()),
+            Types.NestedField.required(
+                11, "ts_without_zone_field", Types.TimestampType.withoutZone()),
+            Types.NestedField.required(12, "uuid_field", Types.UUIDType.get()),
+            Types.NestedField.required(13, "binary_field", Types.BinaryType.get()),
+            Types.NestedField.required(14, "decimal_field", Types.DecimalType.of(9, 2)));
+
+    private final RowType flinkRowType = FlinkSchemaUtil.convert(icebergSchema);
+
+    @Override
+    public Schema icebergSchema() {
+      return icebergSchema;
+    }
+
+    @Override
+    public RowType flinkRowType() {
+      return flinkRowType;
+    }
+
+    @Override
+    public GenericRecord generateIcebergGenericRecord() {
+      GenericRecord genericRecord = GenericRecord.create(icebergSchema);
+      genericRecord.setField("partition_field", "partition_value");
+      genericRecord.setField("boolean_field", false);
+      genericRecord.setField("int_field", Integer.MAX_VALUE);
+      genericRecord.setField("long_field", Long.MAX_VALUE);
+      genericRecord.setField("float_field", Float.MAX_VALUE);
+      genericRecord.setField("double_field", Double.MAX_VALUE);
+      genericRecord.setField("string_field", "str");
+
+      genericRecord.setField("date_field", JAVA_LOCAL_DATE_20220110);
+      genericRecord.setField("time_field", JAVA_LOCAL_TIME_HOUR8);
+      genericRecord.setField("ts_with_zone_field", JAVA_OFFSET_DATE_TIME_20220110);
+      genericRecord.setField("ts_without_zone_field", JAVA_LOCAL_DATE_TIME_20220110);
+
+      byte[] uuidBytes = new byte[16];
+      for (int i = 0; i < 16; ++i) {
+        uuidBytes[i] = (byte) i;
+      }
+      genericRecord.setField("uuid_field", uuidBytes);
+
+      byte[] binaryBytes = new byte[7];
+      for (int i = 0; i < 7; ++i) {
+        binaryBytes[i] = (byte) i;
+      }
+      genericRecord.setField("binary_field", ByteBuffer.wrap(binaryBytes));
+
+      String decimalString = "-1.50";

Review Comment:
   Use some more special numbers? For example, `-1.23E-12`?



##########
flink/v1.16/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java:
##########
@@ -0,0 +1,746 @@
+/*
+ * 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.flink;
+
+import static org.apache.iceberg.types.Types.NestedField.required;
+
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
+import org.apache.flink.table.data.DecimalData;
+import org.apache.flink.table.data.GenericArrayData;
+import org.apache.flink.table.data.GenericMapData;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.StringData;
+import org.apache.flink.table.data.TimestampData;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.data.GenericRecord;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.types.Types;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.joda.time.Days;
+
+/**
+ * Util class to generate test data with extensive coverage different field types: from primitives
+ * to complex nested types.
+ */
+public class DataGenerators {
+
+  public static class Primitives implements DataGenerator {
+    private static final DateTime JODA_DATETIME_EPOC =
+        new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
+    private static final DateTime JODA_DATETIME_20220110 =
+        new DateTime(2022, 1, 10, 0, 0, 0, 0, DateTimeZone.UTC);
+    private static final int DAYS_BTW_EPOC_AND_20220110 =
+        Days.daysBetween(JODA_DATETIME_EPOC, JODA_DATETIME_20220110).getDays();
+    private static final int HOUR_8_IN_MILLI = (int) TimeUnit.HOURS.toMillis(8);
+
+    private static final LocalDate JAVA_LOCAL_DATE_20220110 = LocalDate.of(2022, 1, 10);
+    private static final LocalTime JAVA_LOCAL_TIME_HOUR8 = LocalTime.of(8, 0);
+    private static final OffsetDateTime JAVA_OFFSET_DATE_TIME_20220110 =
+        OffsetDateTime.of(2022, 1, 10, 0, 0, 0, 0, ZoneOffset.UTC);
+    private static final LocalDateTime JAVA_LOCAL_DATE_TIME_20220110 =
+        LocalDateTime.of(2022, 1, 10, 0, 0, 0);
+
+    private final Schema icebergSchema =
+        new Schema(
+            Types.NestedField.required(1, "partition_field", Types.StringType.get()),
+            // primitive types
+            Types.NestedField.optional(2, "boolean_field", Types.BooleanType.get()),
+            Types.NestedField.optional(3, "int_field", Types.IntegerType.get()),
+            Types.NestedField.optional(4, "long_field", Types.LongType.get()),
+            Types.NestedField.optional(5, "float_field", Types.FloatType.get()),
+            Types.NestedField.optional(6, "double_field", Types.DoubleType.get()),
+            Types.NestedField.required(7, "string_field", Types.StringType.get()),
+            Types.NestedField.required(8, "date_field", Types.DateType.get()),
+            Types.NestedField.required(9, "time_field", Types.TimeType.get()),
+            Types.NestedField.required(10, "ts_with_zone_field", Types.TimestampType.withZone()),
+            Types.NestedField.required(
+                11, "ts_without_zone_field", Types.TimestampType.withoutZone()),
+            Types.NestedField.required(12, "uuid_field", Types.UUIDType.get()),
+            Types.NestedField.required(13, "binary_field", Types.BinaryType.get()),
+            Types.NestedField.required(14, "decimal_field", Types.DecimalType.of(9, 2)));
+
+    private final RowType flinkRowType = FlinkSchemaUtil.convert(icebergSchema);
+
+    @Override
+    public Schema icebergSchema() {
+      return icebergSchema;
+    }
+
+    @Override
+    public RowType flinkRowType() {
+      return flinkRowType;
+    }
+
+    @Override
+    public GenericRecord generateIcebergGenericRecord() {
+      GenericRecord genericRecord = GenericRecord.create(icebergSchema);
+      genericRecord.setField("partition_field", "partition_value");
+      genericRecord.setField("boolean_field", false);
+      genericRecord.setField("int_field", Integer.MAX_VALUE);
+      genericRecord.setField("long_field", Long.MAX_VALUE);
+      genericRecord.setField("float_field", Float.MAX_VALUE);
+      genericRecord.setField("double_field", Double.MAX_VALUE);
+      genericRecord.setField("string_field", "str");
+
+      genericRecord.setField("date_field", JAVA_LOCAL_DATE_20220110);
+      genericRecord.setField("time_field", JAVA_LOCAL_TIME_HOUR8);
+      genericRecord.setField("ts_with_zone_field", JAVA_OFFSET_DATE_TIME_20220110);
+      genericRecord.setField("ts_without_zone_field", JAVA_LOCAL_DATE_TIME_20220110);
+
+      byte[] uuidBytes = new byte[16];
+      for (int i = 0; i < 16; ++i) {
+        uuidBytes[i] = (byte) i;
+      }
+      genericRecord.setField("uuid_field", uuidBytes);
+
+      byte[] binaryBytes = new byte[7];
+      for (int i = 0; i < 7; ++i) {
+        binaryBytes[i] = (byte) i;
+      }
+      genericRecord.setField("binary_field", ByteBuffer.wrap(binaryBytes));
+
+      String decimalString = "-1.50";
+      BigDecimal bigDecimal = new BigDecimal(decimalString);
+      genericRecord.setField("decimal_field", bigDecimal);
+
+      return genericRecord;
+    }
+
+    @Override
+    public RowData generateFlinkRowData() {
+      byte[] uuidBytes = new byte[16];
+      for (int i = 0; i < 16; ++i) {
+        uuidBytes[i] = (byte) i;
+      }
+
+      byte[] binaryBytes = new byte[7];
+      for (int i = 0; i < 7; ++i) {
+        binaryBytes[i] = (byte) i;
+      }
+
+      return GenericRowData.of(
+          StringData.fromString("partition_value"),
+          false,
+          Integer.MAX_VALUE,
+          Long.MAX_VALUE,
+          Float.MAX_VALUE,
+          Double.MAX_VALUE,
+          StringData.fromString("str"),
+          DAYS_BTW_EPOC_AND_20220110,
+          HOUR_8_IN_MILLI,
+          // Although Avro logical type for timestamp fields are in micro seconds,
+          // AvroToRowDataConverters only looks for long value in milliseconds.
+          TimestampData.fromEpochMillis(JODA_DATETIME_20220110.getMillis()),
+          TimestampData.fromEpochMillis(JODA_DATETIME_20220110.getMillis()),
+          uuidBytes,
+          binaryBytes,
+          DecimalData.fromBigDecimal(new BigDecimal("-1.50"), 9, 2));

Review Comment:
   use static var instead?



##########
flink/v1.16/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java:
##########
@@ -0,0 +1,746 @@
+/*
+ * 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.flink;
+
+import static org.apache.iceberg.types.Types.NestedField.required;
+
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
+import org.apache.flink.table.data.DecimalData;
+import org.apache.flink.table.data.GenericArrayData;
+import org.apache.flink.table.data.GenericMapData;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.StringData;
+import org.apache.flink.table.data.TimestampData;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.data.GenericRecord;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.types.Types;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.joda.time.Days;
+
+/**
+ * Util class to generate test data with extensive coverage different field types: from primitives
+ * to complex nested types.
+ */
+public class DataGenerators {
+
+  public static class Primitives implements DataGenerator {
+    private static final DateTime JODA_DATETIME_EPOC =
+        new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
+    private static final DateTime JODA_DATETIME_20220110 =
+        new DateTime(2022, 1, 10, 0, 0, 0, 0, DateTimeZone.UTC);
+    private static final int DAYS_BTW_EPOC_AND_20220110 =
+        Days.daysBetween(JODA_DATETIME_EPOC, JODA_DATETIME_20220110).getDays();
+    private static final int HOUR_8_IN_MILLI = (int) TimeUnit.HOURS.toMillis(8);
+
+    private static final LocalDate JAVA_LOCAL_DATE_20220110 = LocalDate.of(2022, 1, 10);
+    private static final LocalTime JAVA_LOCAL_TIME_HOUR8 = LocalTime.of(8, 0);
+    private static final OffsetDateTime JAVA_OFFSET_DATE_TIME_20220110 =
+        OffsetDateTime.of(2022, 1, 10, 0, 0, 0, 0, ZoneOffset.UTC);
+    private static final LocalDateTime JAVA_LOCAL_DATE_TIME_20220110 =
+        LocalDateTime.of(2022, 1, 10, 0, 0, 0);
+
+    private final Schema icebergSchema =
+        new Schema(
+            Types.NestedField.required(1, "partition_field", Types.StringType.get()),
+            // primitive types
+            Types.NestedField.optional(2, "boolean_field", Types.BooleanType.get()),
+            Types.NestedField.optional(3, "int_field", Types.IntegerType.get()),
+            Types.NestedField.optional(4, "long_field", Types.LongType.get()),
+            Types.NestedField.optional(5, "float_field", Types.FloatType.get()),
+            Types.NestedField.optional(6, "double_field", Types.DoubleType.get()),
+            Types.NestedField.required(7, "string_field", Types.StringType.get()),
+            Types.NestedField.required(8, "date_field", Types.DateType.get()),
+            Types.NestedField.required(9, "time_field", Types.TimeType.get()),
+            Types.NestedField.required(10, "ts_with_zone_field", Types.TimestampType.withZone()),
+            Types.NestedField.required(
+                11, "ts_without_zone_field", Types.TimestampType.withoutZone()),
+            Types.NestedField.required(12, "uuid_field", Types.UUIDType.get()),
+            Types.NestedField.required(13, "binary_field", Types.BinaryType.get()),
+            Types.NestedField.required(14, "decimal_field", Types.DecimalType.of(9, 2)));
+
+    private final RowType flinkRowType = FlinkSchemaUtil.convert(icebergSchema);
+
+    @Override
+    public Schema icebergSchema() {
+      return icebergSchema;
+    }
+
+    @Override
+    public RowType flinkRowType() {
+      return flinkRowType;
+    }
+
+    @Override
+    public GenericRecord generateIcebergGenericRecord() {
+      GenericRecord genericRecord = GenericRecord.create(icebergSchema);
+      genericRecord.setField("partition_field", "partition_value");
+      genericRecord.setField("boolean_field", false);
+      genericRecord.setField("int_field", Integer.MAX_VALUE);
+      genericRecord.setField("long_field", Long.MAX_VALUE);
+      genericRecord.setField("float_field", Float.MAX_VALUE);
+      genericRecord.setField("double_field", Double.MAX_VALUE);
+      genericRecord.setField("string_field", "str");
+
+      genericRecord.setField("date_field", JAVA_LOCAL_DATE_20220110);
+      genericRecord.setField("time_field", JAVA_LOCAL_TIME_HOUR8);
+      genericRecord.setField("ts_with_zone_field", JAVA_OFFSET_DATE_TIME_20220110);
+      genericRecord.setField("ts_without_zone_field", JAVA_LOCAL_DATE_TIME_20220110);
+
+      byte[] uuidBytes = new byte[16];
+      for (int i = 0; i < 16; ++i) {
+        uuidBytes[i] = (byte) i;
+      }
+      genericRecord.setField("uuid_field", uuidBytes);
+
+      byte[] binaryBytes = new byte[7];
+      for (int i = 0; i < 7; ++i) {
+        binaryBytes[i] = (byte) i;
+      }
+      genericRecord.setField("binary_field", ByteBuffer.wrap(binaryBytes));
+
+      String decimalString = "-1.50";
+      BigDecimal bigDecimal = new BigDecimal(decimalString);
+      genericRecord.setField("decimal_field", bigDecimal);
+
+      return genericRecord;
+    }
+
+    @Override
+    public RowData generateFlinkRowData() {
+      byte[] uuidBytes = new byte[16];
+      for (int i = 0; i < 16; ++i) {
+        uuidBytes[i] = (byte) i;
+      }
+
+      byte[] binaryBytes = new byte[7];
+      for (int i = 0; i < 7; ++i) {
+        binaryBytes[i] = (byte) i;
+      }
+
+      return GenericRowData.of(
+          StringData.fromString("partition_value"),
+          false,
+          Integer.MAX_VALUE,
+          Long.MAX_VALUE,
+          Float.MAX_VALUE,
+          Double.MAX_VALUE,
+          StringData.fromString("str"),
+          DAYS_BTW_EPOC_AND_20220110,
+          HOUR_8_IN_MILLI,
+          // Although Avro logical type for timestamp fields are in micro seconds,
+          // AvroToRowDataConverters only looks for long value in milliseconds.
+          TimestampData.fromEpochMillis(JODA_DATETIME_20220110.getMillis()),
+          TimestampData.fromEpochMillis(JODA_DATETIME_20220110.getMillis()),
+          uuidBytes,
+          binaryBytes,
+          DecimalData.fromBigDecimal(new BigDecimal("-1.50"), 9, 2));
+    }
+  }
+
+  public static class StructOfPrimitive implements DataGenerator {
+    private final Schema icebergSchema =
+        new Schema(
+            Types.NestedField.required(1, "partition_field", Types.StringType.get()),
+            Types.NestedField.required(
+                2,
+                "struct_of_primitive",
+                Types.StructType.of(
+                    required(101, "id", Types.IntegerType.get()),
+                    required(102, "name", Types.StringType.get()))));
+
+    private final RowType flinkRowType = FlinkSchemaUtil.convert(icebergSchema);
+
+    @Override
+    public Schema icebergSchema() {
+      return icebergSchema;
+    }
+
+    @Override
+    public RowType flinkRowType() {
+      return flinkRowType;
+    }
+
+    @Override
+    public GenericRecord generateIcebergGenericRecord() {
+      Schema structSchema =
+          new Schema(icebergSchema.findField("struct_of_primitive").type().asStructType().fields());
+      GenericRecord struct = GenericRecord.create(structSchema);
+      struct.setField("id", 1);
+      struct.setField("name", "Jane");
+      GenericRecord genericRecord = GenericRecord.create(icebergSchema);
+      genericRecord.setField("partition_field", "partition_value");
+      genericRecord.setField("struct_of_primitive", struct);
+      return genericRecord;
+    }
+
+    @Override
+    public RowData generateFlinkRowData() {
+      return GenericRowData.of(
+          StringData.fromString("partition_value"),
+          GenericRowData.of(1, StringData.fromString("Jane")));
+    }
+  }
+
+  public static class StructOfArray implements DataGenerator {
+    private final Schema icebergSchema =
+        new Schema(
+            Types.NestedField.required(1, "partition_field", Types.StringType.get()),
+            Types.NestedField.required(
+                2,
+                "struct_of_array",
+                Types.StructType.of(
+                    required(101, "id", Types.IntegerType.get()),
+                    required(
+                        102, "names", Types.ListType.ofRequired(201, Types.StringType.get())))));
+
+    private final RowType flinkRowType = FlinkSchemaUtil.convert(icebergSchema);
+
+    @Override
+    public Schema icebergSchema() {
+      return icebergSchema;
+    }
+
+    @Override
+    public RowType flinkRowType() {
+      return flinkRowType;
+    }
+
+    @Override
+    public GenericRecord generateIcebergGenericRecord() {
+      Schema structSchema =
+          new Schema(icebergSchema.findField("struct_of_array").type().asStructType().fields());
+      GenericRecord struct = GenericRecord.create(structSchema);
+      struct.setField("id", 1);
+      struct.setField("names", Arrays.asList("Jane", "Joe"));
+      GenericRecord genericRecord = GenericRecord.create(icebergSchema);
+      genericRecord.setField("partition_field", "partition_value");
+      genericRecord.setField("struct_of_array", struct);
+      return genericRecord;
+    }
+
+    @Override
+    public RowData generateFlinkRowData() {
+      StringData[] names = {StringData.fromString("Jane"), StringData.fromString("Joe")};
+      return GenericRowData.of(
+          StringData.fromString("partition_value"),
+          GenericRowData.of(1, new GenericArrayData(names)));
+    }
+  }
+
+  public static class StructOfMap implements DataGenerator {
+    private final Schema icebergSchema =
+        new Schema(
+            Types.NestedField.required(1, "partition_field", Types.StringType.get()),
+            Types.NestedField.required(
+                2,
+                "struct_of_map",
+                Types.StructType.of(
+                    required(101, "id", Types.IntegerType.get()),
+                    required(
+                        102,
+                        "names",
+                        Types.MapType.ofRequired(
+                            201, 202, Types.StringType.get(), Types.StringType.get())))));
+
+    private final RowType flinkRowType = FlinkSchemaUtil.convert(icebergSchema);
+
+    @Override
+    public Schema icebergSchema() {
+      return icebergSchema;
+    }
+
+    @Override
+    public RowType flinkRowType() {
+      return flinkRowType;
+    }
+
+    @Override
+    public GenericRecord generateIcebergGenericRecord() {
+      Schema structSchema =
+          new Schema(icebergSchema.findField("struct_of_map").type().asStructType().fields());
+      GenericRecord struct = GenericRecord.create(structSchema);
+      struct.setField("id", 1);
+      struct.setField("names", ImmutableMap.of("Jane", "female", "Joe", "male"));
+      GenericRecord genericRecord = GenericRecord.create(icebergSchema);
+      genericRecord.setField("partition_field", "partition_value");
+      genericRecord.setField("struct_of_map", struct);
+      return genericRecord;
+    }
+
+    @Override
+    public RowData generateFlinkRowData() {
+      return GenericRowData.of(
+          StringData.fromString("partition_value"),
+          GenericRowData.of(
+              1,
+              new GenericMapData(
+                  ImmutableMap.of(
+                      StringData.fromString("Jane"),
+                      StringData.fromString("female"),
+                      StringData.fromString("Joe"),
+                      StringData.fromString("male")))));
+    }
+  }
+
+  public static class StructOfStruct implements DataGenerator {
+    private final Schema icebergSchema =
+        new Schema(
+            Types.NestedField.required(1, "partition_field", Types.StringType.get()),
+            Types.NestedField.required(
+                2,
+                "struct_of_struct",
+                Types.StructType.of(
+                    required(101, "id", Types.IntegerType.get()),
+                    required(
+                        102,
+                        "person_struct",
+                        Types.StructType.of(
+                            Types.NestedField.required(201, "name", Types.StringType.get()),
+                            Types.NestedField.required(202, "address", Types.StringType.get()))))));
+
+    private final RowType flinkRowType = FlinkSchemaUtil.convert(icebergSchema);
+
+    @Override
+    public Schema icebergSchema() {
+      return icebergSchema;
+    }
+
+    @Override
+    public RowType flinkRowType() {
+      return flinkRowType;
+    }
+
+    @Override
+    public GenericRecord generateIcebergGenericRecord() {
+      Schema structSchema =
+          new Schema(icebergSchema.findField("struct_of_struct").type().asStructType().fields());
+      Schema personSchema =
+          new Schema(structSchema.findField("person_struct").type().asStructType().fields());
+      GenericRecord person = GenericRecord.create(personSchema);
+      person.setField("name", "Jane");
+      person.setField("address", "Apple Park");
+      GenericRecord struct = GenericRecord.create(structSchema);
+      struct.setField("id", 1);
+      struct.setField("person_struct", person);
+      GenericRecord genericRecord = GenericRecord.create(icebergSchema);
+      genericRecord.setField("partition_field", "partition_value");
+      genericRecord.setField("struct_of_struct", struct);
+      return genericRecord;
+    }
+
+    @Override
+    public RowData generateFlinkRowData() {
+      return GenericRowData.of(
+          StringData.fromString("partition_value"),
+          GenericRowData.of(
+              1,
+              GenericRowData.of(
+                  StringData.fromString("Jane"), StringData.fromString("Apple Park"))));
+    }
+  }
+
+  public static class ArrayOfPrimitive implements DataGenerator {
+    private final Schema icebergSchema =
+        new Schema(
+            Types.NestedField.required(1, "partition_field", Types.StringType.get()),
+            Types.NestedField.required(
+                2, "array_of_int", Types.ListType.ofRequired(101, Types.IntegerType.get())));
+
+    private final RowType flinkRowType = FlinkSchemaUtil.convert(icebergSchema);
+
+    @Override
+    public Schema icebergSchema() {
+      return icebergSchema;
+    }
+
+    @Override
+    public RowType flinkRowType() {
+      return flinkRowType;
+    }
+
+    @Override
+    public GenericRecord generateIcebergGenericRecord() {
+      GenericRecord genericRecord = GenericRecord.create(icebergSchema);
+      genericRecord.setField("partition_field", "partition_value");
+      genericRecord.setField("array_of_int", Arrays.asList(1, 2, 3));
+      return genericRecord;
+    }
+
+    @Override
+    public RowData generateFlinkRowData() {
+      Integer[] arr = {1, 2, 3};

Review Comment:
   `arr` seems to be class var, `generateIcebergGenericRecord` can also use it?



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] stevenzwu merged pull request #6377: Flink: add util class to generate test data with extensive coverage d…

Posted by GitBox <gi...@apache.org>.
stevenzwu merged PR #6377:
URL: https://github.com/apache/iceberg/pull/6377


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] stevenzwu commented on pull request #6377: Flink: add util class to generate test data with extensive coverage d…

Posted by GitBox <gi...@apache.org>.
stevenzwu commented on PR #6377:
URL: https://github.com/apache/iceberg/pull/6377#issuecomment-1343636473

   @hililiwei please help review this PR


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] stevenzwu commented on pull request #6377: Flink: add util class to generate test data with extensive coverage d…

Posted by GitBox <gi...@apache.org>.
stevenzwu commented on PR #6377:
URL: https://github.com/apache/iceberg/pull/6377#issuecomment-1341418873

   Example usage
   
   ```
   public class TestRowDataToAvroGenericRecordConverter  {
   
     protected void testConverter(DataGenerator dataGenerator) throws Exception {
       RowDataToAvroGenericRecordConverter converter =
           RowDataToAvroGenericRecordConverter.fromAvroSchema(dataGenerator.avroSchema());
       GenericRecord expected = dataGenerator.generateAvroGenericRecord();
       GenericRecord actual = converter.apply(dataGenerator.generateFlinkRowData());
       Assert.assertEquals(expected, actual);
     }
   
     @Test
     public void testPrimitiveTypes() throws Exception {
       testConverter(new DataGenerators.Primitives());
     }
   
     @Test
     public void testStructOfPrimitive() throws Exception {
       testConverter(new DataGenerators.StructOfPrimitive());
     }
   
     @Test
     public void testStructOfArray() throws Exception {
       testConverter(new DataGenerators.StructOfArray());
     }
   
     @Test
     public void testStructOfMap() throws Exception {
       testConverter(new DataGenerators.StructOfMap());
     }
   
     @Test
     public void testStructOfStruct() throws Exception {
       testConverter(new DataGenerators.StructOfStruct());
     }
   
     @Test
     public void testArrayOfPrimitive() throws Exception {
       testConverter(new DataGenerators.ArrayOfPrimitive());
     }
   
     @Test
     public void testArrayOfArray() throws Exception {
       testConverter(new DataGenerators.ArrayOfArray());
     }
   
     @Test
     public void testArrayOfMap() throws Exception {
       testConverter(new DataGenerators.ArrayOfMap());
     }
   
     @Test
     public void testArrayOfStruct() throws Exception {
       testConverter(new DataGenerators.ArrayOfStruct());
     }
   
     @Test
     public void testMapOfPrimitives() throws Exception {
       testConverter(new DataGenerators.MapOfPrimitives());
     }
   
     @Test
     public void testMapOfArray() throws Exception {
       testConverter(new DataGenerators.MapOfArray());
     }
   
     @Test
     public void testMapOfMap() throws Exception {
       testConverter(new DataGenerators.MapOfMap());
     }
   
     @Test
     public void testMapOfStruct() throws Exception {
       testConverter(new DataGenerators.MapOfStruct());
     }
   }
   
   ```


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] stevenzwu commented on a diff in pull request #6377: Flink: add util class to generate test data with extensive coverage d…

Posted by GitBox <gi...@apache.org>.
stevenzwu commented on code in PR #6377:
URL: https://github.com/apache/iceberg/pull/6377#discussion_r1046417674


##########
flink/v1.16/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java:
##########
@@ -0,0 +1,746 @@
+/*
+ * 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.flink;
+
+import static org.apache.iceberg.types.Types.NestedField.required;
+
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
+import org.apache.flink.table.data.DecimalData;
+import org.apache.flink.table.data.GenericArrayData;
+import org.apache.flink.table.data.GenericMapData;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.StringData;
+import org.apache.flink.table.data.TimestampData;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.data.GenericRecord;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.types.Types;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.joda.time.Days;
+
+/**
+ * Util class to generate test data with extensive coverage different field types: from primitives
+ * to complex nested types.
+ */
+public class DataGenerators {
+
+  public static class Primitives implements DataGenerator {
+    private static final DateTime JODA_DATETIME_EPOC =
+        new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
+    private static final DateTime JODA_DATETIME_20220110 =
+        new DateTime(2022, 1, 10, 0, 0, 0, 0, DateTimeZone.UTC);
+    private static final int DAYS_BTW_EPOC_AND_20220110 =
+        Days.daysBetween(JODA_DATETIME_EPOC, JODA_DATETIME_20220110).getDays();
+    private static final int HOUR_8_IN_MILLI = (int) TimeUnit.HOURS.toMillis(8);
+
+    private static final LocalDate JAVA_LOCAL_DATE_20220110 = LocalDate.of(2022, 1, 10);
+    private static final LocalTime JAVA_LOCAL_TIME_HOUR8 = LocalTime.of(8, 0);
+    private static final OffsetDateTime JAVA_OFFSET_DATE_TIME_20220110 =
+        OffsetDateTime.of(2022, 1, 10, 0, 0, 0, 0, ZoneOffset.UTC);
+    private static final LocalDateTime JAVA_LOCAL_DATE_TIME_20220110 =
+        LocalDateTime.of(2022, 1, 10, 0, 0, 0);
+
+    private final Schema icebergSchema =
+        new Schema(
+            Types.NestedField.required(1, "partition_field", Types.StringType.get()),
+            // primitive types
+            Types.NestedField.optional(2, "boolean_field", Types.BooleanType.get()),
+            Types.NestedField.optional(3, "int_field", Types.IntegerType.get()),
+            Types.NestedField.optional(4, "long_field", Types.LongType.get()),
+            Types.NestedField.optional(5, "float_field", Types.FloatType.get()),
+            Types.NestedField.optional(6, "double_field", Types.DoubleType.get()),
+            Types.NestedField.required(7, "string_field", Types.StringType.get()),
+            Types.NestedField.required(8, "date_field", Types.DateType.get()),
+            Types.NestedField.required(9, "time_field", Types.TimeType.get()),
+            Types.NestedField.required(10, "ts_with_zone_field", Types.TimestampType.withZone()),
+            Types.NestedField.required(
+                11, "ts_without_zone_field", Types.TimestampType.withoutZone()),
+            Types.NestedField.required(12, "uuid_field", Types.UUIDType.get()),
+            Types.NestedField.required(13, "binary_field", Types.BinaryType.get()),
+            Types.NestedField.required(14, "decimal_field", Types.DecimalType.of(9, 2)));
+
+    private final RowType flinkRowType = FlinkSchemaUtil.convert(icebergSchema);
+
+    @Override
+    public Schema icebergSchema() {
+      return icebergSchema;
+    }
+
+    @Override
+    public RowType flinkRowType() {
+      return flinkRowType;
+    }
+
+    @Override
+    public GenericRecord generateIcebergGenericRecord() {
+      GenericRecord genericRecord = GenericRecord.create(icebergSchema);
+      genericRecord.setField("partition_field", "partition_value");
+      genericRecord.setField("boolean_field", false);
+      genericRecord.setField("int_field", Integer.MAX_VALUE);
+      genericRecord.setField("long_field", Long.MAX_VALUE);
+      genericRecord.setField("float_field", Float.MAX_VALUE);
+      genericRecord.setField("double_field", Double.MAX_VALUE);
+      genericRecord.setField("string_field", "str");
+
+      genericRecord.setField("date_field", JAVA_LOCAL_DATE_20220110);
+      genericRecord.setField("time_field", JAVA_LOCAL_TIME_HOUR8);
+      genericRecord.setField("ts_with_zone_field", JAVA_OFFSET_DATE_TIME_20220110);
+      genericRecord.setField("ts_without_zone_field", JAVA_LOCAL_DATE_TIME_20220110);
+
+      byte[] uuidBytes = new byte[16];
+      for (int i = 0; i < 16; ++i) {
+        uuidBytes[i] = (byte) i;
+      }
+      genericRecord.setField("uuid_field", uuidBytes);
+
+      byte[] binaryBytes = new byte[7];
+      for (int i = 0; i < 7; ++i) {
+        binaryBytes[i] = (byte) i;
+      }
+      genericRecord.setField("binary_field", ByteBuffer.wrap(binaryBytes));
+
+      String decimalString = "-1.50";

Review Comment:
   not sure if  it is necessary. will probably stay put on this one.



##########
flink/v1.16/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java:
##########
@@ -0,0 +1,746 @@
+/*
+ * 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.flink;
+
+import static org.apache.iceberg.types.Types.NestedField.required;
+
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
+import org.apache.flink.table.data.DecimalData;
+import org.apache.flink.table.data.GenericArrayData;
+import org.apache.flink.table.data.GenericMapData;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.StringData;
+import org.apache.flink.table.data.TimestampData;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.data.GenericRecord;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.types.Types;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.joda.time.Days;
+
+/**
+ * Util class to generate test data with extensive coverage different field types: from primitives
+ * to complex nested types.
+ */
+public class DataGenerators {
+
+  public static class Primitives implements DataGenerator {
+    private static final DateTime JODA_DATETIME_EPOC =
+        new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
+    private static final DateTime JODA_DATETIME_20220110 =
+        new DateTime(2022, 1, 10, 0, 0, 0, 0, DateTimeZone.UTC);
+    private static final int DAYS_BTW_EPOC_AND_20220110 =
+        Days.daysBetween(JODA_DATETIME_EPOC, JODA_DATETIME_20220110).getDays();
+    private static final int HOUR_8_IN_MILLI = (int) TimeUnit.HOURS.toMillis(8);
+
+    private static final LocalDate JAVA_LOCAL_DATE_20220110 = LocalDate.of(2022, 1, 10);
+    private static final LocalTime JAVA_LOCAL_TIME_HOUR8 = LocalTime.of(8, 0);
+    private static final OffsetDateTime JAVA_OFFSET_DATE_TIME_20220110 =
+        OffsetDateTime.of(2022, 1, 10, 0, 0, 0, 0, ZoneOffset.UTC);
+    private static final LocalDateTime JAVA_LOCAL_DATE_TIME_20220110 =
+        LocalDateTime.of(2022, 1, 10, 0, 0, 0);

Review Comment:
   not sure if it is necessary. will stay put.



##########
flink/v1.16/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java:
##########
@@ -0,0 +1,746 @@
+/*
+ * 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.flink;
+
+import static org.apache.iceberg.types.Types.NestedField.required;
+
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
+import org.apache.flink.table.data.DecimalData;
+import org.apache.flink.table.data.GenericArrayData;
+import org.apache.flink.table.data.GenericMapData;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.StringData;
+import org.apache.flink.table.data.TimestampData;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.data.GenericRecord;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.types.Types;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.joda.time.Days;
+
+/**
+ * Util class to generate test data with extensive coverage different field types: from primitives
+ * to complex nested types.
+ */
+public class DataGenerators {
+
+  public static class Primitives implements DataGenerator {
+    private static final DateTime JODA_DATETIME_EPOC =
+        new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
+    private static final DateTime JODA_DATETIME_20220110 =
+        new DateTime(2022, 1, 10, 0, 0, 0, 0, DateTimeZone.UTC);
+    private static final int DAYS_BTW_EPOC_AND_20220110 =
+        Days.daysBetween(JODA_DATETIME_EPOC, JODA_DATETIME_20220110).getDays();
+    private static final int HOUR_8_IN_MILLI = (int) TimeUnit.HOURS.toMillis(8);
+
+    private static final LocalDate JAVA_LOCAL_DATE_20220110 = LocalDate.of(2022, 1, 10);
+    private static final LocalTime JAVA_LOCAL_TIME_HOUR8 = LocalTime.of(8, 0);
+    private static final OffsetDateTime JAVA_OFFSET_DATE_TIME_20220110 =
+        OffsetDateTime.of(2022, 1, 10, 0, 0, 0, 0, ZoneOffset.UTC);
+    private static final LocalDateTime JAVA_LOCAL_DATE_TIME_20220110 =
+        LocalDateTime.of(2022, 1, 10, 0, 0, 0);
+
+    private final Schema icebergSchema =
+        new Schema(
+            Types.NestedField.required(1, "partition_field", Types.StringType.get()),
+            // primitive types
+            Types.NestedField.optional(2, "boolean_field", Types.BooleanType.get()),
+            Types.NestedField.optional(3, "int_field", Types.IntegerType.get()),
+            Types.NestedField.optional(4, "long_field", Types.LongType.get()),
+            Types.NestedField.optional(5, "float_field", Types.FloatType.get()),
+            Types.NestedField.optional(6, "double_field", Types.DoubleType.get()),
+            Types.NestedField.required(7, "string_field", Types.StringType.get()),
+            Types.NestedField.required(8, "date_field", Types.DateType.get()),
+            Types.NestedField.required(9, "time_field", Types.TimeType.get()),
+            Types.NestedField.required(10, "ts_with_zone_field", Types.TimestampType.withZone()),
+            Types.NestedField.required(
+                11, "ts_without_zone_field", Types.TimestampType.withoutZone()),
+            Types.NestedField.required(12, "uuid_field", Types.UUIDType.get()),
+            Types.NestedField.required(13, "binary_field", Types.BinaryType.get()),
+            Types.NestedField.required(14, "decimal_field", Types.DecimalType.of(9, 2)));
+
+    private final RowType flinkRowType = FlinkSchemaUtil.convert(icebergSchema);
+
+    @Override
+    public Schema icebergSchema() {
+      return icebergSchema;
+    }
+
+    @Override
+    public RowType flinkRowType() {
+      return flinkRowType;
+    }
+
+    @Override
+    public GenericRecord generateIcebergGenericRecord() {
+      GenericRecord genericRecord = GenericRecord.create(icebergSchema);
+      genericRecord.setField("partition_field", "partition_value");
+      genericRecord.setField("boolean_field", false);
+      genericRecord.setField("int_field", Integer.MAX_VALUE);
+      genericRecord.setField("long_field", Long.MAX_VALUE);
+      genericRecord.setField("float_field", Float.MAX_VALUE);
+      genericRecord.setField("double_field", Double.MAX_VALUE);
+      genericRecord.setField("string_field", "str");
+
+      genericRecord.setField("date_field", JAVA_LOCAL_DATE_20220110);
+      genericRecord.setField("time_field", JAVA_LOCAL_TIME_HOUR8);
+      genericRecord.setField("ts_with_zone_field", JAVA_OFFSET_DATE_TIME_20220110);
+      genericRecord.setField("ts_without_zone_field", JAVA_LOCAL_DATE_TIME_20220110);
+
+      byte[] uuidBytes = new byte[16];
+      for (int i = 0; i < 16; ++i) {
+        uuidBytes[i] = (byte) i;
+      }
+      genericRecord.setField("uuid_field", uuidBytes);
+
+      byte[] binaryBytes = new byte[7];
+      for (int i = 0; i < 7; ++i) {
+        binaryBytes[i] = (byte) i;
+      }
+      genericRecord.setField("binary_field", ByteBuffer.wrap(binaryBytes));
+
+      String decimalString = "-1.50";
+      BigDecimal bigDecimal = new BigDecimal(decimalString);
+      genericRecord.setField("decimal_field", bigDecimal);
+
+      return genericRecord;
+    }
+
+    @Override
+    public RowData generateFlinkRowData() {
+      byte[] uuidBytes = new byte[16];
+      for (int i = 0; i < 16; ++i) {
+        uuidBytes[i] = (byte) i;
+      }
+
+      byte[] binaryBytes = new byte[7];
+      for (int i = 0; i < 7; ++i) {
+        binaryBytes[i] = (byte) i;
+      }
+
+      return GenericRowData.of(
+          StringData.fromString("partition_value"),
+          false,
+          Integer.MAX_VALUE,
+          Long.MAX_VALUE,
+          Float.MAX_VALUE,
+          Double.MAX_VALUE,
+          StringData.fromString("str"),
+          DAYS_BTW_EPOC_AND_20220110,
+          HOUR_8_IN_MILLI,
+          // Although Avro logical type for timestamp fields are in micro seconds,
+          // AvroToRowDataConverters only looks for long value in milliseconds.
+          TimestampData.fromEpochMillis(JODA_DATETIME_20220110.getMillis()),
+          TimestampData.fromEpochMillis(JODA_DATETIME_20220110.getMillis()),
+          uuidBytes,
+          binaryBytes,
+          DecimalData.fromBigDecimal(new BigDecimal("-1.50"), 9, 2));

Review Comment:
   agree. will update



##########
flink/v1.16/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java:
##########
@@ -0,0 +1,746 @@
+/*
+ * 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.flink;
+
+import static org.apache.iceberg.types.Types.NestedField.required;
+
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
+import org.apache.flink.table.data.DecimalData;
+import org.apache.flink.table.data.GenericArrayData;
+import org.apache.flink.table.data.GenericMapData;
+import org.apache.flink.table.data.GenericRowData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.StringData;
+import org.apache.flink.table.data.TimestampData;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.data.GenericRecord;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.types.Types;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.joda.time.Days;
+
+/**
+ * Util class to generate test data with extensive coverage different field types: from primitives
+ * to complex nested types.
+ */
+public class DataGenerators {
+
+  public static class Primitives implements DataGenerator {
+    private static final DateTime JODA_DATETIME_EPOC =
+        new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeZone.UTC);
+    private static final DateTime JODA_DATETIME_20220110 =
+        new DateTime(2022, 1, 10, 0, 0, 0, 0, DateTimeZone.UTC);
+    private static final int DAYS_BTW_EPOC_AND_20220110 =
+        Days.daysBetween(JODA_DATETIME_EPOC, JODA_DATETIME_20220110).getDays();
+    private static final int HOUR_8_IN_MILLI = (int) TimeUnit.HOURS.toMillis(8);
+
+    private static final LocalDate JAVA_LOCAL_DATE_20220110 = LocalDate.of(2022, 1, 10);
+    private static final LocalTime JAVA_LOCAL_TIME_HOUR8 = LocalTime.of(8, 0);
+    private static final OffsetDateTime JAVA_OFFSET_DATE_TIME_20220110 =
+        OffsetDateTime.of(2022, 1, 10, 0, 0, 0, 0, ZoneOffset.UTC);
+    private static final LocalDateTime JAVA_LOCAL_DATE_TIME_20220110 =
+        LocalDateTime.of(2022, 1, 10, 0, 0, 0);
+
+    private final Schema icebergSchema =
+        new Schema(
+            Types.NestedField.required(1, "partition_field", Types.StringType.get()),
+            // primitive types
+            Types.NestedField.optional(2, "boolean_field", Types.BooleanType.get()),
+            Types.NestedField.optional(3, "int_field", Types.IntegerType.get()),
+            Types.NestedField.optional(4, "long_field", Types.LongType.get()),
+            Types.NestedField.optional(5, "float_field", Types.FloatType.get()),
+            Types.NestedField.optional(6, "double_field", Types.DoubleType.get()),
+            Types.NestedField.required(7, "string_field", Types.StringType.get()),
+            Types.NestedField.required(8, "date_field", Types.DateType.get()),
+            Types.NestedField.required(9, "time_field", Types.TimeType.get()),
+            Types.NestedField.required(10, "ts_with_zone_field", Types.TimestampType.withZone()),
+            Types.NestedField.required(
+                11, "ts_without_zone_field", Types.TimestampType.withoutZone()),
+            Types.NestedField.required(12, "uuid_field", Types.UUIDType.get()),
+            Types.NestedField.required(13, "binary_field", Types.BinaryType.get()),
+            Types.NestedField.required(14, "decimal_field", Types.DecimalType.of(9, 2)));
+
+    private final RowType flinkRowType = FlinkSchemaUtil.convert(icebergSchema);
+
+    @Override
+    public Schema icebergSchema() {
+      return icebergSchema;
+    }
+
+    @Override
+    public RowType flinkRowType() {
+      return flinkRowType;
+    }
+
+    @Override
+    public GenericRecord generateIcebergGenericRecord() {
+      GenericRecord genericRecord = GenericRecord.create(icebergSchema);
+      genericRecord.setField("partition_field", "partition_value");
+      genericRecord.setField("boolean_field", false);
+      genericRecord.setField("int_field", Integer.MAX_VALUE);
+      genericRecord.setField("long_field", Long.MAX_VALUE);
+      genericRecord.setField("float_field", Float.MAX_VALUE);
+      genericRecord.setField("double_field", Double.MAX_VALUE);
+      genericRecord.setField("string_field", "str");
+
+      genericRecord.setField("date_field", JAVA_LOCAL_DATE_20220110);
+      genericRecord.setField("time_field", JAVA_LOCAL_TIME_HOUR8);
+      genericRecord.setField("ts_with_zone_field", JAVA_OFFSET_DATE_TIME_20220110);
+      genericRecord.setField("ts_without_zone_field", JAVA_LOCAL_DATE_TIME_20220110);
+
+      byte[] uuidBytes = new byte[16];
+      for (int i = 0; i < 16; ++i) {
+        uuidBytes[i] = (byte) i;
+      }
+      genericRecord.setField("uuid_field", uuidBytes);
+
+      byte[] binaryBytes = new byte[7];
+      for (int i = 0; i < 7; ++i) {
+        binaryBytes[i] = (byte) i;
+      }
+      genericRecord.setField("binary_field", ByteBuffer.wrap(binaryBytes));
+
+      String decimalString = "-1.50";
+      BigDecimal bigDecimal = new BigDecimal(decimalString);
+      genericRecord.setField("decimal_field", bigDecimal);
+
+      return genericRecord;
+    }
+
+    @Override
+    public RowData generateFlinkRowData() {
+      byte[] uuidBytes = new byte[16];
+      for (int i = 0; i < 16; ++i) {
+        uuidBytes[i] = (byte) i;
+      }
+
+      byte[] binaryBytes = new byte[7];
+      for (int i = 0; i < 7; ++i) {
+        binaryBytes[i] = (byte) i;
+      }
+
+      return GenericRowData.of(
+          StringData.fromString("partition_value"),
+          false,
+          Integer.MAX_VALUE,
+          Long.MAX_VALUE,
+          Float.MAX_VALUE,
+          Double.MAX_VALUE,
+          StringData.fromString("str"),
+          DAYS_BTW_EPOC_AND_20220110,
+          HOUR_8_IN_MILLI,
+          // Although Avro logical type for timestamp fields are in micro seconds,
+          // AvroToRowDataConverters only looks for long value in milliseconds.
+          TimestampData.fromEpochMillis(JODA_DATETIME_20220110.getMillis()),
+          TimestampData.fromEpochMillis(JODA_DATETIME_20220110.getMillis()),
+          uuidBytes,
+          binaryBytes,
+          DecimalData.fromBigDecimal(new BigDecimal("-1.50"), 9, 2));
+    }
+  }
+
+  public static class StructOfPrimitive implements DataGenerator {
+    private final Schema icebergSchema =
+        new Schema(
+            Types.NestedField.required(1, "partition_field", Types.StringType.get()),
+            Types.NestedField.required(
+                2,
+                "struct_of_primitive",
+                Types.StructType.of(
+                    required(101, "id", Types.IntegerType.get()),
+                    required(102, "name", Types.StringType.get()))));
+
+    private final RowType flinkRowType = FlinkSchemaUtil.convert(icebergSchema);
+
+    @Override
+    public Schema icebergSchema() {
+      return icebergSchema;
+    }
+
+    @Override
+    public RowType flinkRowType() {
+      return flinkRowType;
+    }
+
+    @Override
+    public GenericRecord generateIcebergGenericRecord() {
+      Schema structSchema =
+          new Schema(icebergSchema.findField("struct_of_primitive").type().asStructType().fields());
+      GenericRecord struct = GenericRecord.create(structSchema);
+      struct.setField("id", 1);
+      struct.setField("name", "Jane");
+      GenericRecord genericRecord = GenericRecord.create(icebergSchema);
+      genericRecord.setField("partition_field", "partition_value");
+      genericRecord.setField("struct_of_primitive", struct);
+      return genericRecord;
+    }
+
+    @Override
+    public RowData generateFlinkRowData() {
+      return GenericRowData.of(
+          StringData.fromString("partition_value"),
+          GenericRowData.of(1, StringData.fromString("Jane")));
+    }
+  }
+
+  public static class StructOfArray implements DataGenerator {
+    private final Schema icebergSchema =
+        new Schema(
+            Types.NestedField.required(1, "partition_field", Types.StringType.get()),
+            Types.NestedField.required(
+                2,
+                "struct_of_array",
+                Types.StructType.of(
+                    required(101, "id", Types.IntegerType.get()),
+                    required(
+                        102, "names", Types.ListType.ofRequired(201, Types.StringType.get())))));
+
+    private final RowType flinkRowType = FlinkSchemaUtil.convert(icebergSchema);
+
+    @Override
+    public Schema icebergSchema() {
+      return icebergSchema;
+    }
+
+    @Override
+    public RowType flinkRowType() {
+      return flinkRowType;
+    }
+
+    @Override
+    public GenericRecord generateIcebergGenericRecord() {
+      Schema structSchema =
+          new Schema(icebergSchema.findField("struct_of_array").type().asStructType().fields());
+      GenericRecord struct = GenericRecord.create(structSchema);
+      struct.setField("id", 1);
+      struct.setField("names", Arrays.asList("Jane", "Joe"));
+      GenericRecord genericRecord = GenericRecord.create(icebergSchema);
+      genericRecord.setField("partition_field", "partition_value");
+      genericRecord.setField("struct_of_array", struct);
+      return genericRecord;
+    }
+
+    @Override
+    public RowData generateFlinkRowData() {
+      StringData[] names = {StringData.fromString("Jane"), StringData.fromString("Joe")};
+      return GenericRowData.of(
+          StringData.fromString("partition_value"),
+          GenericRowData.of(1, new GenericArrayData(names)));
+    }
+  }
+
+  public static class StructOfMap implements DataGenerator {
+    private final Schema icebergSchema =
+        new Schema(
+            Types.NestedField.required(1, "partition_field", Types.StringType.get()),
+            Types.NestedField.required(
+                2,
+                "struct_of_map",
+                Types.StructType.of(
+                    required(101, "id", Types.IntegerType.get()),
+                    required(
+                        102,
+                        "names",
+                        Types.MapType.ofRequired(
+                            201, 202, Types.StringType.get(), Types.StringType.get())))));
+
+    private final RowType flinkRowType = FlinkSchemaUtil.convert(icebergSchema);
+
+    @Override
+    public Schema icebergSchema() {
+      return icebergSchema;
+    }
+
+    @Override
+    public RowType flinkRowType() {
+      return flinkRowType;
+    }
+
+    @Override
+    public GenericRecord generateIcebergGenericRecord() {
+      Schema structSchema =
+          new Schema(icebergSchema.findField("struct_of_map").type().asStructType().fields());
+      GenericRecord struct = GenericRecord.create(structSchema);
+      struct.setField("id", 1);
+      struct.setField("names", ImmutableMap.of("Jane", "female", "Joe", "male"));
+      GenericRecord genericRecord = GenericRecord.create(icebergSchema);
+      genericRecord.setField("partition_field", "partition_value");
+      genericRecord.setField("struct_of_map", struct);
+      return genericRecord;
+    }
+
+    @Override
+    public RowData generateFlinkRowData() {
+      return GenericRowData.of(
+          StringData.fromString("partition_value"),
+          GenericRowData.of(
+              1,
+              new GenericMapData(
+                  ImmutableMap.of(
+                      StringData.fromString("Jane"),
+                      StringData.fromString("female"),
+                      StringData.fromString("Joe"),
+                      StringData.fromString("male")))));
+    }
+  }
+
+  public static class StructOfStruct implements DataGenerator {
+    private final Schema icebergSchema =
+        new Schema(
+            Types.NestedField.required(1, "partition_field", Types.StringType.get()),
+            Types.NestedField.required(
+                2,
+                "struct_of_struct",
+                Types.StructType.of(
+                    required(101, "id", Types.IntegerType.get()),
+                    required(
+                        102,
+                        "person_struct",
+                        Types.StructType.of(
+                            Types.NestedField.required(201, "name", Types.StringType.get()),
+                            Types.NestedField.required(202, "address", Types.StringType.get()))))));
+
+    private final RowType flinkRowType = FlinkSchemaUtil.convert(icebergSchema);
+
+    @Override
+    public Schema icebergSchema() {
+      return icebergSchema;
+    }
+
+    @Override
+    public RowType flinkRowType() {
+      return flinkRowType;
+    }
+
+    @Override
+    public GenericRecord generateIcebergGenericRecord() {
+      Schema structSchema =
+          new Schema(icebergSchema.findField("struct_of_struct").type().asStructType().fields());
+      Schema personSchema =
+          new Schema(structSchema.findField("person_struct").type().asStructType().fields());
+      GenericRecord person = GenericRecord.create(personSchema);
+      person.setField("name", "Jane");
+      person.setField("address", "Apple Park");
+      GenericRecord struct = GenericRecord.create(structSchema);
+      struct.setField("id", 1);
+      struct.setField("person_struct", person);
+      GenericRecord genericRecord = GenericRecord.create(icebergSchema);
+      genericRecord.setField("partition_field", "partition_value");
+      genericRecord.setField("struct_of_struct", struct);
+      return genericRecord;
+    }
+
+    @Override
+    public RowData generateFlinkRowData() {
+      return GenericRowData.of(
+          StringData.fromString("partition_value"),
+          GenericRowData.of(
+              1,
+              GenericRowData.of(
+                  StringData.fromString("Jane"), StringData.fromString("Apple Park"))));
+    }
+  }
+
+  public static class ArrayOfPrimitive implements DataGenerator {
+    private final Schema icebergSchema =
+        new Schema(
+            Types.NestedField.required(1, "partition_field", Types.StringType.get()),
+            Types.NestedField.required(
+                2, "array_of_int", Types.ListType.ofRequired(101, Types.IntegerType.get())));
+
+    private final RowType flinkRowType = FlinkSchemaUtil.convert(icebergSchema);
+
+    @Override
+    public Schema icebergSchema() {
+      return icebergSchema;
+    }
+
+    @Override
+    public RowType flinkRowType() {
+      return flinkRowType;
+    }
+
+    @Override
+    public GenericRecord generateIcebergGenericRecord() {
+      GenericRecord genericRecord = GenericRecord.create(icebergSchema);
+      genericRecord.setField("partition_field", "partition_value");
+      genericRecord.setField("array_of_int", Arrays.asList(1, 2, 3));
+      return genericRecord;
+    }
+
+    @Override
+    public RowData generateFlinkRowData() {
+      Integer[] arr = {1, 2, 3};

Review Comment:
   `generateIcebergGenericRecord` needs a list as `Arrays.asList(1, 2, 3)` . so it is not reusable. 



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] stevenzwu commented on pull request #6377: Flink: add util class to generate test data with extensive coverage d…

Posted by GitBox <gi...@apache.org>.
stevenzwu commented on PR #6377:
URL: https://github.com/apache/iceberg/pull/6377#issuecomment-1348983387

   @pvary I missed the FixedType because of this code snippet in Iceberg
   
   ```
     private static final ImmutableMap<String, PrimitiveType> TYPES =
         ImmutableMap.<String, PrimitiveType>builder()
             .put(BooleanType.get().toString(), BooleanType.get())
             .put(IntegerType.get().toString(), IntegerType.get())
             .put(LongType.get().toString(), LongType.get())
             .put(FloatType.get().toString(), FloatType.get())
             .put(DoubleType.get().toString(), DoubleType.get())
             .put(DateType.get().toString(), DateType.get())
             .put(TimeType.get().toString(), TimeType.get())
             .put(TimestampType.withZone().toString(), TimestampType.withZone())
             .put(TimestampType.withoutZone().toString(), TimestampType.withoutZone())
             .put(StringType.get().toString(), StringType.get())
             .put(UUIDType.get().toString(), UUIDType.get())
             .put(BinaryType.get().toString(), BinaryType.get())
             .buildOrThrow();
   ```


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] chenjunjiedada commented on pull request #6377: Flink: add util class to generate test data with extensive coverage d…

Posted by GitBox <gi...@apache.org>.
chenjunjiedada commented on PR #6377:
URL: https://github.com/apache/iceberg/pull/6377#issuecomment-1345455704

   In flink-1.13 test source, we have `RandomRowData` class that should work.
   
   


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org