Updated on 2026-11-06 GMT+08:00

Managing Paimon Catalogs

After configuring a Paimon catalog for an AI DataLake Flink job, you can use AI DataLake Flink to directly access Paimon tables in Huawei Cloud LakeFormation. This section describes how to create a Paimon catalog in an AI DataLake Flink job and manage Paimon databases and tables.

Operation method: Use a tool such as Postman to call the API for Creating a Flink Job to submit a Flink job.

Creating a Paimon Catalog

CREATE CATALOG lf_paimon_catalog
WITH
  (
    'type' = 'paimon',
    'metastore' = 'lakeformation'
  );

Configuration parameters

Parameter

Description

Mandatory (Yes/No)

Remarks

type

Catalog type.

Yes

The value is fixed to paimon.

metastore

Catalog implementation type.

Yes

The value is fixed to lakeformation.

lakeformation.catalog-name

Name of the catalog in LakeFormation to be accessed.

The name must be the same as the name of the catalog created in LakeFormation.

No

The default value is the catalog name on the Flink engine side, that is, lf_paimon_catalog.

Managing Paimon Databases

  • Creating a database
    CREATE DATABASE IF NOT EXISTS lf_paimon_catalog.paimon_db
    WITH (
      'location' = 'obs://bucket/path/paimon-warehouse/paimon_db'
    );
  • Deleting a database
    DROP DATABASE lf_paimon_catalog.paimon_db; -- Only deletes databases that do not contain any tables.

Managing Paimon Tables

  • Creating a table

    Create a partitioned table in the paimon_db database under the lf_paimon_catalog catalog. The sample code is as follows:

    CREATE TABLE lf_paimon_catalog.paimon_db.paimon_table (
      id BIGINT,
      data STRING,
      PRIMARY KEY (`id`,data) NOT ENFORCED
    ) PARTITIONED BY (data);
  • Modifying the table structure

    Operation

    Code Example

    Modifying/Adding table properties

    ALTER TABLE my_table SET (

    'write-buffer-size' = '256 MB'

    );

    Removing table properties

    ALTER TABLE my_table RESET ('write-buffer-size');

    Modifying/Adding table comments

    ALTER TABLE my_table SET (

    'comment' = 'table comment'

    );

    Removing table comments

    ALTER TABLE my_table RESET ('comment');

    Temporarily modifying table parameters

    You can temporarily modify table parameters by adding an SQL hint after the table name when writing data to the table. These temporary modifications are only effective for the current SQL job.

    • Temporarily set upsert-enabled to true when writing to the my_table table.
      INSERT INTO tableName /*+ OPTIONS('upsert-enabled'='true') */SELECT ...;
    • Temporarily set monitor-interval to 10s when consuming the my_table table.
      SELECT * FROM my_table /*+ OPTIONS('monitor-interval'='10s') */

    Renaming a table

    Rename the table from my_table to my_table_new. Only EXTERNAL tables can be renamed.

    ALTER TABLE my_table RENAME TO my_table_new;

    Adding a column

    Add the c1 column of the INT type and the c2 column of the STRING type to the end of the my_table table.

    ALTER TABLE my_table ADD (c1 INT, c2 STRING);

    Renaming a column

    Rename the c0 column in the my_table table to c1.

    ALTER TABLE my_table RENAME c0 TO c1;

    Dropping a column

    Drop columns c1 and c2 from the my_table table.

    ALTER TABLE my_table DROP (c1, c2);

    Modifying column comments

    Change the comment of the buy_count column in the my_table table to this is buy count.

    ALTER TABLE my_table MODIFY buy_count BIGINT COMMENT 'this is buy count';

    Modifying the column order

    • Move the col_a column of the DOUBLE type in the my_table table to the beginning.
      ALTER TABLE my_table MODIFY col_a DOUBLE FIRST;
    • Move the col_a column of the DOUBLE type in the my_table table to the end of the col_b column.
      ALTER TABLE my_table MODIFY col_a DOUBLE AFTER col_b;

    Modifying the column type

    ALTER TABLE my_table MODIFY col_a DOUBLE;

  • Deleting a table
    DROP TABLE lf_paimon_catalog.paimon_db.paimon_table;