You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by sn...@apache.org on 2023/09/10 21:32:40 UTC

[flink] branch release-1.18 updated: [FLINK-32796][docs] Extend catalog store documentation (#23294)

This is an automated email from the ASF dual-hosted git repository.

snuyanzin pushed a commit to branch release-1.18
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.18 by this push:
     new 97d116645e3 [FLINK-32796][docs] Extend catalog store documentation (#23294)
97d116645e3 is described below

commit 97d116645e3048af21475280b46ae54bd3efc731
Author: Ferenc Csaky <fe...@pm.me>
AuthorDate: Sun Sep 10 23:32:33 2023 +0200

    [FLINK-32796][docs] Extend catalog store documentation (#23294)
---
 docs/content/docs/dev/table/catalogs.md            | 93 ++++++++++++----------
 .../catalog/FileCatalogStoreFactoryOptions.java    |  2 +-
 .../flink/table/catalog/CommonCatalogOptions.java  |  3 +-
 3 files changed, 56 insertions(+), 42 deletions(-)

diff --git a/docs/content/docs/dev/table/catalogs.md b/docs/content/docs/dev/table/catalogs.md
index 49474377269..09ba385f20b 100644
--- a/docs/content/docs/dev/table/catalogs.md
+++ b/docs/content/docs/dev/table/catalogs.md
@@ -853,13 +853,14 @@ of catalogs created in the session will be persisted in the corresponding extern
 Even if the session is reconstructed, previously created catalogs can still be retrieved from Catalog Store.
 
 ### Configure Catalog Store
+
 Users can configure the Catalog Store in different ways, one is to use the Table API, and another is to use YAML configuration.
 
-Register a catalog store using catalog store instance.
+Register a catalog store using catalog store instance:
 
 ```java
 // Initialize a catalog Store instance
-CatalogStore catalogStore = new FileCatalogStore("file://path/to/catalog/store/");
+CatalogStore catalogStore = new FileCatalogStore("file:///path/to/catalog/store/");
 
 // set up the catalog store
 final EnvironmentSettings settings =
@@ -868,13 +869,13 @@ final EnvironmentSettings settings =
         .build();
 ```
 
-Register a catalog store using configuration.
+Register a catalog store using configuration:
 
 ```java 
 // Set up configuration
 Configuration configuration = new Configuration();
 configuration.set("table.catalog-store.kind", "file");
-configuration.set("table.catalog-store.file.path", "file://path/to/catalog/store/");
+configuration.set("table.catalog-store.file.path", "file:///path/to/catalog/store/");
 // set up the configuration.
 final EnvironmentSettings settings =
         EnvironmentSettings.newInstance().inBatchMode()
@@ -887,40 +888,41 @@ final TableEnvironment tableEnv = TableEnvironment.create(settings);
 In SQL Gateway, it is recommended to configure the settings in a yaml file so that all sessions can automatically
 use the pre-created Catalog. Usually, you need to configure the kind of Catalog Store and other
 required parameters for the Catalog Store.
+
 ```yaml
 table.catalog-store.kind: file
-table.catalog-store.file.path: /path/to/catalog/store/
+table.catalog-store.file.path: file:///path/to/catalog/store/
 ```
 
 ### Catalog Store Type
-Flink has two built-in Catalog Stores, namely GenericInMemoryCatalogStore and FileCatalogStore.
-Users can also customize their own Catalog Store.
+
+Flink has two built-in Catalog Stores, namely `GenericInMemoryCatalogStore` and `FileCatalogStore`,
+but the Catalog Store model is extendable, so users can also implement their own custom Catalog Store.
 
 #### GenericInMemoryCatalogStore
-GenericInMemoryCatalogStore is an implementation of CatalogStore that saves configuration information in memory.
-All catalog configurations are only available within the session's lifecycle, and the stored catalog configurations will be
-automatically cleared after session reconstruction.
 
-<table class="table table-bordered">
-    <thead>
-      <tr>
-        <th class="text-left" style="width: 25%">Option</th>
-        <th class="text-center" style="width: 45%">Description</th>
-      </tr>
-    </thead>
-    <tbody>
-    <tr>
-      <td><h5>kind</h5></td>
-      <td>Specify the Catalog Store type to be used, which should be 'generic_in_memory'</td>
-    </tr>
-    </tbody>
-</table>
+`GenericInMemoryCatalogStore` is an implementation of `CatalogStore` that saves configuration information in memory.
+All catalog configurations are only available within the sessions' lifecycle, and the stored catalog configurations will be
+automatically cleared after the session is closed.
+
+{{< hint info >}}
+By default, if no Catalog Store related configuration is specified, the system uses this implementation.
+{{< /hint >}}
 
 #### FileCatalogStore
-FileCatalogStore can save the user's Catalog configuration to a file. To use FileCatalogStore, you need to specify the directory where the Catalog configuration
-needs to be saved. Different Catalogs will correspond to different files and each file will correspond to a Catalog Name.
 
-Here's an example directory structure representing the storage of Catalog configurations using FileCatalogStore:
+`FileCatalogStore` can save the Catalog configuration to a file. To use `FileCatalogStore`, you need to specify the directory where the Catalog configurations
+needs to be saved. Each Catalog will have its own file named the same as the Catalog Name.
+
+The `FileCatalogStore` implementation supports both local and remote file systems that are available via the [Flink `FileSystem` abstraction]({{< ref "docs/deployment/filesystems/overview" >}}).
+If the given Catalog Store path does not exist either completely or partly, `FileCatalogStore` will try to create the missing directories.
+
+{{< hint warning >}}
+If the given Catalog Store path does not exist and `FileCatalogStore` fails to create a directory, the Catalog Store cannot be initialized, hence an exception will be thrown.
+In case the `FileCatalogstore` initialization is not successful, both SQL Client and SQL Gateway will be broken.
+{{< /hint >}}
+
+Here is an example directory structure representing the storage of Catalog configurations using `FileCatalogStore`:
 
 ```shell
 - /path/to/save/the/catalog/
@@ -929,26 +931,37 @@ Here's an example directory structure representing the storage of Catalog config
   - catalog3.yaml
 ```
 
-<table class="table table-bordered">
+#### Catalog Store Configuration
+
+The following options can be used to adjust the Catalog Store behavior.
+
+<table class="configuration table table-bordered">
     <thead>
-      <tr>
-        <th class="text-left" style="width: 25%">Option</th>
-        <th class="text-center" style="width: 45%">Description</th>
-      </tr>
+        <tr>
+            <th class="text-left" style="width: 20%">Key</th>
+            <th class="text-left" style="width: 15%">Default</th>
+            <th class="text-left" style="width: 10%">Type</th>
+            <th class="text-left" style="width: 55%">Description</th>
+        </tr>
     </thead>
     <tbody>
-    <tr>
-      <td><h5>kind</h5></td>
-      <td>Specify the Catalog Store type to be used, which should be 'file'</td>
-    </tr>
-    <tr>
-      <td><h5>path</h5></td>
-      <td>Specify the path to be used for saving in the Catalog Store, it must be a valid directory and currently only supports local directories.</td>
-    </tr>
+        <tr>
+            <td><h5>table.catalog-store.kind</h5></td>
+            <td style="word-wrap: break-word;">"generic_in_memory"</td>
+            <td>String</td>
+            <td>The kind of catalog store to be used. Out of the box, 'generic_in_memory' and 'file' options are supported.</td>
+        </tr>
+        <tr>
+            <td><h5>table.catalog-store.file.path</h5></td>
+            <td style="word-wrap: break-word;">(none)</td>
+            <td>String</td>
+            <td>The configuration option for specifying the path to the file catalog store root directory.</td>
+        </tr>
     </tbody>
 </table>
 
 #### Custom Catalog Store
+
 Catalog Store is extensible, and users can customize Catalog Store by implementing its interface.
 If SQL CLI or SQL Gateway needs to use Catalog Store, the corresponding CatalogStoreFactory interface
 also needs to be implemented for this Catalog Store.
diff --git a/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/FileCatalogStoreFactoryOptions.java b/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/FileCatalogStoreFactoryOptions.java
index 7e1a30c1c51..5a7a82c9766 100644
--- a/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/FileCatalogStoreFactoryOptions.java
+++ b/flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/FileCatalogStoreFactoryOptions.java
@@ -31,7 +31,7 @@ public class FileCatalogStoreFactoryOptions {
                     .stringType()
                     .noDefaultValue()
                     .withDescription(
-                            "The configuration option for specifying the path to the file catalog store.");
+                            "The configuration option for specifying the path to the file catalog store root directory.");
 
     private FileCatalogStoreFactoryOptions() {}
 }
diff --git a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CommonCatalogOptions.java b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CommonCatalogOptions.java
index 9f1b009fc55..218b01fdd9b 100644
--- a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CommonCatalogOptions.java
+++ b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/catalog/CommonCatalogOptions.java
@@ -47,7 +47,8 @@ public class CommonCatalogOptions {
             ConfigOptions.key("table.catalog-store.kind")
                     .stringType()
                     .defaultValue(DEFAULT_CATALOG_STORE_KIND)
-                    .withDescription("The kind of catalog store to be used.");
+                    .withDescription(
+                            "The kind of catalog store to be used. Out of the box, 'generic_in_memory' and 'file' options are supported.");
 
     /** Used to filter the specific options for catalog store. */
     public static final String TABLE_CATALOG_STORE_OPTION_PREFIX = "table.catalog-store.";