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 63ea34f1ee [core] Keep SnapshotNotExistPlan when query auth rules wrap 
a stream plan (#10940)
63ea34f1ee is described below

commit 63ea34f1eeeaec80d06ba22e8b8790e1a5721076
Author: YangJie <[email protected]>
AuthorDate: Mon Nov 2 09:41:14 2026 -0500

    [core] Keep SnapshotNotExistPlan when query auth rules wrap a stream plan 
(#10940)
---
 .../paimon/catalog/TableQueryAuthResult.java       |  4 +-
 .../org/apache/paimon/rest/RESTCatalogTest.java    | 27 ++++++++++
 .../org/apache/paimon/flink/RESTCatalogITCase.java | 61 ++++++++++++++++++++++
 3 files changed, 91 insertions(+), 1 deletion(-)

diff --git 
a/paimon-core/src/main/java/org/apache/paimon/catalog/TableQueryAuthResult.java 
b/paimon-core/src/main/java/org/apache/paimon/catalog/TableQueryAuthResult.java
index cf3bfdf049..1a064fb7f2 100644
--- 
a/paimon-core/src/main/java/org/apache/paimon/catalog/TableQueryAuthResult.java
+++ 
b/paimon-core/src/main/java/org/apache/paimon/catalog/TableQueryAuthResult.java
@@ -33,6 +33,7 @@ import org.apache.paimon.table.SpecialFields;
 import org.apache.paimon.table.Table;
 import org.apache.paimon.table.source.DataFilePlan;
 import org.apache.paimon.table.source.QueryAuthSplit;
+import org.apache.paimon.table.source.SnapshotNotExistPlan;
 import org.apache.paimon.table.source.Split;
 import org.apache.paimon.table.source.TableScan;
 import org.apache.paimon.types.DataField;
@@ -224,7 +225,8 @@ public class TableQueryAuthResult implements Serializable {
     }
 
     public TableScan.Plan convertPlan(TableScan.Plan plan) {
-        if (!hasRules()) {
+        // SnapshotNotExistPlan has no splits; stream consumers check for it 
by identity
+        if (!hasRules() || plan instanceof SnapshotNotExistPlan) {
             return plan;
         }
         List<Split> authSplits =
diff --git 
a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java 
b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
index 7fb3b6791b..5548a3f76b 100644
--- a/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
+++ b/paimon-core/src/test/java/org/apache/paimon/rest/RESTCatalogTest.java
@@ -103,6 +103,7 @@ import org.apache.paimon.table.source.DataSplit;
 import org.apache.paimon.table.source.InnerTableScan;
 import org.apache.paimon.table.source.QueryAuthSplit;
 import org.apache.paimon.table.source.ReadBuilder;
+import org.apache.paimon.table.source.SnapshotNotExistPlan;
 import org.apache.paimon.table.source.Split;
 import org.apache.paimon.table.source.StreamTableScan;
 import org.apache.paimon.table.source.TableRead;
@@ -4668,6 +4669,32 @@ public abstract class RESTCatalogTest extends 
CatalogTestBase {
                 .hasMessageContaining("does not exist in table schema");
     }
 
+    @Test
+    void testStreamScanWithAuthRulesKeepsSnapshotNotExistPlan() throws 
Exception {
+        Identifier identifier = Identifier.create("test_table_db", 
"auth_stream_no_snapshot");
+        Table table =
+                createMaskingAuthTable(
+                        identifier, stringFields("name", "secret"), 
Collections.emptyMap());
+        setRowFilter(
+                identifier,
+                Collections.singletonList(
+                        leaf(
+                                0,
+                                "name",
+                                DataTypes.STRING(),
+                                Equal.INSTANCE,
+                                BinaryString.fromString("john"))));
+        maskConstant(identifier, "secret");
+
+        // stream consumers tell "no new snapshot yet" from an empty plan by 
this instance
+        StreamTableScan scan = table.newReadBuilder().newStreamScan();
+        assertThat(scan.plan()).isSameAs(SnapshotNotExistPlan.INSTANCE);
+
+        writeStringRow(table, "john", "s1");
+        assertThat(scan.plan().splits()).isNotEmpty();
+        assertThat(scan.plan()).isSameAs(SnapshotNotExistPlan.INSTANCE);
+    }
+
     @Test
     void testColumnMaskingRejectsNestedPrunedRuleInput() throws Exception {
         Identifier identifier =
diff --git 
a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/RESTCatalogITCase.java
 
b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/RESTCatalogITCase.java
index 74d4b2c520..ad6aac4be0 100644
--- 
a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/RESTCatalogITCase.java
+++ 
b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/RESTCatalogITCase.java
@@ -36,6 +36,7 @@ import org.apache.paimon.predicate.Transform;
 import org.apache.paimon.predicate.UpperTransform;
 import org.apache.paimon.rest.RESTToken;
 import org.apache.paimon.types.DataTypes;
+import org.apache.paimon.utils.BlockingIterator;
 
 import org.apache.paimon.shade.guava30.com.google.common.collect.ImmutableList;
 import org.apache.paimon.shade.guava30.com.google.common.collect.ImmutableMap;
@@ -56,6 +57,9 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
+import java.util.concurrent.TimeUnit;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -717,6 +721,63 @@ class RESTCatalogITCase extends RESTCatalogITCaseBase {
                 .containsExactlyInAnyOrder(Row.of(4L));
     }
 
+    @Test
+    public void testAlignedStreamingReadWithRowFilterOnEmptyTable() throws 
Exception {
+        checkAlignedStreamingReadWithRowFilter("aligned_row_filter_empty", 
false);
+    }
+
+    @Test
+    public void testAlignedStreamingReadWithRowFilter() throws Exception {
+        checkAlignedStreamingReadWithRowFilter("aligned_row_filter", true);
+    }
+
+    private void checkAlignedStreamingReadWithRowFilter(String table, boolean 
writeFirst)
+            throws Exception {
+        batchSql(
+                String.format(
+                        "CREATE TABLE %s.%s (id INT, name STRING) WITH 
('query-auth.enabled' = 'true')",
+                        DATABASE_NAME, table));
+        restCatalogServer.setRowFilterAuth(
+                Identifier.create(DATABASE_NAME, table),
+                Collections.singletonList(
+                        LeafPredicate.of(
+                                new FieldTransform(new FieldRef(0, "id", 
DataTypes.INT())),
+                                GreaterThan.INSTANCE,
+                                Collections.singletonList(0))));
+        String insert = "INSERT INTO %s.%s VALUES (%s)";
+        if (writeFirst) {
+            batchSql(String.format(insert, DATABASE_NAME, table, "1, 'a'"));
+        }
+
+        BlockingIterator<Row, Row> iter =
+                streamSqlBlockIter(
+                        "SELECT * FROM %s.%s /*+ 
OPTIONS('source.checkpoint-align.enabled' = 'true', "
+                                + "'continuous.discovery-interval' = '100 ms') 
*/",
+                        DATABASE_NAME, table);
+        CompletableFuture<List<Row>> result =
+                CompletableFuture.supplyAsync(
+                        () -> {
+                            try {
+                                return iter.collect(1, 60, TimeUnit.SECONDS);
+                            } catch (Exception e) {
+                                throw new CompletionException(e);
+                            }
+                        });
+        try {
+            if (!writeFirst) {
+                batchSql(String.format(insert, DATABASE_NAME, table, "1, 
'a'"));
+            }
+            // an aligned checkpoint waits for a new snapshot, so keep 
committing rows the row
+            // filter drops
+            while (!result.isDone()) {
+                batchSql(String.format(insert, DATABASE_NAME, table, "0, 
'z'"));
+            }
+            assertThat(result.get()).containsExactly(Row.of(1, "a"));
+        } finally {
+            iter.close();
+        }
+    }
+
     @Test
     public void testColumnMaskingAndRowFilter() {
         String combinedTable = "combined_auth_table";

Reply via email to