You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by lz...@apache.org on 2020/09/23 02:25:38 UTC
[flink] branch release-1.11 updated: [FLINK-19227][table] The
catalog is still created after opening failed in catalog registering
This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch release-1.11
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/release-1.11 by this push:
new 7129b18 [FLINK-19227][table] The catalog is still created after opening failed in catalog registering
7129b18 is described below
commit 7129b18ef7ab0a331bd8503088247f0c345ee571
Author: zhuxiaoshang <31...@users.noreply.github.com>
AuthorDate: Wed Sep 23 10:22:25 2020 +0800
[FLINK-19227][table] The catalog is still created after opening failed in catalog registering
This closes #13414
---
.../apache/flink/table/catalog/CatalogManager.java | 2 +-
.../table/catalog/GenericInMemoryCatalogTest.java | 26 ++++++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java b/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java
index f80efd1..e047dfe 100644
--- a/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java
+++ b/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java
@@ -187,8 +187,8 @@ public final class CatalogManager {
throw new CatalogException(format("Catalog %s already exists.", catalogName));
}
- catalogs.put(catalogName, catalog);
catalog.open();
+ catalogs.put(catalogName, catalog);
}
/**
diff --git a/flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogTest.java b/flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogTest.java
index a016236..0e36a72 100644
--- a/flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogTest.java
+++ b/flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogTest.java
@@ -18,6 +18,7 @@
package org.apache.flink.table.catalog;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
import org.apache.flink.table.catalog.stats.CatalogColumnStatistics;
import org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataBase;
import org.apache.flink.table.catalog.stats.CatalogColumnStatisticsDataBinary;
@@ -30,6 +31,7 @@ import org.apache.flink.table.catalog.stats.CatalogTableStatistics;
import org.apache.flink.table.catalog.stats.Date;
import org.apache.flink.table.functions.TestGenericUDF;
import org.apache.flink.table.functions.TestSimpleUDF;
+import org.apache.flink.table.utils.TableEnvironmentMock;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -37,7 +39,9 @@ import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
+import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -169,4 +173,26 @@ public class GenericInMemoryCatalogTest extends CatalogTestBase {
protected CatalogFunction createPythonFunction() {
return new CatalogFunctionImpl("test.func1", FunctionLanguage.PYTHON);
}
+
+ @Test
+ public void testRegisterCatalog() {
+ final TableEnvironmentMock tableEnv = TableEnvironmentMock.getStreamingInstance();
+ try {
+ tableEnv.registerCatalog(TEST_CATALOG_NAME, new MyCatalog(TEST_CATALOG_NAME));
+ } catch (CatalogException e) {
+ }
+ assertThat(tableEnv.getCatalog(TEST_CATALOG_NAME).isPresent(), equalTo(false));
+ }
+
+ class MyCatalog extends GenericInMemoryCatalog {
+
+ public MyCatalog(String name) {
+ super(name);
+ }
+
+ @Override
+ public void open() {
+ throw new CatalogException("open catalog failed.");
+ }
+ }
}