From 32fd276b92f71f0333e3caa26bfcc218adb321cb Mon Sep 17 00:00:00 2001 From: harveyyue Date: Mon, 11 Nov 2024 17:30:38 +0800 Subject: [PATCH] [core] Fix merge schemas equal method issue --- .../paimon/schema/SchemaMergingUtilsTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/paimon-core/src/test/java/org/apache/paimon/schema/SchemaMergingUtilsTest.java b/paimon-core/src/test/java/org/apache/paimon/schema/SchemaMergingUtilsTest.java index 8ad40852721ab..bfc6dd7aa36ba 100644 --- a/paimon-core/src/test/java/org/apache/paimon/schema/SchemaMergingUtilsTest.java +++ b/paimon-core/src/test/java/org/apache/paimon/schema/SchemaMergingUtilsTest.java @@ -44,6 +44,7 @@ import org.assertj.core.util.Lists; import org.junit.jupiter.api.Test; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -92,6 +93,27 @@ public void testMergeTableSchemas() { assertThat(fields.get(4).type() instanceof RowType).isTrue(); } + @Test + public void testMergeTableSchemaNotChanges() { + // Init the table schema + DataField a = new DataField(0, "a", new IntType()); + DataField b = new DataField(1, "b", new DoubleType()); + TableSchema current = + new TableSchema( + 0, + Lists.newArrayList(a, b), + 3, + new ArrayList<>(), + Lists.newArrayList("a"), + new HashMap<>(), + ""); + + // fake the RowType of data with different field sequences + RowType t = new RowType(Lists.newArrayList(b, a)); + TableSchema merged = SchemaMergingUtils.mergeSchemas(current, t, false); + assertThat(merged.id()).isEqualTo(0); + } + @Test public void testMergeSchemas() { // This will test both `mergeSchemas` and `merge` methods.