leaves12138 commented on code in PR #8770:
URL: https://github.com/apache/paimon/pull/8770#discussion_r3627397653


##########
paimon-core/src/test/java/org/apache/paimon/table/FallbackReadFileStoreTableTest.java:
##########
@@ -91,6 +99,105 @@ public void before() {
         fileIO = FileIOFinder.find(tablePath);
     }
 
+    @Test
+    public void testScanForwardsReadType() {
+        FileStoreTable mainTable = Mockito.mock(FileStoreTable.class);
+        FileStoreTable fallbackTable = Mockito.mock(FileStoreTable.class);
+        DataTableScan mainScan = Mockito.mock(DataTableScan.class);
+        DataTableScan fallbackScan = Mockito.mock(DataTableScan.class);
+        RowType readType = ROW_TYPE.project("a");
+
+        FallbackReadFileStoreTable.FallbackReadScan scan =
+                new FallbackReadFileStoreTable.FallbackReadScan(
+                        mainTable,
+                        fallbackTable,
+                        Mockito.mock(TableSchema.class),
+                        table -> table == mainTable ? mainScan : fallbackScan);
+
+        assertThat(scan.withReadType(readType)).isSameAs(scan);
+        Mockito.verify(mainScan).withReadType(readType);
+        Mockito.verify(fallbackScan).withReadType(readType);
+    }
+
+    @Test
+    public void testPlanAndReadWithQueryAuthSplit() throws Exception {
+        FileStoreTable mainTable = createTable();
+        writeDataIntoTable(mainTable, 0, rowData(1, 10));
+
+        mainTable.createBranch("bc");
+        FileStoreTable branchTable = createTableFromBranch(mainTable, "bc");
+        writeDataIntoTable(branchTable, 0, rowData(2, 20));
+
+        FallbackReadFileStoreTable table =
+                new FallbackReadFileStoreTable(mainTable, branchTable, true);
+        TableQueryAuthResult authResult =
+                new TableQueryAuthResult(
+                        null,
+                        Collections.singletonMap(
+                                "a",
+                                JsonSerdeUtil.toFlatJson(
+                                        new FieldTransform(
+                                                new FieldRef(0, "pt", 
DataTypes.INT())))));
+        DataTableScan scan =
+                table.newFallbackScan(
+                        fileStoreTable -> 
queryAuthScan(fileStoreTable.newScan(), authResult));
+
+        List<Split> splits = scan.plan().splits();
+        assertThat(splits).hasSize(2);
+        assertThat(splits)
+                .allSatisfy(
+                        split -> {
+                            assertThat(split)
+                                    
.isInstanceOf(FallbackReadFileStoreTable.FallbackSplit.class);
+                            Split wrapped =
+                                    
((FallbackReadFileStoreTable.FallbackSplit) split).wrapped();
+                            
assertThat(wrapped).isInstanceOf(QueryAuthSplit.class);
+                        });
+
+        List<Pair<Integer, Integer>> result = new ArrayList<>();
+        for (Split split : splits) {
+            Split deserialized =
+                    InstantiationUtil.deserializeObject(
+                            InstantiationUtil.serializeObject(split), 
getClass().getClassLoader());
+            RecordReader<InternalRow> reader = 
table.newRead().createReader(deserialized);
+            reader.forEachRemaining(r -> result.add(Pair.of(r.getInt(0), 
r.getInt(1))));
+            reader.close();
+        }
+
+        assertThat(result).containsExactlyInAnyOrder(Pair.of(1, 1), Pair.of(2, 
2));
+    }
+
+    @Test
+    public void testChainTableFallbackSplitPreservesQueryAuth() throws 
Exception {

Review Comment:
   This test only exercises the non-fallback route (`isFallback=false`) and 
bypasses real `ChainGroupReadTable` planning. With query auth enabled, the 
branch scans used by `ChainTableBatchScan` return `QueryAuthSplit`, but 
`preloadTargetSnapshotSplits` and the two sub-split collectors still cast every 
split directly to `DataSplit` (`ChainGroupReadTable.java:435`, `:443`, and 
`:497`). A real chain-table scan therefore throws `ClassCastException` before 
it reaches this reader path; I reproduced it with a `QueryAuthSplit(DataSplit)` 
plan, failing at `preloadTargetSnapshotSplits:497`. Please add a planning/read 
regression test for the `isFallback=true` chain path and preserve the auth 
wrapper when constructing/reading the resulting `ChainSplit` (the chain reader 
currently rejects `QueryAuthSplit` as well).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to