rdblue commented on code in PR #12470:
URL: https://github.com/apache/iceberg/pull/12470#discussion_r1996274844


##########
flink/v1.20/flink/src/test/java/org/apache/iceberg/flink/TestHelpers.java:
##########
@@ -187,11 +188,38 @@ public static void assertRowData(
       types.add(field.type());
     }
 
-    for (int i = 0; i < types.size(); i += 1) {
-      LogicalType logicalType = ((RowType) rowType).getTypeAt(i);
-      Object expected = expectedRecord.get(i, Object.class);
-      Object actual = FlinkRowData.createFieldGetter(logicalType, 
i).getFieldOrNull(actualRowData);
-      assertEquals(types.get(i), logicalType, expected, actual);
+    if (expectedRecord instanceof Record) {
+      Record expected = (Record) expectedRecord;
+      Types.StructType expectedType = expected.struct();
+      int pos = 0;
+      for (Types.NestedField field : structType.fields()) {
+        Types.NestedField expectedField = expectedType.field(field.fieldId());
+        LogicalType logicalType = ((RowType) rowType).getTypeAt(pos);
+        Object actualValue =
+            FlinkRowData.createFieldGetter(logicalType, 
pos).getFieldOrNull(actualRowData);
+        if (expectedField != null) {
+          assertEquals(
+              field.type(), logicalType, 
expected.getField(expectedField.name()), actualValue);
+        } else {
+          // convert the initial value to generic because that is the data 
model used to generate
+          // the expected records
+          assertEquals(
+              field.type(),
+              logicalType,
+              GenericDataUtil.internalToGeneric(field.type(), 
field.initialDefault()),
+              actualValue);
+        }
+        pos += 1;
+      }
+

Review Comment:
   For dense control flow blocks, we often leave extra newlines to make it more 
readable.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to