This is an automated email from the ASF dual-hosted git repository.
JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 4f4df2e74f [api] Recurse into element type in MultisetType field-id
comparison (#8519)
4f4df2e74f is described below
commit 4f4df2e74fcea466657b0c42942b6adaf16a7e2a
Author: Eunbin Son <[email protected]>
AuthorDate: Thu Jul 9 13:02:53 2026 +0900
[api] Recurse into element type in MultisetType field-id comparison (#8519)
---
.../java/org/apache/paimon/types/MultisetType.java | 30 +++++++++
.../org/apache/paimon/types/MultisetTypeTest.java | 76 ++++++++++++++++++++++
2 files changed, 106 insertions(+)
diff --git a/paimon-api/src/main/java/org/apache/paimon/types/MultisetType.java
b/paimon-api/src/main/java/org/apache/paimon/types/MultisetType.java
index e211e1d8b2..b0113450c8 100644
--- a/paimon-api/src/main/java/org/apache/paimon/types/MultisetType.java
+++ b/paimon-api/src/main/java/org/apache/paimon/types/MultisetType.java
@@ -100,6 +100,36 @@ public class MultisetType extends DataType {
return elementType.equals(that.elementType);
}
+ @Override
+ public boolean equalsIgnoreFieldId(DataType o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ if (!super.equals(o)) {
+ return false;
+ }
+ MultisetType that = (MultisetType) o;
+ return elementType.equalsIgnoreFieldId(that.elementType);
+ }
+
+ @Override
+ public boolean isPrunedFrom(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ if (!super.equals(o)) {
+ return false;
+ }
+ MultisetType that = (MultisetType) o;
+ return elementType.isPrunedFrom(that.elementType);
+ }
+
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), elementType);
diff --git
a/paimon-api/src/test/java/org/apache/paimon/types/MultisetTypeTest.java
b/paimon-api/src/test/java/org/apache/paimon/types/MultisetTypeTest.java
new file mode 100644
index 0000000000..abacf50af4
--- /dev/null
+++ b/paimon-api/src/test/java/org/apache/paimon/types/MultisetTypeTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.paimon.types;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link MultisetType}. */
+class MultisetTypeTest {
+
+ @Test
+ void testEqualsIgnoreFieldIdRecursesIntoElementType() {
+ MultisetType left =
+ DataTypes.MULTISET(DataTypes.ROW(DataTypes.FIELD(1, "f",
DataTypes.INT())));
+ MultisetType rightDifferentFieldId =
+ DataTypes.MULTISET(DataTypes.ROW(DataTypes.FIELD(2, "f",
DataTypes.INT())));
+
+ // field ids differ, but names and element types match
+ assertThat(left.equals(rightDifferentFieldId)).isFalse();
+ assertThat(left.equalsIgnoreFieldId(rightDifferentFieldId)).isTrue();
+ }
+
+ @Test
+ void testEqualsIgnoreFieldIdRejectsDifferentElement() {
+ MultisetType left =
+ DataTypes.MULTISET(DataTypes.ROW(DataTypes.FIELD(1, "f",
DataTypes.INT())));
+ MultisetType differentName =
+ DataTypes.MULTISET(DataTypes.ROW(DataTypes.FIELD(1, "g",
DataTypes.INT())));
+ MultisetType differentType =
+ DataTypes.MULTISET(DataTypes.ROW(DataTypes.FIELD(1, "f",
DataTypes.BIGINT())));
+
+ assertThat(left.equalsIgnoreFieldId(differentName)).isFalse();
+ assertThat(left.equalsIgnoreFieldId(differentType)).isFalse();
+ }
+
+ @Test
+ void testIsPrunedFromRecursesIntoElementType() {
+ MultisetType pruned =
+ DataTypes.MULTISET(DataTypes.ROW(DataTypes.FIELD(1, "f",
DataTypes.INT())));
+ MultisetType full =
+ DataTypes.MULTISET(
+ DataTypes.ROW(
+ DataTypes.FIELD(1, "f", DataTypes.INT()),
+ DataTypes.FIELD(2, "g", DataTypes.INT())));
+
+ assertThat(pruned.equals(full)).isFalse();
+ assertThat(pruned.isPrunedFrom(full)).isTrue();
+ }
+
+ @Test
+ void testIsPrunedFromRejectsDifferentElement() {
+ MultisetType left =
+ DataTypes.MULTISET(DataTypes.ROW(DataTypes.FIELD(1, "f",
DataTypes.INT())));
+ MultisetType differentType =
+ DataTypes.MULTISET(DataTypes.ROW(DataTypes.FIELD(1, "f",
DataTypes.BIGINT())));
+
+ assertThat(left.isPrunedFrom(differentType)).isFalse();
+ }
+}