Skip to content

Commit 14b5d53

Browse files
authored
[FLINK-37093][table] Build the catalog instance before store the definition in catalog store(#25946)
1 parent be5fcaf commit 14b5d53

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,12 @@ public void createCatalog(
331331
throw new CatalogException(format("Catalog %s already exists.", catalogName));
332332
}
333333
} else {
334-
// Store the catalog in the catalog store
335-
catalogStoreHolder.catalogStore().storeCatalog(catalogName, catalogDescriptor);
336-
337334
// Initialize and store the catalog in memory
338335
Catalog catalog = initCatalog(catalogName, catalogDescriptor);
339336
catalog.open();
340337
catalogs.put(catalogName, catalog);
338+
// Store the catalog in the catalog store
339+
catalogStoreHolder.catalogStore().storeCatalog(catalogName, catalogDescriptor);
341340
}
342341
}
343342

flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/CatalogManagerTest.java

+12
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,19 @@ void testCatalogStore() throws Exception {
540540
false))
541541
.isInstanceOf(CatalogException.class)
542542
.hasMessage("Catalog cat_comment already exists.");
543+
assertThatThrownBy(
544+
() ->
545+
catalogManager.createCatalog(
546+
"cat_no_type",
547+
CatalogDescriptor.of(
548+
"cat_no_type",
549+
new Configuration(),
550+
"catalog without type"),
551+
false))
552+
.isInstanceOf(ValidationException.class)
553+
.hasMessageContaining("Unable to create catalog 'cat_no_type'.");
543554

555+
assertFalse(catalogManager.listCatalogs().contains("cat_no_type"));
544556
assertTrue(catalogManager.getCatalog("cat1").isPresent());
545557
assertTrue(catalogManager.getCatalog("cat2").isPresent());
546558
assertTrue(catalogManager.getCatalog("cat3").isPresent());

0 commit comments

Comments
 (0)