You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/07/03 23:35:52 UTC

[GitHub] [flink] xuefuz commented on a change in pull request #8976: [FLINK-12277][table/hive/doc] Add documentation for catalogs

xuefuz commented on a change in pull request #8976: [FLINK-12277][table/hive/doc] Add documentation for catalogs
URL: https://github.com/apache/flink/pull/8976#discussion_r300186939
 
 

 ##########
 File path: docs/dev/table/catalog.md
 ##########
 @@ -0,0 +1,344 @@
+---
+title: "Catalog"
+is_beta: true
+nav-parent_id: tableapi
+nav-pos: 100
+---
+<!--
+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.
+-->
+
+A catalog can provide information about metadata, such as names, schemas, statistics of tables, and information about how to access data stored in a database or table. Once a catalog is registered to a `TableEnvironment`, all meta-objects defined in a catalog can be accessed from Table API or SQL queries.
+
+
+* This will be replaced by the TOC
+{:toc}
+
+
+Catalog Interface
+-----------------
+
+APIs are defined in `Catalog` interface. The interface defines a set of APIs to read and write catalog meta-objects such as database, tables, partitions, views, and functions.
+
+Users can develop their own catalogs by implementing the interface.
+
+
+Naming Structure in Catalog
+---------------------------
+
+Flink's catalogs use a strict two-level structure, that is, catalogs contain databases, and databases contain meta-objects. Thus, the full name of a meta-object is always structured as `catalogName`.`databaseName`.`objectName`.
+
+All registered catalogs are managed by a `CatalogManager` instance in `TableEnvironment`. In order to ease access to meta-objects, `CatalogManager` has a concept of current catalog and current database. Usually how users access meta-objects in a catalog is to specify its full name in the format of `catalogName`.`databaseName`.`objectName`. By setting current catalog and current database, users can use just the meta-object's name in their queries. This greatly simplifies user experience. For example, a previous query as
+
+```sql
+select * from mycatalog.mydb.myTable;
+```
+
+can be shortened as
+
+```sql
+select * from myTable;
+```
+
+Querying tables in a different databases under the default catalog would be
+
+```
+select * from mydb2.myTable
+```
+
+`CatalogManager` always has a built-in `GenericInMemoryCatalog` with name of `default_catalog`, which has a built-in default database named `default_database`. They will be the current catalog and current database if no other catalog and database are explicitly set. All temp meta-objects will be registered to this catalog. Users can set current catalog and database via `TableEnvironment.useCatalog(...)` and `TableEnvironment.useDatabase(...)` in Table API, or `USE CATALOG ...` and `USE DATABASE ...` in Flink SQL.
+
+
+Catalog Types
+-------------
+
+## GenericInMemoryCatalog
+
+All meta-objects in this catalog are stored in memory, and be will lost once the session shuts down.
+
+Its config entry value in SQL CLI yaml file is "generic_in_memory".
+
+## HiveCatalog
+
+`HiveCatalog` can read and write both Flink and Hive meta-objects by using Hive Metastore as a persistent storage.
+
+Its config entry value in SQL CLI yaml file is "hive".
+
+### Persist Flink meta-objects
+
+Previously, Flink meta-objects are only stored in memory and are per session based. That means users have to recreate all the meta-objects every time they start a new session.
+
+To solve this user pain point, we use `HiveCatalog` to persist all of users' Flink streaming and batch meta-objects by using Hive Metastore as a pure storage. Because Hive Metastore is only used for storage in this case, Hive itself may not understand Flink's meta-objects stored in the metastore.
 
 Review comment:
   I think use HiveCatalog to store flink meta-objects is optional, up to user's choice. Thus, it may make sense to see "one can use ..." rather than "we use ...".

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services