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 b9061068ea [common] Fix null literals in evolved integer predicates 
(#11120)
b9061068ea is described below

commit b9061068eaf0ed59f3cf54ca5592602b304648ea
Author: YueZhang <[email protected]>
AuthorDate: Fri Nov 13 18:55:11 2026 +0800

    [common] Fix null literals in evolved integer predicates (#11120)
---
 .../org/apache/paimon/casting/CastExecutors.java   |  3 ++
 .../apache/paimon/casting/CastExecutorTest.java    | 30 +++++++++++++++++++
 .../apache/paimon/table/SchemaEvolutionTest.java   | 34 ++++++++++++++++++++++
 3 files changed, 67 insertions(+)

diff --git 
a/paimon-common/src/main/java/org/apache/paimon/casting/CastExecutors.java 
b/paimon-common/src/main/java/org/apache/paimon/casting/CastExecutors.java
index 6822c2c3ce..1ccb430614 100644
--- a/paimon-common/src/main/java/org/apache/paimon/casting/CastExecutors.java
+++ b/paimon-common/src/main/java/org/apache/paimon/casting/CastExecutors.java
@@ -151,6 +151,9 @@ public class CastExecutors {
                             (CastExecutor<Number, Number>) 
castRule.create(predicateType, dataType);
                     List<Object> newLiterals = new 
ArrayList<>(literals.size());
                     for (Object literal : literals) {
+                        if (literal == null) {
+                            return Optional.empty();
+                        }
                         Number literalNumber = (Number) literal;
                         Number newLiteralNumber = 
castExecutor.cast(literalNumber);
                         // Ignore if any literal is overflowed.
diff --git 
a/paimon-common/src/test/java/org/apache/paimon/casting/CastExecutorTest.java 
b/paimon-common/src/test/java/org/apache/paimon/casting/CastExecutorTest.java
index bba5c0a30e..a5a05d8cae 100644
--- 
a/paimon-common/src/test/java/org/apache/paimon/casting/CastExecutorTest.java
+++ 
b/paimon-common/src/test/java/org/apache/paimon/casting/CastExecutorTest.java
@@ -52,6 +52,8 @@ import org.apache.paimon.utils.DecimalUtils;
 import org.junit.jupiter.api.Test;
 
 import java.time.LocalDateTime;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.TimeZone;
@@ -63,6 +65,34 @@ import static org.assertj.core.api.Assertions.fail;
 /** Test for {@link CastExecutor}. */
 public class CastExecutorTest {
 
+    @Test
+    public void testNullLiteralsWithEvolution() {
+        assertThat(
+                        CastExecutors.castLiteralsWithEvolution(
+                                Arrays.asList(1L, null, 3L), 
DataTypes.BIGINT(), DataTypes.INT()))
+                .isEmpty();
+        assertThat(
+                        CastExecutors.castLiteralsWithEvolution(
+                                Collections.singletonList(null),
+                                DataTypes.BIGINT(),
+                                DataTypes.INT()))
+                .isEmpty();
+        assertThat(
+                        CastExecutors.castLiteralsWithEvolution(
+                                Arrays.asList(1L, 3L), DataTypes.BIGINT(), 
DataTypes.INT()))
+                .hasValue(Arrays.asList(1, 3));
+        assertThat(
+                        CastExecutors.castLiteralsWithEvolution(
+                                Arrays.asList(1L, Long.MAX_VALUE),
+                                DataTypes.BIGINT(),
+                                DataTypes.INT()))
+                .isEmpty();
+        assertThat(
+                        CastExecutors.castLiteralsWithEvolution(
+                                Collections.emptyList(), DataTypes.BIGINT(), 
DataTypes.INT()))
+                .hasValue(Collections.emptyList());
+    }
+
     @Test
     public void testNumericToNumeric() {
         // byte to other numeric
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/table/SchemaEvolutionTest.java 
b/paimon-core/src/test/java/org/apache/paimon/table/SchemaEvolutionTest.java
index 2e2adc51a2..0d499ab416 100644
--- a/paimon-core/src/test/java/org/apache/paimon/table/SchemaEvolutionTest.java
+++ b/paimon-core/src/test/java/org/apache/paimon/table/SchemaEvolutionTest.java
@@ -39,6 +39,7 @@ import org.apache.paimon.table.sink.StreamTableWrite;
 import org.apache.paimon.table.sink.TableCommitImpl;
 import org.apache.paimon.table.source.DataSplit;
 import org.apache.paimon.table.source.InnerTableRead;
+import org.apache.paimon.table.source.ReadBuilder;
 import org.apache.paimon.table.source.Split;
 import org.apache.paimon.table.source.snapshot.SnapshotReader;
 import org.apache.paimon.types.DataField;
@@ -98,6 +99,39 @@ public class SchemaEvolutionTest {
         commitUser = UUID.randomUUID().toString();
     }
 
+    @Test
+    public void testInWithNullAfterIntegerWidening() throws Exception {
+        schemaManager.createTable(
+                new Schema(
+                        RowType.of(DataTypes.INT()).getFields(),
+                        Collections.emptyList(),
+                        Collections.emptyList(),
+                        new HashMap<>(),
+                        ""));
+        FileStoreTable table = 
FileStoreTableFactory.create(LocalFileIO.create(), tablePath);
+        try (StreamTableWrite write = table.newWrite(commitUser);
+                TableCommitImpl commit = table.newCommit(commitUser)) {
+            write.write(GenericRow.of(1));
+            write.write(GenericRow.of(2));
+            write.write(GenericRow.of(3));
+            write.write(GenericRow.of((Object) null));
+            commit.commit(0, write.prepareCommit(true, 0));
+        }
+
+        schemaManager.commitChanges(SchemaChange.updateColumnType("f0", 
DataTypes.BIGINT()));
+        table = FileStoreTableFactory.create(LocalFileIO.create(), tablePath);
+        PredicateBuilder builder = new PredicateBuilder(table.rowType());
+        ReadBuilder readBuilder =
+                table.newReadBuilder().withFilter(builder.in(0, 
Arrays.asList(1L, null, 3L)));
+        List<Long> values = new ArrayList<>();
+        readBuilder
+                .newRead()
+                .executeFilter()
+                .createReader(readBuilder.newScan().plan())
+                .forEachRemaining(row -> values.add(row.getLong(0)));
+        assertThat(values).containsExactlyInAnyOrder(1L, 3L);
+    }
+
     @Test
     public void testAddField() throws Exception {
         Schema schema =

Reply via email to