You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "hackergin (via GitHub)" <gi...@apache.org> on 2023/07/03 17:12:10 UTC

[GitHub] [flink] hackergin opened a new pull request, #22937: [FLINK-32428] Introduce base interfaces for CatalogStore

hackergin opened a new pull request, #22937:
URL: https://github.com/apache/flink/pull/22937

   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   *Introduce some base interfaces for CatalogStore*
   
   
   ## Brief change log
   
     - *Introduce CatalogStore Interface*
     - *Introduce CatalogStoreFactory for create CatalogStore*
     - *Introduce GenericInMemoryCatalogStore and GenericInMemoryCatalogStoreFactory*
   
   ## Verifying this change
   
   Add some unit test to test InMemoryCatalogStore and InMemoryCatalogStoreFactory
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
     - The serializers: (no)
     - The runtime per-record code paths (performance sensitive): (no)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
     - The S3 file system connector: (no)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes)
     - If yes, how is the feature documented? (JavaDocs)
   


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] leonardBang commented on a diff in pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "leonardBang (via GitHub)" <gi...@apache.org>.
leonardBang commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1257836980


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * The {@link CatalogStore} is used in {@link CatalogManager} to retrieve, save and remove {@link
+ * CatalogDescriptor} at the external storage system.
+ */
+@PublicEvolving
+public interface CatalogStore {
+
+    /**
+     * Store a catalog under the given catalog name. The catalog name must be unique.

Review Comment:
   minor: Stores



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * The {@link CatalogStore} is used in {@link CatalogManager} to retrieve, save and remove {@link
+ * CatalogDescriptor} at the external storage system.
+ */

Review Comment:
   let's try to define the interface firstly instead of explain it.
   ```suggestion
   /**
    * Represents the storage where persists all {@link Catalog}s.
    *
    * <p>All catalogs can be lazy initialized with the {@link CatalogStore}.
    *
    * <p>It can be used in {@code CatalogManager} to retrieve, save and remove catalog in {@link
    * CatalogDescriptor} format at the external storage system.
    */
   ```



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * The {@link CatalogStore} is used in {@link CatalogManager} to retrieve, save and remove {@link
+ * CatalogDescriptor} at the external storage system.
+ */
+@PublicEvolving
+public interface CatalogStore {
+
+    /**
+     * Store a catalog under the given catalog name. The catalog name must be unique.
+     *
+     * @param catalogName the given catalog name under which to store the given catalog
+     * @param catalog catalog descriptor to store
+     * @throws CatalogException throw when registration failed
+     */
+    void storeCatalog(String catalogName, CatalogDescriptor catalog) throws CatalogException;
+
+    /**
+     * Remove a catalog with the given catalog name. The catalog name must be existed.

Review Comment:
   The javadoc` The catalog name must be existed.` is mismatched with parameter `ignoreIfNotExists `
    



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/factories/CatalogStoreFactory.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.factories;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.configuration.ReadableConfig;
+import org.apache.flink.table.catalog.CatalogStore;
+
+import java.util.Map;
+
+/**
+ * A factory to create configured catalog store instances based on string-based properties. See also
+ * {@link Factory} for more information.
+ */
+@PublicEvolving
+public interface CatalogStoreFactory extends Factory {
+
+    /** Creates a {@link CatalogStore} instance from context information. */
+    CatalogStore createCatalogStore(Context context);
+
+    /** Initialize the CatalogStoreFactory. */
+    void open(Context context);
+
+    /** Close the CatalogStoreFactory. */
+    void close();

Review Comment:
   Why a factory need the Initialization and tear-down methods? Please give more explanation to developers. Maybe we known the reason as the FLIP participates but other developer would confuse a lot. 



##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStoreTest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.configuration.Configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+/** Test for {@link GenericInMemoryCatalogStore}. */
+public class GenericInMemoryCatalogStoreTest {
+
+    @Test
+    void testStoreAndGet() {
+        CatalogStore catalogStore = new GenericInMemoryCatalogStore();
+        catalogStore.open();
+
+        catalogStore.storeCatalog(
+                "catalog1", CatalogDescriptor.of("catalog1", new Configuration()));
+        assertThat(catalogStore.getCatalog("catalog1").isPresent()).isTrue();
+        assertThat(catalogStore.contains("catalog1")).isTrue();
+
+        catalogStore.removeCatalog("catalog1", true);
+        assertThat(catalogStore.contains("catalog1")).isFalse();
+
+        catalogStore.close();

Review Comment:
   Could we use `catalogStore` after it is closed? what's the expected behavior ?



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hackergin commented on a diff in pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "hackergin (via GitHub)" <gi...@apache.org>.
hackergin commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1259408171


##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStoreTest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.configuration.Configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+/** Test for {@link GenericInMemoryCatalogStore}. */
+public class GenericInMemoryCatalogStoreTest {
+
+    @Test
+    void testStoreAndGet() {
+        CatalogStore catalogStore = new GenericInMemoryCatalogStore();
+        catalogStore.open();
+
+        catalogStore.storeCatalog(
+                "catalog1", CatalogDescriptor.of("catalog1", new Configuration()));
+        assertThat(catalogStore.getCatalog("catalog1").isPresent()).isTrue();
+        assertThat(catalogStore.contains("catalog1")).isTrue();
+
+        catalogStore.removeCatalog("catalog1", true);
+        assertThat(catalogStore.contains("catalog1")).isFalse();
+
+        catalogStore.close();

Review Comment:
   I think this may depend on the specific implementation of CatalogStoreFactory. 
   
   In GenericInMemoryCatalogStoreFactory, it’s close methods do not handle any logic, just like InMemoryCatalog. So even after closing, you can still continue to use the getCatalog method. 
   
   However, based on the current usage flow of CatalogStore, this situation is unlikely to occur. 
   
   I also tried to create a CatalogStoreFactory that cannot continue to use getCatalog after closing, but I think it may be redundant and this process should be controlled by the specific implementation logic. Therefore, I did not add related tests in this PullRequest. 
   
   What do you think?



##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStoreTest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.configuration.Configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+/** Test for {@link GenericInMemoryCatalogStore}. */
+public class GenericInMemoryCatalogStoreTest {
+
+    @Test
+    void testStoreAndGet() {
+        CatalogStore catalogStore = new GenericInMemoryCatalogStore();
+        catalogStore.open();
+
+        catalogStore.storeCatalog(
+                "catalog1", CatalogDescriptor.of("catalog1", new Configuration()));
+        assertThat(catalogStore.getCatalog("catalog1").isPresent()).isTrue();
+        assertThat(catalogStore.contains("catalog1")).isTrue();
+
+        catalogStore.removeCatalog("catalog1", true);
+        assertThat(catalogStore.contains("catalog1")).isFalse();
+
+        catalogStore.close();

Review Comment:
   I think this may depend on the specific implementation of CatalogStoreFactory. 
   
   In GenericInMemoryCatalogStoreFactory, it’s close methods do not handle any logic, just like InMemoryCatalog. So even after closing, you can still continue to use the getCatalog method. 
   
   However, based on the current usage flow of CatalogStore, this situation is unlikely to occur. 
   
   I also tried to create a CatalogStoreFactory that cannot continue to use getCatalog after closing, but I think it may be redundant and this process should be controlled by the specific implementation logic. Therefore, I did not add related tests in this PullRequest. 
   
   What do you think?



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] ferenc-csaky commented on a diff in pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "ferenc-csaky (via GitHub)" <gi...@apache.org>.
ferenc-csaky commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1260909612


##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStoreTest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.configuration.Configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+/** Test for {@link GenericInMemoryCatalogStore}. */
+public class GenericInMemoryCatalogStoreTest {
+
+    @Test
+    void testStoreAndGet() {
+        CatalogStore catalogStore = new GenericInMemoryCatalogStore();
+        catalogStore.open();
+
+        catalogStore.storeCatalog(
+                "catalog1", CatalogDescriptor.of("catalog1", new Configuration()));
+        assertThat(catalogStore.getCatalog("catalog1").isPresent()).isTrue();
+        assertThat(catalogStore.contains("catalog1")).isTrue();
+
+        catalogStore.removeCatalog("catalog1", true);
+        assertThat(catalogStore.contains("catalog1")).isFalse();
+
+        catalogStore.close();

Review Comment:
   IMO managing the state check of a `CatalogStore` outside of would not be an optimal approach, cause it would require anything that accesses a `CatalogStore` to do the same thing. I'd let the `CatalogStore` itself to manage its own state, so for the current scenario maybe we could initialize the in-memory map in the `open()` mehod, and clear/dereference it in the `close()`. We could store an `opened` or `closed` flag for it and based on that throw an exception for any access if the catalog store is not yet opened or closed already.
   
   WDYT?



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] ferenc-csaky commented on a diff in pull request #22937: [FLINK-32428] Introduce base interfaces for CatalogStore

Posted by "ferenc-csaky (via GitHub)" <gi...@apache.org>.
ferenc-csaky commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1252099831


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/factories/CatalogStoreFactory.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.factories;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.configuration.ReadableConfig;
+import org.apache.flink.table.catalog.CatalogStore;
+
+import java.util.Map;
+
+/**
+ * A factory to create configured catalog store instances based on string-based properties. See also
+ * {@link Factory} for more information.
+ */
+@PublicEvolving
+public interface CatalogStoreFactory extends Factory {
+
+    /** Creates a {@link CatalogStore} instance from context information. */
+    CatalogStore createCatalogStore(Context context);
+
+    /** Initialization method for the CatalogStoreFactory. */
+    void open(Context context);
+
+    /** Tear-down method for the CatalogStoreFactory. */
+    void close();
+
+    interface Context {

Review Comment:
   According to the already existing examples for the inner context interface, this should be marked as `@PublicEvolving` too. And missing javadoc for the interface generates a checkstyle error and fails the compile.



##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStore.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+/** A generic catalog store implementation that store all catalog configuration in memory. */
+public class GenericInMemoryCatalogStore implements CatalogStore {
+
+    Map<String, CatalogDescriptor> descriptors;

Review Comment:
   I think this field should be `private final`, there is no reinit and outside access for it.



##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStoreFactoryTest.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.table.factories.CatalogStoreFactory;
+import org.apache.flink.table.factories.FactoryUtil;
+
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+/** Test for {@link GenericInMemoryCatalogFactoryTest} */
+public class GenericInMemoryCatalogStoreFactoryTest {
+
+    @Test

Review Comment:
   We should sue JUnit5 instead of JUnit4.



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogDescriptor.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.configuration.Configuration;
+
+/** Describes {@link Catalog} with catalogName and configuration */
+@PublicEvolving
+public class CatalogDescriptor {
+    /* Catalog name */

Review Comment:
   Missing period at the end, generates checkstyle error.



##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStoreTest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.configuration.Configuration;
+
+import org.junit.Test;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+/** Test for {@link GenericInMemoryCatalogStore} */
+public class GenericInMemoryCatalogStoreTest {
+
+    @Test

Review Comment:
   We should sue JUnit5 instead of JUnit4.



##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStoreFactory.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.configuration.ConfigOption;
+import org.apache.flink.table.factories.CatalogStoreFactory;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/** Catalog store factory for {@link GenericInMemoryCatalogStore}. */
+public class GenericInMemoryCatalogStoreFactory implements CatalogStoreFactory {
+    @Override
+    public CatalogStore createCatalogStore(Context context) {
+        return new GenericInMemoryCatalogStore();
+    }
+
+    @Override
+    public void open(Context context) {}
+
+    @Override
+    public void close() {}
+
+    @Override
+    public String factoryIdentifier() {
+        return GenericInMemoryCatalogStoreFactoryOptions.IDENTIFIER;
+    }
+
+    @Override
+    public Set<ConfigOption<?>> requiredOptions() {
+        return new HashSet<>();
+    }
+
+    @Override
+    public Set<ConfigOption<?>> optionalOptions() {
+        return new HashSet<>();
+    }

Review Comment:
   Both of these options should not change after read, so IMO returning `Collections.emptySet()` would be better here. It is immutable and also spares the instantiation of a new object.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] FangYongs commented on a diff in pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "FangYongs (via GitHub)" <gi...@apache.org>.
FangYongs commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1260950412


##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStoreTest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.configuration.Configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+/** Test for {@link GenericInMemoryCatalogStore}. */
+public class GenericInMemoryCatalogStoreTest {
+
+    @Test
+    void testStoreAndGet() {
+        CatalogStore catalogStore = new GenericInMemoryCatalogStore();
+        catalogStore.open();
+
+        catalogStore.storeCatalog(
+                "catalog1", CatalogDescriptor.of("catalog1", new Configuration()));
+        assertThat(catalogStore.getCatalog("catalog1").isPresent()).isTrue();
+        assertThat(catalogStore.contains("catalog1")).isTrue();
+
+        catalogStore.removeCatalog("catalog1", true);
+        assertThat(catalogStore.contains("catalog1")).isFalse();
+
+        catalogStore.close();

Review Comment:
   Nice, how about introducing `AbstractCatalogStore` which implements `CatalogStore` to manage `opened` and `closed` flag in `open()` and `close()` methods? I think it should be universal for all `CatalogStore`.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] leonardBang commented on pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "leonardBang (via GitHub)" <gi...@apache.org>.
leonardBang commented on PR #22937:
URL: https://github.com/apache/flink/pull/22937#issuecomment-1643649600

   CI passed, merging...
   
   https://dev.azure.com/leonardBang/Azure_CI/_build/results?buildId=780&view=logs&s=ab6e269b-88b2-5ded-2544-4aa5b1124530
   


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hackergin commented on pull request #22937: [FLINK-32428] Introduce base interfaces for CatalogStore

Posted by "hackergin (via GitHub)" <gi...@apache.org>.
hackergin commented on PR #22937:
URL: https://github.com/apache/flink/pull/22937#issuecomment-1619644414

   @flinkbot run azure


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] ferenc-csaky commented on a diff in pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "ferenc-csaky (via GitHub)" <gi...@apache.org>.
ferenc-csaky commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1261353832


##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStoreTest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.configuration.Configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+/** Test for {@link GenericInMemoryCatalogStore}. */
+public class GenericInMemoryCatalogStoreTest {
+
+    @Test
+    void testStoreAndGet() {
+        CatalogStore catalogStore = new GenericInMemoryCatalogStore();
+        catalogStore.open();
+
+        catalogStore.storeCatalog(
+                "catalog1", CatalogDescriptor.of("catalog1", new Configuration()));
+        assertThat(catalogStore.getCatalog("catalog1").isPresent()).isTrue();
+        assertThat(catalogStore.contains("catalog1")).isTrue();
+
+        catalogStore.removeCatalog("catalog1", true);
+        assertThat(catalogStore.contains("catalog1")).isFalse();
+
+        catalogStore.close();

Review Comment:
   >We could store an opened or closed flag for it and based on that throw an exception for any access of the catalog store is not yet opened or closed already.
   
   By "any access of the catalog store" I meant the catalog store should validate its state and throw an exception if necessary. IMO that means any method that actually touches the content of the catalog store, which is basically true for every method other than the `open()` and `close()`.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hackergin commented on pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "hackergin (via GitHub)" <gi...@apache.org>.
hackergin commented on PR #22937:
URL: https://github.com/apache/flink/pull/22937#issuecomment-1642970805

   @flinkbot run azure


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hackergin commented on pull request #22937: [FLINK-32428] Introduce base interfaces for CatalogStore

Posted by "hackergin (via GitHub)" <gi...@apache.org>.
hackergin commented on PR #22937:
URL: https://github.com/apache/flink/pull/22937#issuecomment-1620987697

   @ferenc-csaky Thanks for the great suggestion, I update the code. 


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] leonardBang merged pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "leonardBang (via GitHub)" <gi...@apache.org>.
leonardBang merged PR #22937:
URL: https://github.com/apache/flink/pull/22937


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] FangYongs commented on a diff in pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "FangYongs (via GitHub)" <gi...@apache.org>.
FangYongs commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1260537362


##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStoreTest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.configuration.Configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+/** Test for {@link GenericInMemoryCatalogStore}. */
+public class GenericInMemoryCatalogStoreTest {
+
+    @Test
+    void testStoreAndGet() {
+        CatalogStore catalogStore = new GenericInMemoryCatalogStore();
+        catalogStore.open();
+
+        catalogStore.storeCatalog(
+                "catalog1", CatalogDescriptor.of("catalog1", new Configuration()));
+        assertThat(catalogStore.getCatalog("catalog1").isPresent()).isTrue();
+        assertThat(catalogStore.contains("catalog1")).isTrue();
+
+        catalogStore.removeCatalog("catalog1", true);
+        assertThat(catalogStore.contains("catalog1")).isFalse();
+
+        catalogStore.close();

Review Comment:
   It's a little strange that `CatalogStore` can still be used after it is closed. Can we restrict this behavior? For example, `CatalogManager` should throw an exception when it access a closed `CatalogStore`



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] leonardBang commented on a diff in pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "leonardBang (via GitHub)" <gi...@apache.org>.
leonardBang commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1267484748


##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStoreTest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.configuration.Configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+/** Test for {@link GenericInMemoryCatalogStore}. */
+public class GenericInMemoryCatalogStoreTest {
+
+    @Test
+    void testStoreAndGet() {
+        CatalogStore catalogStore = new GenericInMemoryCatalogStore();
+        catalogStore.open();
+
+        catalogStore.storeCatalog(
+                "catalog1", CatalogDescriptor.of("catalog1", new Configuration()));
+        assertThat(catalogStore.getCatalog("catalog1").isPresent()).isTrue();
+        assertThat(catalogStore.contains("catalog1")).isTrue();
+
+        catalogStore.removeCatalog("catalog1", true);
+        assertThat(catalogStore.contains("catalog1")).isFalse();
+
+        catalogStore.close();

Review Comment:
   +1



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] leonardBang commented on a diff in pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "leonardBang (via GitHub)" <gi...@apache.org>.
leonardBang commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1267487839


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/AbstractCatalogStore.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.util.Preconditions;
+
+/** The AbstractCatalogStore class is an abstract base class for implementing a catalog store. */
+public abstract class AbstractCatalogStore implements CatalogStore {
+
+    /** Catalog store state. */
+    protected boolean isOpen;
+
+    /** Opens the catalog store. */
+    @Override
+    public void open() {
+        isOpen = true;
+    }
+
+    /** Closes the catalog store. */
+    @Override
+    public void close() {
+        isOpen = false;
+    }
+
+    /**
+     * Checks whether the catalog store is currently open.
+     *
+     * @throws IllegalStateException if the store is closed
+     */
+    protected void checkOpenState() {
+        Preconditions.checkState(isOpen, "Catalog store is not open.");

Review Comment:
   ```suggestion
           Preconditions.checkState(isOpen, "CatalogStore is not opened yet.");
   ```



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] FangYongs commented on a diff in pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "FangYongs (via GitHub)" <gi...@apache.org>.
FangYongs commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1260545206


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/factories/CatalogStoreFactory.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.factories;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.configuration.ReadableConfig;
+import org.apache.flink.table.catalog.CatalogStore;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Map;
+
+/**
+ * A factory to create configured catalog store instances based on string-based properties. See also
+ * {@link Factory} for more information.
+ *
+ * <p>This factory is specifically designed for the Flink SQL gateway scenario, where different
+ * catalog stores need to be created for different sessions.
+ *
+ * <p>If the CatalogStore is implemented using JDBC, this factory can be used to create a JDBC
+ * connection pool in the open method. This connection pool can then be reused for subsequent
+ * catalog store creations.
+ *
+ * <p>The following examples implementation of CatalogStoreFactory using jdbc.
+ *
+ * <pre>{@code
+ *     public class JdbcCatalogStore implements CatalogStore {
+ *
+ *         private JdbcConnectionPool jdbcConnectionPool;
+ *         public JdbcCatalogStore(JdbcConnectionPool jdbcConnectionPool) {
+ *             this.jdbcConnectionPool = jdbcConnectionPool;
+ *         }
+ *         ...
+ *     }
+ *
+ *     public class JdbcCatalogStoreFactory implements CatalogStoreFactory {
+ *
+ *         private JdbcConnectionPool jdbcConnectionPool;
+ *
+ *         @Override
+ *         public CatalogStore createCatalogStore(Context context) {
+ *             return new JdbcCatalogStore(jdbcConnectionPool);
+ *         }
+ *
+ *         @Override
+ *         public void open(Context context) throws CatalogException {
+ *             // initialize the thread pool using options from context
+ *             jdbcConnectionPool = initializeJdbcConnectionPool(context);
+ *         }
+ *         ...

Review Comment:
   Add `close` for JdbcCatalogStoreFactory? I think the `close` is very special for jdbc catalog store factory



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] flinkbot commented on pull request #22937: [FLINK-32428] Introduce base interfaces for CatalogStore

Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #22937:
URL: https://github.com/apache/flink/pull/22937#issuecomment-1618910367

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "47270e09a01c1852192a14c269ff5c8fbe5fd04e",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "47270e09a01c1852192a14c269ff5c8fbe5fd04e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 47270e09a01c1852192a14c269ff5c8fbe5fd04e UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] ferenc-csaky commented on a diff in pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "ferenc-csaky (via GitHub)" <gi...@apache.org>.
ferenc-csaky commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1266636153


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/AbstractCatalogStore.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.util.Preconditions;
+
+/** The AbstractCatalogStore class is an abstract base class for implementing a catalog store. */
+public abstract class AbstractCatalogStore implements CatalogStore {
+
+    private boolean isOpen;
+
+    /** Opens the catalog store. */
+    @Override
+    public void open() {
+        isOpen = true;
+    }
+
+    /** Closes the catalog store. */
+    @Override
+    public void close() {
+        isOpen = false;
+    }
+
+    /**
+     * Returns whether the catalog store is currently open.
+     *
+     * @return true if the store is open, false otherwise
+     */
+    public boolean isOpen() {
+        return isOpen;
+    }
+
+    /**
+     * Checks whether the catalog store is currently open.
+     *
+     * @throws IllegalStateException if the store is closed
+     */
+    public void checkOpenState() {
+        Preconditions.checkState(isOpen(), "Catalog store is not open.");
+    }

Review Comment:
   nit: Is it necessary to make these `public`? I feel like this won't be really useful outside the catalog store itself, so I may drop the getter and make `checkOpenState` and the boolean field itself `protected`.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] ruanhang1993 commented on a diff in pull request #22937: [FLINK-32428] Introduce base interfaces for CatalogStore

Posted by "ruanhang1993 (via GitHub)" <gi...@apache.org>.
ruanhang1993 commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1252649833


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogDescriptor.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.configuration.Configuration;
+
+/** Describes {@link Catalog} with catalogName and configuration. */

Review Comment:
   ```java
   /**
    * Describes a {@link Catalog} with the catalog name and configuration.
    *
    * <p>A {@link CatalogDescriptor} is a template for creating a {@link Catalog} instance. It
    * closely resembles the "CREATE CATALOG" SQL DDL statement, containing catalog name and catalog configuration. 
    * A {@link CatalogDescriptor} could be stored to {@link CatalogStore}. 
    * 
    * <p>This can be used to register a catalog in the Table API, see {@link
    * TableEnvironment#createCatalog(String, CatalogDescriptor)}.
    */
   ```



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogDescriptor.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.configuration.Configuration;
+
+/** Describes {@link Catalog} with catalogName and configuration. */
+@PublicEvolving
+public class CatalogDescriptor {
+
+    /* Catalog name */
+    private final String catalogName;
+
+    /* The configuration used to discover and construct the catalog. */
+    private final Configuration configuration;
+
+    public String getCatalogName() {
+        return catalogName;
+    }
+
+    public Configuration getConfiguration() {
+        return configuration;
+    }
+
+    private CatalogDescriptor(String catalogName, Configuration configuration) {
+        this.catalogName = catalogName;
+        this.configuration = configuration;
+    }
+
+    /**
+     * @param catalogName CatalogName of the register catalog.
+     * @param configuration Catalog configuration to the catalog instance.
+     * @return
+     */

Review Comment:
   ```java
   /**
        * Creates an instance of this interface.
        *
        * @param catalogName the name of the catalog
        * @param configuration the configuration of the catalog
        */
   ```



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * This interface describes the behavior of retrieving, saving, or deleting Catalog configurations
+ * from an external storage system.
+ */
+@PublicEvolving
+public interface CatalogStore {
+
+    /**
+     * Store a catalog under the give name. The catalog name must be unique.
+     *
+     * @param catalogName name under which to register the given catalog
+     * @param catalog catalog instance to store
+     * @throws CatalogException if the registration of the catalog under the given name failed
+     */
+    void storeCatalog(String catalogName, CatalogDescriptor catalog) throws CatalogException;
+
+    /**
+     * Unregisters a catalog under the given name. The catalog name must be existed.
+     *
+     * @param catalogName name under which to unregister the given catalog.

Review Comment:
   the given catalog name



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * This interface describes the behavior of retrieving, saving, or deleting Catalog configurations
+ * from an external storage system.
+ */
+@PublicEvolving
+public interface CatalogStore {
+
+    /**
+     * Store a catalog under the give name. The catalog name must be unique.
+     *
+     * @param catalogName name under which to register the given catalog
+     * @param catalog catalog instance to store
+     * @throws CatalogException if the registration of the catalog under the given name failed
+     */
+    void storeCatalog(String catalogName, CatalogDescriptor catalog) throws CatalogException;
+
+    /**
+     * Unregisters a catalog under the given name. The catalog name must be existed.
+     *
+     * @param catalogName name under which to unregister the given catalog.
+     * @param ignoreIfNotExists If false exception will be thrown if the table or database or
+     *     catalog to be altered does not exist.
+     * @throws CatalogException if the unregistration of the catalog under the given name failed
+     */
+    void removeCatalog(String catalogName, boolean ignoreIfNotExists) throws CatalogException;
+
+    /**
+     * Gets a catalog by name.
+     *
+     * @param catalogName name of the catalog to retrieve
+     * @return the requested catalog or empty if it does not exist
+     */
+    Optional<CatalogDescriptor> getCatalog(String catalogName);
+
+    /**
+     * Retrieves names of all registered catalogs.
+     *
+     * @return a set of names of registered catalogs
+     */
+    Set<String> listCatalogs();
+
+    /**
+     * Check if there is a corresponding catalog with the given name in CatalogStore.
+     *
+     * @return whether there is a corresponding Catalog with the given name
+     */
+    boolean contains(String catalogName);
+
+    /** Initialization method for the CatalogStore. */
+    void open();
+
+    /** Tear-down method for the CatalogStore. */

Review Comment:
   Close the catalog store.



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * This interface describes the behavior of retrieving, saving, or deleting Catalog configurations
+ * from an external storage system.
+ */
+@PublicEvolving
+public interface CatalogStore {
+
+    /**
+     * Store a catalog under the give name. The catalog name must be unique.
+     *
+     * @param catalogName name under which to register the given catalog
+     * @param catalog catalog instance to store
+     * @throws CatalogException if the registration of the catalog under the given name failed
+     */
+    void storeCatalog(String catalogName, CatalogDescriptor catalog) throws CatalogException;
+
+    /**
+     * Unregisters a catalog under the given name. The catalog name must be existed.
+     *
+     * @param catalogName name under which to unregister the given catalog.
+     * @param ignoreIfNotExists If false exception will be thrown if the table or database or
+     *     catalog to be altered does not exist.
+     * @throws CatalogException if the unregistration of the catalog under the given name failed
+     */
+    void removeCatalog(String catalogName, boolean ignoreIfNotExists) throws CatalogException;
+
+    /**
+     * Gets a catalog by name.
+     *
+     * @param catalogName name of the catalog to retrieve
+     * @return the requested catalog or empty if it does not exist
+     */
+    Optional<CatalogDescriptor> getCatalog(String catalogName);
+
+    /**
+     * Retrieves names of all registered catalogs.

Review Comment:
   the names of



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * This interface describes the behavior of retrieving, saving, or deleting Catalog configurations
+ * from an external storage system.
+ */
+@PublicEvolving
+public interface CatalogStore {
+
+    /**
+     * Store a catalog under the give name. The catalog name must be unique.
+     *
+     * @param catalogName name under which to register the given catalog
+     * @param catalog catalog instance to store
+     * @throws CatalogException if the registration of the catalog under the given name failed

Review Comment:
   throw when the registration failed



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * This interface describes the behavior of retrieving, saving, or deleting Catalog configurations
+ * from an external storage system.
+ */
+@PublicEvolving
+public interface CatalogStore {
+
+    /**
+     * Store a catalog under the give name. The catalog name must be unique.
+     *
+     * @param catalogName name under which to register the given catalog
+     * @param catalog catalog instance to store

Review Comment:
   catalog descriptor to store



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * This interface describes the behavior of retrieving, saving, or deleting Catalog configurations
+ * from an external storage system.
+ */
+@PublicEvolving
+public interface CatalogStore {
+
+    /**
+     * Store a catalog under the give name. The catalog name must be unique.
+     *
+     * @param catalogName name under which to register the given catalog
+     * @param catalog catalog instance to store
+     * @throws CatalogException if the registration of the catalog under the given name failed
+     */
+    void storeCatalog(String catalogName, CatalogDescriptor catalog) throws CatalogException;
+
+    /**
+     * Unregisters a catalog under the given name. The catalog name must be existed.

Review Comment:
   Remove a catalog with the given catalog name.



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * This interface describes the behavior of retrieving, saving, or deleting Catalog configurations
+ * from an external storage system.
+ */
+@PublicEvolving
+public interface CatalogStore {
+
+    /**
+     * Store a catalog under the give name. The catalog name must be unique.
+     *
+     * @param catalogName name under which to register the given catalog
+     * @param catalog catalog instance to store
+     * @throws CatalogException if the registration of the catalog under the given name failed
+     */
+    void storeCatalog(String catalogName, CatalogDescriptor catalog) throws CatalogException;
+
+    /**
+     * Unregisters a catalog under the given name. The catalog name must be existed.
+     *
+     * @param catalogName name under which to unregister the given catalog.
+     * @param ignoreIfNotExists If false exception will be thrown if the table or database or
+     *     catalog to be altered does not exist.
+     * @throws CatalogException if the unregistration of the catalog under the given name failed

Review Comment:
   throw when the removal operation failed



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * This interface describes the behavior of retrieving, saving, or deleting Catalog configurations
+ * from an external storage system.
+ */

Review Comment:
   ```java
   /**
    * The {@link CatalogStore} is used in {@link CatalogManager} to retrieve, save and remove {@link CatalogDescriptor} at the
    * external storage system. 
   */
   ```



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * This interface describes the behavior of retrieving, saving, or deleting Catalog configurations
+ * from an external storage system.
+ */
+@PublicEvolving
+public interface CatalogStore {
+
+    /**
+     * Store a catalog under the give name. The catalog name must be unique.
+     *
+     * @param catalogName name under which to register the given catalog
+     * @param catalog catalog instance to store
+     * @throws CatalogException if the registration of the catalog under the given name failed
+     */
+    void storeCatalog(String catalogName, CatalogDescriptor catalog) throws CatalogException;
+
+    /**
+     * Unregisters a catalog under the given name. The catalog name must be existed.
+     *
+     * @param catalogName name under which to unregister the given catalog.
+     * @param ignoreIfNotExists If false exception will be thrown if the table or database or
+     *     catalog to be altered does not exist.

Review Comment:
   whether throw an exception when the catalog does not exist.



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * This interface describes the behavior of retrieving, saving, or deleting Catalog configurations
+ * from an external storage system.
+ */
+@PublicEvolving
+public interface CatalogStore {
+
+    /**
+     * Store a catalog under the give name. The catalog name must be unique.
+     *
+     * @param catalogName name under which to register the given catalog

Review Comment:
   the given catalog name



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * This interface describes the behavior of retrieving, saving, or deleting Catalog configurations
+ * from an external storage system.
+ */
+@PublicEvolving
+public interface CatalogStore {
+
+    /**
+     * Store a catalog under the give name. The catalog name must be unique.
+     *
+     * @param catalogName name under which to register the given catalog
+     * @param catalog catalog instance to store
+     * @throws CatalogException if the registration of the catalog under the given name failed
+     */
+    void storeCatalog(String catalogName, CatalogDescriptor catalog) throws CatalogException;
+
+    /**
+     * Unregisters a catalog under the given name. The catalog name must be existed.
+     *
+     * @param catalogName name under which to unregister the given catalog.
+     * @param ignoreIfNotExists If false exception will be thrown if the table or database or
+     *     catalog to be altered does not exist.
+     * @throws CatalogException if the unregistration of the catalog under the given name failed
+     */
+    void removeCatalog(String catalogName, boolean ignoreIfNotExists) throws CatalogException;
+
+    /**
+     * Gets a catalog by name.
+     *
+     * @param catalogName name of the catalog to retrieve
+     * @return the requested catalog or empty if it does not exist

Review Comment:
   if the catalog does not exist



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * This interface describes the behavior of retrieving, saving, or deleting Catalog configurations
+ * from an external storage system.
+ */
+@PublicEvolving
+public interface CatalogStore {
+
+    /**
+     * Store a catalog under the give name. The catalog name must be unique.
+     *
+     * @param catalogName name under which to register the given catalog
+     * @param catalog catalog instance to store
+     * @throws CatalogException if the registration of the catalog under the given name failed
+     */
+    void storeCatalog(String catalogName, CatalogDescriptor catalog) throws CatalogException;
+
+    /**
+     * Unregisters a catalog under the given name. The catalog name must be existed.
+     *
+     * @param catalogName name under which to unregister the given catalog.
+     * @param ignoreIfNotExists If false exception will be thrown if the table or database or
+     *     catalog to be altered does not exist.
+     * @throws CatalogException if the unregistration of the catalog under the given name failed
+     */
+    void removeCatalog(String catalogName, boolean ignoreIfNotExists) throws CatalogException;
+
+    /**
+     * Gets a catalog by name.

Review Comment:
   Get



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * This interface describes the behavior of retrieving, saving, or deleting Catalog configurations
+ * from an external storage system.
+ */
+@PublicEvolving
+public interface CatalogStore {
+
+    /**
+     * Store a catalog under the give name. The catalog name must be unique.
+     *
+     * @param catalogName name under which to register the given catalog
+     * @param catalog catalog instance to store
+     * @throws CatalogException if the registration of the catalog under the given name failed
+     */
+    void storeCatalog(String catalogName, CatalogDescriptor catalog) throws CatalogException;
+
+    /**
+     * Unregisters a catalog under the given name. The catalog name must be existed.
+     *
+     * @param catalogName name under which to unregister the given catalog.
+     * @param ignoreIfNotExists If false exception will be thrown if the table or database or
+     *     catalog to be altered does not exist.
+     * @throws CatalogException if the unregistration of the catalog under the given name failed
+     */
+    void removeCatalog(String catalogName, boolean ignoreIfNotExists) throws CatalogException;
+
+    /**
+     * Gets a catalog by name.
+     *
+     * @param catalogName name of the catalog to retrieve
+     * @return the requested catalog or empty if it does not exist
+     */
+    Optional<CatalogDescriptor> getCatalog(String catalogName);
+
+    /**
+     * Retrieves names of all registered catalogs.
+     *
+     * @return a set of names of registered catalogs
+     */
+    Set<String> listCatalogs();
+
+    /**
+     * Check if there is a corresponding catalog with the given name in CatalogStore.

Review Comment:
   Return whether the catalog exists in the catalog store.



##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStoreFactoryOptions.java:
##########
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.configuration.ConfigOption;
+
+/** {@link ConfigOption}s for {@link GenericInMemoryCatalogStore}. */
+public class GenericInMemoryCatalogStoreFactoryOptions {
+    public static final String IDENTIFIER = "generic_in_memory";

Review Comment:
   private GenericInMemoryCatalogStoreFactoryOptions() {}



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/factories/CatalogStoreFactory.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.factories;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.configuration.ReadableConfig;
+import org.apache.flink.table.catalog.CatalogStore;
+
+import java.util.Map;
+
+/**
+ * A factory to create configured catalog store instances based on string-based properties. See also
+ * {@link Factory} for more information.
+ */
+@PublicEvolving
+public interface CatalogStoreFactory extends Factory {
+
+    /** Creates a {@link CatalogStore} instance from context information. */
+    CatalogStore createCatalogStore(Context context);
+
+    /** Initialization method for the CatalogStoreFactory. */
+    void open(Context context);
+
+    /** Tear-down method for the CatalogStoreFactory. */
+    void close();
+
+    /** Context provided when a catalog store is created. */
+    @PublicEvolving
+    interface Context {
+
+        /**
+         * Returns the options with which the catalog store is created.
+         *
+         * <p>An implementation should perform validation of these options.
+         */
+        Map<String, String> getOptions();
+
+        /** Gives read-only access to the configuration of the current session. */
+        ReadableConfig getConfiguration();
+
+        /**
+         * Returns the class loader of the current session.
+         *
+         * <p>The class loader is in particular useful for discovering further (nested) factories.
+         */
+        ClassLoader getClassLoader();
+    }
+
+    /** Default implementation of {@link CatalogStoreFactory.Context}. */
+    @Internal
+    class DefaultCatalogStoreContext implements CatalogStoreFactory.Context {

Review Comment:
   Maybe this default implementation should be put at `FactoryUtil`?



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * This interface describes the behavior of retrieving, saving, or deleting Catalog configurations
+ * from an external storage system.
+ */
+@PublicEvolving
+public interface CatalogStore {
+
+    /**
+     * Store a catalog under the give name. The catalog name must be unique.
+     *
+     * @param catalogName name under which to register the given catalog
+     * @param catalog catalog instance to store
+     * @throws CatalogException if the registration of the catalog under the given name failed
+     */
+    void storeCatalog(String catalogName, CatalogDescriptor catalog) throws CatalogException;
+
+    /**
+     * Unregisters a catalog under the given name. The catalog name must be existed.
+     *
+     * @param catalogName name under which to unregister the given catalog.
+     * @param ignoreIfNotExists If false exception will be thrown if the table or database or
+     *     catalog to be altered does not exist.
+     * @throws CatalogException if the unregistration of the catalog under the given name failed
+     */
+    void removeCatalog(String catalogName, boolean ignoreIfNotExists) throws CatalogException;
+
+    /**
+     * Gets a catalog by name.
+     *
+     * @param catalogName name of the catalog to retrieve
+     * @return the requested catalog or empty if it does not exist
+     */
+    Optional<CatalogDescriptor> getCatalog(String catalogName);
+
+    /**
+     * Retrieves names of all registered catalogs.
+     *
+     * @return a set of names of registered catalogs

Review Comment:
   the names of registered catalogs



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * This interface describes the behavior of retrieving, saving, or deleting Catalog configurations
+ * from an external storage system.
+ */
+@PublicEvolving
+public interface CatalogStore {
+
+    /**
+     * Store a catalog under the give name. The catalog name must be unique.
+     *
+     * @param catalogName name under which to register the given catalog
+     * @param catalog catalog instance to store
+     * @throws CatalogException if the registration of the catalog under the given name failed
+     */
+    void storeCatalog(String catalogName, CatalogDescriptor catalog) throws CatalogException;
+
+    /**
+     * Unregisters a catalog under the given name. The catalog name must be existed.
+     *
+     * @param catalogName name under which to unregister the given catalog.
+     * @param ignoreIfNotExists If false exception will be thrown if the table or database or
+     *     catalog to be altered does not exist.
+     * @throws CatalogException if the unregistration of the catalog under the given name failed
+     */
+    void removeCatalog(String catalogName, boolean ignoreIfNotExists) throws CatalogException;
+
+    /**
+     * Gets a catalog by name.
+     *
+     * @param catalogName name of the catalog to retrieve
+     * @return the requested catalog or empty if it does not exist
+     */
+    Optional<CatalogDescriptor> getCatalog(String catalogName);
+
+    /**
+     * Retrieves names of all registered catalogs.
+     *
+     * @return a set of names of registered catalogs
+     */
+    Set<String> listCatalogs();
+
+    /**
+     * Check if there is a corresponding catalog with the given name in CatalogStore.
+     *
+     * @return whether there is a corresponding Catalog with the given name
+     */
+    boolean contains(String catalogName);
+
+    /** Initialization method for the CatalogStore. */

Review Comment:
   Initialize the catalog store.



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CatalogStore.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * This interface describes the behavior of retrieving, saving, or deleting Catalog configurations
+ * from an external storage system.
+ */
+@PublicEvolving
+public interface CatalogStore {
+
+    /**
+     * Store a catalog under the give name. The catalog name must be unique.
+     *
+     * @param catalogName name under which to register the given catalog
+     * @param catalog catalog instance to store
+     * @throws CatalogException if the registration of the catalog under the given name failed
+     */
+    void storeCatalog(String catalogName, CatalogDescriptor catalog) throws CatalogException;
+
+    /**
+     * Unregisters a catalog under the given name. The catalog name must be existed.
+     *
+     * @param catalogName name under which to unregister the given catalog.
+     * @param ignoreIfNotExists If false exception will be thrown if the table or database or
+     *     catalog to be altered does not exist.
+     * @throws CatalogException if the unregistration of the catalog under the given name failed
+     */
+    void removeCatalog(String catalogName, boolean ignoreIfNotExists) throws CatalogException;
+
+    /**
+     * Gets a catalog by name.
+     *
+     * @param catalogName name of the catalog to retrieve
+     * @return the requested catalog or empty if it does not exist
+     */
+    Optional<CatalogDescriptor> getCatalog(String catalogName);
+
+    /**
+     * Retrieves names of all registered catalogs.
+     *
+     * @return a set of names of registered catalogs
+     */
+    Set<String> listCatalogs();
+
+    /**
+     * Check if there is a corresponding catalog with the given name in CatalogStore.
+     *
+     * @return whether there is a corresponding Catalog with the given name

Review Comment:
   Remove this `@reutrn`.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] ferenc-csaky commented on a diff in pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "ferenc-csaky (via GitHub)" <gi...@apache.org>.
ferenc-csaky commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1261056641


##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStoreTest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.configuration.Configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+/** Test for {@link GenericInMemoryCatalogStore}. */
+public class GenericInMemoryCatalogStoreTest {
+
+    @Test
+    void testStoreAndGet() {
+        CatalogStore catalogStore = new GenericInMemoryCatalogStore();
+        catalogStore.open();
+
+        catalogStore.storeCatalog(
+                "catalog1", CatalogDescriptor.of("catalog1", new Configuration()));
+        assertThat(catalogStore.getCatalog("catalog1").isPresent()).isTrue();
+        assertThat(catalogStore.contains("catalog1")).isTrue();
+
+        catalogStore.removeCatalog("catalog1", true);
+        assertThat(catalogStore.contains("catalog1")).isFalse();
+
+        catalogStore.close();

Review Comment:
   +1, that makes sense to me.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] ferenc-csaky commented on a diff in pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "ferenc-csaky (via GitHub)" <gi...@apache.org>.
ferenc-csaky commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1261353832


##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStoreTest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.configuration.Configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+/** Test for {@link GenericInMemoryCatalogStore}. */
+public class GenericInMemoryCatalogStoreTest {
+
+    @Test
+    void testStoreAndGet() {
+        CatalogStore catalogStore = new GenericInMemoryCatalogStore();
+        catalogStore.open();
+
+        catalogStore.storeCatalog(
+                "catalog1", CatalogDescriptor.of("catalog1", new Configuration()));
+        assertThat(catalogStore.getCatalog("catalog1").isPresent()).isTrue();
+        assertThat(catalogStore.contains("catalog1")).isTrue();
+
+        catalogStore.removeCatalog("catalog1", true);
+        assertThat(catalogStore.contains("catalog1")).isFalse();
+
+        catalogStore.close();

Review Comment:
   >We could store an opened or closed flag for it and based on that throw an exception for any access if the catalog store is not yet opened or closed already.
   
   By "any access of the catalog store" I meant the catalog store should validate its state and throw an exception if necessary. IMO that means any method that actually touches the content of the catalog store, which is basically true for every method other than the `open()` and `close()`.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] FangYongs commented on a diff in pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "FangYongs (via GitHub)" <gi...@apache.org>.
FangYongs commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1260543524


##########
flink-table/flink-table-common/src/test/java/org/apache/flink/table/factories/CatalogStoreFactoryTest.java:
##########
@@ -0,0 +1,9 @@
+package org.apache.flink.table.factories;
+
+import org.junit.jupiter.api.Test;
+

Review Comment:
   Add license and doc



##########
flink-table/flink-table-common/src/test/java/org/apache/flink/table/factories/TestCatalogStoreFactory.java:
##########
@@ -0,0 +1,87 @@
+package org.apache.flink.table.factories;
+
+import org.apache.flink.configuration.ConfigOption;
+import org.apache.flink.table.catalog.CatalogDescriptor;
+import org.apache.flink.table.catalog.CatalogStore;
+import org.apache.flink.table.catalog.exceptions.CatalogException;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+

Review Comment:
   Add license and doc



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hackergin commented on a diff in pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "hackergin (via GitHub)" <gi...@apache.org>.
hackergin commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1265634150


##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStoreTest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.configuration.Configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+/** Test for {@link GenericInMemoryCatalogStore}. */
+public class GenericInMemoryCatalogStoreTest {
+
+    @Test
+    void testStoreAndGet() {
+        CatalogStore catalogStore = new GenericInMemoryCatalogStore();
+        catalogStore.open();
+
+        catalogStore.storeCatalog(
+                "catalog1", CatalogDescriptor.of("catalog1", new Configuration()));
+        assertThat(catalogStore.getCatalog("catalog1").isPresent()).isTrue();
+        assertThat(catalogStore.contains("catalog1")).isTrue();
+
+        catalogStore.removeCatalog("catalog1", true);
+        assertThat(catalogStore.contains("catalog1")).isFalse();
+
+        catalogStore.close();

Review Comment:
   I add the `AbastractCatalogStore` that store the open state and change the state when `open()` and `close`. 
   And I add a `checkState` method for state checking,  and `isOpen` for getting state status. 
   And now `GenericInMemoryCatalog` extends to `AbastractCatalogStore` and I add state check in  `getCatalog`, `listCatalogs`, `contains` , `removeCatalog`.  
   
   WDYT? @ferenc-csaky @FangYongs @leonardBang 



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hackergin commented on pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "hackergin (via GitHub)" <gi...@apache.org>.
hackergin commented on PR #22937:
URL: https://github.com/apache/flink/pull/22937#issuecomment-1641407812

   @flinkbot run azure


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hackergin commented on pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "hackergin (via GitHub)" <gi...@apache.org>.
hackergin commented on PR #22937:
URL: https://github.com/apache/flink/pull/22937#issuecomment-1643437682

   @flinkbot  run azure


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hackergin commented on a diff in pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "hackergin (via GitHub)" <gi...@apache.org>.
hackergin commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1261189996


##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStoreTest.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.configuration.Configuration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+/** Test for {@link GenericInMemoryCatalogStore}. */
+public class GenericInMemoryCatalogStoreTest {
+
+    @Test
+    void testStoreAndGet() {
+        CatalogStore catalogStore = new GenericInMemoryCatalogStore();
+        catalogStore.open();
+
+        catalogStore.storeCatalog(
+                "catalog1", CatalogDescriptor.of("catalog1", new Configuration()));
+        assertThat(catalogStore.getCatalog("catalog1").isPresent()).isTrue();
+        assertThat(catalogStore.contains("catalog1")).isTrue();
+
+        catalogStore.removeCatalog("catalog1", true);
+        assertThat(catalogStore.contains("catalog1")).isFalse();
+
+        catalogStore.close();

Review Comment:
   This is indeed more general, but if we are only adding a flag, should we control the default behavior? For example, for `getCatalog`, should we check whether it is in a `closed` state or an `opened` state? Otherwise, simply adding a flag may not have much effect. However, in that case, we will need to add another method to `AbastractCatalogStore` for the actual implementation of `getCatalog`.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hackergin commented on a diff in pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "hackergin (via GitHub)" <gi...@apache.org>.
hackergin commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1266703598


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/AbstractCatalogStore.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.util.Preconditions;
+
+/** The AbstractCatalogStore class is an abstract base class for implementing a catalog store. */
+public abstract class AbstractCatalogStore implements CatalogStore {
+
+    private boolean isOpen;
+
+    /** Opens the catalog store. */
+    @Override
+    public void open() {
+        isOpen = true;
+    }
+
+    /** Closes the catalog store. */
+    @Override
+    public void close() {
+        isOpen = false;
+    }
+
+    /**
+     * Returns whether the catalog store is currently open.
+     *
+     * @return true if the store is open, false otherwise
+     */
+    public boolean isOpen() {
+        return isOpen;
+    }
+
+    /**
+     * Checks whether the catalog store is currently open.
+     *
+     * @throws IllegalStateException if the store is closed
+     */
+    public void checkOpenState() {
+        Preconditions.checkState(isOpen(), "Catalog store is not open.");
+    }

Review Comment:
   Make sense to me. I updated the code. 



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] leonardBang commented on a diff in pull request #22937: [FLINK-32428][table] Introduce base interfaces for CatalogStore

Posted by "leonardBang (via GitHub)" <gi...@apache.org>.
leonardBang commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1267521123


##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/AbstractCatalogStore.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.util.Preconditions;
+
+/** The AbstractCatalogStore class is an abstract base class for implementing a catalog store. */
+public abstract class AbstractCatalogStore implements CatalogStore {
+
+    /** Catalog store state. */
+    protected boolean isOpen;
+
+    /** Opens the catalog store. */
+    @Override
+    public void open() {
+        isOpen = true;
+    }
+
+    /** Closes the catalog store. */
+    @Override
+    public void close() {
+        isOpen = false;
+    }
+
+    /**
+     * Checks whether the catalog store is currently open.
+     *
+     * @throws IllegalStateException if the store is closed
+     */
+    protected void checkOpenState() {
+        Preconditions.checkState(isOpen, "Catalog store is not open.");

Review Comment:
   Related tests should be adjusted 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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] ruanhang1993 commented on a diff in pull request #22937: [FLINK-32428] Introduce base interfaces for CatalogStore

Posted by "ruanhang1993 (via GitHub)" <gi...@apache.org>.
ruanhang1993 commented on code in PR #22937:
URL: https://github.com/apache/flink/pull/22937#discussion_r1253856457


##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/catalog/GenericInMemoryCatalogStoreFactoryTest.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.catalog;
+
+import org.apache.flink.table.factories.CatalogStoreFactory;
+import org.apache.flink.table.factories.FactoryUtil;
+import org.apache.flink.table.factories.FactoryUtil.DefaultCatalogStoreContext;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+/** Test for {@link GenericInMemoryCatalogFactoryTest}. */

Review Comment:
   Test for {@link GenericInMemoryCatalogFactory}



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hackergin commented on pull request #22937: [FLINK-32428] Introduce base interfaces for CatalogStore

Posted by "hackergin (via GitHub)" <gi...@apache.org>.
hackergin commented on PR #22937:
URL: https://github.com/apache/flink/pull/22937#issuecomment-1622791724

   @ruanhang1993  Thank you very much for your thoughtful and detailed comments.  I update the code, I will pay more attention to annotations and documentation.


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [flink] hackergin commented on pull request #22937: [FLINK-32428] Introduce base interfaces for CatalogStore

Posted by "hackergin (via GitHub)" <gi...@apache.org>.
hackergin commented on PR #22937:
URL: https://github.com/apache/flink/pull/22937#issuecomment-1619653235

   @leonardBang @ruanhang1993  Please help to review this PR when you're free, thanks 
   


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org