Skip to content

Commit cc69883

Browse files
committed
[core] Fix manifests system table not work in REST Catalog
1 parent 01215e8 commit cc69883

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

paimon-core/src/main/java/org/apache/paimon/catalog/CatalogUtils.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,18 @@ public static Table loadTable(
226226
return toIcebergTable(identifier, schema, dataFileIO);
227227
}
228228

229+
Identifier tableIdentifier = identifier;
230+
if (identifier.isSystemTable()) {
231+
tableIdentifier =
232+
new Identifier(
233+
identifier.getDatabaseName(),
234+
identifier.getTableName(),
235+
identifier.getBranchName());
236+
}
237+
229238
CatalogEnvironment catalogEnv =
230239
new CatalogEnvironment(
231-
identifier,
240+
tableIdentifier,
232241
metadata.uuid(),
233242
catalog.catalogLoader(),
234243
lockFactory,

paimon-core/src/test/java/org/apache/paimon/catalog/CatalogTestBase.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,25 @@ public void testGetTable() throws Exception {
777777
Table dataTable = catalog.getTable(identifier);
778778
assertThat(dataTable).isNotNull();
779779

780+
// Get manifests system table and read it
781+
Table table = catalog.getTable(Identifier.create("test_db", "test_table"));
782+
BatchWriteBuilder writeBuilder = table.newBatchWriteBuilder();
783+
try (BatchTableWrite write = writeBuilder.newWrite();
784+
BatchTableCommit commit = writeBuilder.newCommit(); ) {
785+
write.write(
786+
GenericRow.of(1, BinaryString.fromString("2"), BinaryString.fromString("3")));
787+
commit.commit(write.prepareCommit());
788+
}
789+
Table manifestsTable =
790+
catalog.getTable(Identifier.create("test_db", "test_table$manifests"));
791+
ReadBuilder readBuilder = manifestsTable.newReadBuilder();
792+
List<String> manifestFiles = new ArrayList<>();
793+
readBuilder
794+
.newRead()
795+
.createReader(readBuilder.newScan().plan())
796+
.forEachRemaining(r -> manifestFiles.add(r.getString(0).toString()));
797+
assertThat(manifestFiles).hasSize(1);
798+
780799
// Get system table throws TableNotExistException when data table does not exist
781800
assertThatExceptionOfType(Catalog.TableNotExistException.class)
782801
.isThrownBy(

paimon-core/src/test/java/org/apache/paimon/jdbc/JdbcCatalogTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ private JdbcCatalog initCatalog(Map<String, String> props) {
6868
return catalog;
6969
}
7070

71+
@Override // ignore for lock error
72+
@Test
73+
public void testGetTable() throws Exception {}
74+
7175
@Test
7276
public void testAcquireLockFail() throws SQLException, InterruptedException {
7377
String lockId = "jdbc.testDb.testTable";

0 commit comments

Comments
 (0)