After you configure a Hologres Catalog, you can directly read Hologres metadata in the console of fully managed Flink without the need to manually register Hologres tables. Hologres Catalogs improve the efficiency of job development and ensure data accuracy. This topic describes how to configure, view, and drop a Hologres Catalog in the console of fully managed Flink.

Background information

Hologres Catalogs provide metadata, such as databases, tables, partitions, and views. The metadata also includes functions and information that are required to access data stored in a database or other external systems. For more information, see Catalogs.

You can perform the following operations to manage Hologres Catalogs:

Limits

  • Only Flink V1.13 and later allow you to configure Hologres Catalogs.
  • You are not allowed to modify the DDL statements that are related to Hologres Catalogs.

Create a Hologres Catalog

  1. Log on to the Realtime Compute for Apache Flink console.
  2. On the Fully Managed Flink tab, find the workspace that you want to manage and click Console in the Actions column.
  3. In the left-side navigation pane, click Draft Editor.
  4. In the upper-left corner of the page, click New. In the New Draft dialog box, select STREAM / SQL from the Type drop-down list.
  5. In the script editor, enter the following statement to create a Hologres Catalog.
    CREATE CATALOG <catalogname> WITH (
      'type' = 'hologres',
      'endpoint' = '<endpoint>', 
      'username' = '<username>',
      'password' = '<password>',
      'dbname' = '<dbname>'
    );
    Parameter Description Required
    catalogname The name of the Hologres Catalog.
    Note The name can contain only lowercase letters and digits. It cannot contain uppercase letters or special characters such as hyphens (-) and underscores (_).
    Yes
    type The type of the table. Set the value to hologres. Yes
    endpoint The endpoint of the Hologres instance.

    For more information, see Instance configurations.

    Yes
    username The username that is used to access the database specified by dbname. Yes
    password The password that is used to access the database specified by dbname. Yes
    dbname The name of the default Hologres database that you want to access. Yes
  6. Click Execute.
    After the statement is executed, the message "Query has been executed" appears. If you want to drop the Hologres Catalog, follow the instructions provided in Drop a Hologres Catalog.
  7. On the left side of the script editor, click the Schemas tab.
  8. Click the Refresh icon icon to refresh and view the Hologres Catalog that you created.
    Refresh icon

View a Hologres Catalog

After you create a Hologres Catalog, you can perform the following operations to view the metadata in the Hologres Catalog.

  1. Log on to the Realtime Compute for Apache Flink console.
  2. On the Fully Managed Flink tab, find the workspace that you want to manage and click Console in the Actions column.
  3. In the left-side navigation pane, click Draft Editor.
  4. Click the Schemas tab.
  5. In the top navigation bar, switch to the Hologres Catalog that you want to view. In this example, the Hologres Catalog named holo is used.
    holo
  6. View the databases, tables, and functions in the Hologres Catalog.
    Table name
    Note If the public schema is used, the schema prefix is not added to a table name. In this case, table names are directly used.

Use a Hologres Catalog

  • Create a table in Hologres.
    • Execute the USE CATALOG HoloName statement to directly reference the information of the Hologres service.
      USE CATALOG ${catalog_name};
      CREATE TABLE `${db_name}`.`${schema_name.table_name}`(
        ...
       ) WITH (
         'connector' = 'hologres'
       );
      For more information about the USE syntax, see USE statements.
    • Directly reference the information of the Hologres service in DDL statements.
      CREATE TABLE `${catalog_name}`.`${db_name}`.`${schema_name.table_name}` (
        ...
      ) WITH (
        'connector' = 'hologres'
      );
      Note
  • Read data from a Hologres table.
    INSERT INTO ${other_sink_table}
    SELECT ...
    FROM `${catalog_name}`.`${db_name}`.`${schema_name.table_name}`
  • Import result data to a Hologres table.
    INSERT INTO `${catalog_name}`.`${db_name}`.`${schema_name.table_name}`
    SELECT ... 
    FROM ${other_source_table}
Note If the public schema is used, ${table_name} is used instead of ${schema_name.table_name}. This is because the schema prefix is not added to the table name in this case.

Drop a Hologres Catalog

  1. Log on to the Realtime Compute for Apache Flink console.
  2. On the Fully Managed Flink tab, find the workspace that you want to manage and click Console in the Actions column.
  3. In the left-side navigation pane, click Draft Editor.
  4. In the upper-left corner of the page, click New. In the New Draft dialog box, select STREAM / SQL from the Type drop-down list.
  5. In the script editor, enter the following statement:
    DROP CATALOG ${catalog_name}
    catalog_name is the name of the Hologres Catalog that you want to drop from the console of fully managed Flink.
    Note The drop operation does not affect the jobs that are running. However, jobs that are not published or that need to be suspended and then resumed are affected. Proceed with caution.
  6. Click Execute.
  7. On the left side of the script editor, click the Schemas tab.
  8. Click the Refresh icon icon to refresh the page and check whether the Hologres Catalog is dropped.
    Refresh icon