rambleraptor commented on code in PR #15795:
URL: https://github.com/apache/iceberg/pull/15795#discussion_r3358965121


##########
data/src/test/java/org/apache/iceberg/data/BaseFormatModelTests.java:
##########
@@ -1803,41 +1899,66 @@ private static void assertBounds(
 
     Map<Integer, ByteBuffer> lowerBounds = file.lowerBounds();
     Map<Integer, ByteBuffer> upperBounds = file.upperBounds();
+    if (genericRecords.isEmpty()) {
+      return;
+    }
+    Types.StructType recordStruct = genericRecords.get(0).struct();
+    InternalRecordWrapper wrapper = new InternalRecordWrapper(recordStruct);
+    List<Types.NestedField> recordFields = recordStruct.fields();
     for (Types.NestedField field : schema.columns()) {
-      if (field.type().isPrimitiveType()) {
-        assertThat(lowerBounds).containsKey(field.fieldId());
-        assertThat(upperBounds).containsKey(field.fieldId());
-
-        ByteBuffer lowerBuffer = lowerBounds.get(field.fieldId());
-        ByteBuffer upperBuffer = upperBounds.get(field.fieldId());
+      if (!field.type().isPrimitiveType()) {
+        continue;
+      }
 
-        Comparator<Object> cmp = 
Comparators.forType(field.type().asPrimitiveType());
+      assertThat(lowerBounds).containsKey(field.fieldId());
+      assertThat(upperBounds).containsKey(field.fieldId());
 
-        Object[] minMax = computeMinMax(genericRecords, field, cmp);
-        Object expectedMin = minMax[0];
-        Object expectedMax = minMax[1];
+      // String bounds may be truncated by the writer; skip value comparison.
+      if (field.type().typeId() == Type.TypeID.STRING) {
+        continue;
+      }
 
-        if (expectedMin != null) {
-          assertThat(lowerBuffer).isNotNull();
-          Object actualLower = Conversions.fromByteBuffer(field.type(), 
lowerBuffer);
-          assertThat(cmp.compare(actualLower, expectedMin)).isEqualTo(0);
+      int recordPos = -1;
+      for (int i = 0; i < recordFields.size(); i++) {
+        if (recordFields.get(i).fieldId() == field.fieldId()) {
+          recordPos = i;
+          break;
         }
+      }
+      if (recordPos < 0) {
+        continue;
+      }

Review Comment:
   Yep, great call.



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