CREATE CATALOG
Overview
The CREATE CATALOG statement is used to register an external catalog in the current session. A catalog is the top-level namespace for Flink metadata management, including databases, tables, views, and functions. Currently, AI DataLake supports HiveCatalog, which is used to connect to Hive Metastore to implement data interoperability between Flink and Hive.
Application Scenarios
- Hive data integration: HiveCatalog is used to access table data in Hive and perform unified stream and batch processing in Flink SQL.
- Unified metadata management: Hive metadata is incorporated into the Flink catalog system to implement unified query and management.
- Cross-data source query: After multiple catalogs are registered, you can use the fully qualified name (catalog.database.table) to query data across data sources in SQL statements.
Notes and Constraints
- To use HiveCatalog, ensure that the Hive Metastore service is available and the network is connected.
- The hive-conf-dir parameter of HiveCatalog must point to a valid Hive configuration directory that contains the hive-site.xml file.
- A catalog registered in the current session is valid only in the current session and will not be persisted to the cluster level.
- If a catalog with the same name is registered, the existing catalog will be overwritten. You need to use IF NOT EXISTS to avoid conflicts.
Syntax Structure
CREATE CATALOG [IF NOT EXISTS] catalog_name WITH (key1=val1, key2=val2, ...)
Usage Example
Example 1: Create a HiveCatalog.
-- Create a HiveCatalog. CREATE CATALOG IF NOT EXISTS myhive WITH ( 'type' = 'hive', 'default-database' = 'mydb', 'hive-conf-dir' = '/etc/hive/conf' ); -- Create a DataGen source table. CREATE TABLE datagen_source ( id BIGINT, name STRING, `value` DOUBLE ) WITH ( 'connector' = 'datagen', 'rows-per-second' = '100', 'fields.id.kind' = 'sequence', 'fields.id.start' = '1', 'fields.id.end' = '10000', 'fields.name.length' = '8', 'fields.value.min' = '0.0', 'fields.value.max' = '100.0' ); -- Create the Print result table. CREATE TABLE print_sink ( id BIGINT, name STRING, `value` DOUBLE ) WITH ( 'connector' = 'print', 'print-identifier' = 'catalog_output' ); -- Submit the job. INSERT INTO print_sink SELECT id, name, `value` FROM datagen_source;
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot