|
38 | 38 | import org.apache.paimon.reader.RecordReader; |
39 | 39 | import org.apache.paimon.schema.FileSystemSchemaManager; |
40 | 40 | import org.apache.paimon.schema.Schema; |
| 41 | +import org.apache.paimon.schema.SchemaChange; |
41 | 42 | import org.apache.paimon.schema.SchemaUtils; |
42 | 43 | import org.apache.paimon.schema.TableSchema; |
43 | 44 | import org.apache.paimon.table.sink.StreamTableCommit; |
@@ -538,6 +539,38 @@ public void testWriteGoesToWrapped(boolean wrappedFirst) throws Exception { |
538 | 539 | assertThat(mergedPartitions).containsExactlyInAnyOrder(1, 2, 3); |
539 | 540 | } |
540 | 541 |
|
| 542 | + @Test |
| 543 | + public void testReadPlainSplitWithPrimaryBranch() throws Exception { |
| 544 | + String branchName = "bc"; |
| 545 | + |
| 546 | + FileStoreTable mainTable = createTable(); |
| 547 | + writeDataIntoTable(mainTable, 0, rowData(1, 10)); |
| 548 | + |
| 549 | + mainTable.createBranch(branchName); |
| 550 | + FileStoreTable branchTable = createTableFromBranch(mainTable, branchName); |
| 551 | + writeDataIntoTable(branchTable, 0, rowData(2, 20)); |
| 552 | + |
| 553 | + // evolve only the main branch, so its new files use a schema id the branch lacks |
| 554 | + TableSchema newSchema = |
| 555 | + new FileSystemSchemaManager(fileIO, tablePath) |
| 556 | + .commitChanges(SchemaChange.setOption("my-custom-key", "my-value")); |
| 557 | + mainTable = mainTable.copy(newSchema); |
| 558 | + writeDataIntoTable(mainTable, 1, rowData(3, 30)); |
| 559 | + |
| 560 | + FallbackReadFileStoreTable table = |
| 561 | + new FallbackReadFileStoreTable(mainTable, branchTable, false); |
| 562 | + |
| 563 | + // splits planned by newSnapshotReader() belong to the wrapped table |
| 564 | + List<Pair<Integer, Integer>> result = new ArrayList<>(); |
| 565 | + for (Split split : table.newSnapshotReader().read().splits()) { |
| 566 | + assertThat(split).isNotInstanceOf(FallbackReadFileStoreTable.FallbackSplit.class); |
| 567 | + RecordReader<InternalRow> reader = table.newRead().createReader(split); |
| 568 | + reader.forEachRemaining(r -> result.add(Pair.of(r.getInt(0), r.getInt(1)))); |
| 569 | + reader.close(); |
| 570 | + } |
| 571 | + assertThat(result).containsExactlyInAnyOrder(Pair.of(1, 10), Pair.of(3, 30)); |
| 572 | + } |
| 573 | + |
541 | 574 | @Test |
542 | 575 | public void testFallbackReadFailFastDefaultSwallowsException() throws Exception { |
543 | 576 | FallbackReadFileStoreTable table = setUpTableWithThrowingFallback(false); |
|
0 commit comments