This is an automated email from the ASF dual-hosted git repository.
rdblue pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/main by this push:
new ec8eb2c649 Core: Make content stats schema tests order-independent
(#18302)
ec8eb2c649 is described below
commit ec8eb2c649f38b79eda7ad2857db25a4f97d58e7
Author: Manu Zhang <[email protected]>
AuthorDate: Wed Sep 30 04:37:56 2026 +0800
Core: Make content stats schema tests order-independent (#18302)
Generated-by: Codex (GPT-6)
---
core/src/test/java/org/apache/iceberg/TestStatsUtil.java | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/core/src/test/java/org/apache/iceberg/TestStatsUtil.java
b/core/src/test/java/org/apache/iceberg/TestStatsUtil.java
index 183c4336f7..a0db67642f 100644
--- a/core/src/test/java/org/apache/iceberg/TestStatsUtil.java
+++ b/core/src/test/java/org/apache/iceberg/TestStatsUtil.java
@@ -21,9 +21,11 @@ package org.apache.iceberg;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import java.util.Comparator;
import java.util.List;
import java.util.Map;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.relocated.com.google.common.collect.Lists;
import org.apache.iceberg.types.Type;
import org.apache.iceberg.types.Types;
import org.junit.jupiter.api.Test;
@@ -565,14 +567,20 @@ public class TestStatsUtil {
}
/**
- * Assert that two struct types match in field IDs, names, optionality, and
types, ignoring docs.
+ * Assert that two struct types match in field IDs, names, optionality, and
types, ignoring field
+ * order and docs.
*/
private static void assertSameStructure(Types.StructType expected,
Types.StructType actual) {
assertThat(actual.fields()).as("Number of
fields").hasSameSizeAs(expected.fields());
- for (int i = 0; i < expected.fields().size(); i += 1) {
- Types.NestedField expectedField = expected.fields().get(i);
- Types.NestedField actualField = actual.fields().get(i);
+ List<Types.NestedField> expectedFields =
Lists.newArrayList(expected.fields());
+ List<Types.NestedField> actualFields = Lists.newArrayList(actual.fields());
+ expectedFields.sort(Comparator.comparingInt(Types.NestedField::fieldId));
+ actualFields.sort(Comparator.comparingInt(Types.NestedField::fieldId));
+
+ for (int i = 0; i < expectedFields.size(); i += 1) {
+ Types.NestedField expectedField = expectedFields.get(i);
+ Types.NestedField actualField = actualFields.get(i);
assertThat(actualField.fieldId()).as("Field
ID").isEqualTo(expectedField.fieldId());
assertThat(actualField.name()).as("Field
name").isEqualTo(expectedField.name());