> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# Paimon catalog

> The database supports Paimon catalogs from v3.1 onwards.

**Beta feature**

[Advice on use of Beta features](/documents/4.2/maturity/features.md)

The database supports Paimon catalogs from v3.1 onwards.

A Paimon catalog is a kind of external catalog that enables you to query data from Apache Paimon without ingestion.

Also, you can directly transform and load data from Paimon by using [INSERT INTO](/documents/4.2/sql-reference/sql-statements/loading_unloading/INSERT.md) based on Paimon catalogs.

To ensure successful SQL workloads on your Paimon cluster, your cluster must be able to access the storage system and metastore of your Paimon cluster. The database supports the following storage systems and metastores:

* Distributed file system (HDFS) or object storage like AWS S3, Microsoft Azure Storage, Google GCS, or or other S3-compatible storage system (for example, MinIO)
* Metastore like your file system or Hive metastore

## Usage notes

You can use Paimon catalogs to query data, create or drop Paimon databases and tables, and write data with INSERT INTO, INSERT OVERWRITE, or CREATE TABLE AS SELECT. UPDATE, DELETE, and CREATE TABLE LIKE are not supported.

## Paimon to data types

| Paimon Type | the database Type |
| - | - |
| `BINARY` | `VARBINARY` |
| `VARBINARY` | `VARBINARY` |
| `CHAR` | `CHAR(length)` |
| `VARCHAR` | `VARCHAR` |
| `BOOLEAN` | `BOOLEAN` |
| `DECIMAL` | `DECIMAL(precision, scale)` |
| `TINYINT` | `TINYINT` |
| `SMALLINT` | `SMALLINT` |
| `INT` | `INT` |
| `BIGINT` | `BIGINT` |
| `FLOAT` | `FLOAT` |
| `DOUBLE` | `DOUBLE` |
| `DATE` | `DATE` |
| `TIME` | `TIME` |
| `TIMESTAMP` | `DATETIME` |
| `LocalZonedTimestamp` | `DATETIME` |
| `ARRAY` | `ARRAY<element_type>` |
| `MAP` | `MAP<key_type, value_type>` |
| `ROW/STRUCT` | `STRUCT<field1:type1, ...>` |
| `VARIANT` | `VARIANT` |

**Note**

`VARIANT` is supported from v4.2 onwards for splits read by the native reader (append-only tables and compacted primary-key data). Reading `VARIANT` from uncompacted primary-key data requires the JNI reader and is not yet supported; such queries are rejected with a plan-time error.

## Integration preparations

Before you create a Paimon catalog, make sure your cluster can integrate with the storage system and metastore of your Paimon cluster.

### AWS IAM

If your Paimon cluster uses AWS S3 as storage, choose your suitable authentication method and make the required preparations to ensure that your cluster can access the related AWS cloud resources.

The following authentication methods are recommended:

* Instance profile (recommended)
* Assumed role
* IAM user

Of the above-mentioned three authentication methods, instance profile is the most widely used.

For more information, see [Preparation for authentication in AWS IAM](/documents/4.2/integrations/csp_auth/authenticate_to_aws_resources.md#preparation-for-iam-user-based-authentication).

### HDFS

If you choose HDFS as storage, configure your cluster as follows:

* (Optional) Set the username that is used to access your HDFS cluster and Hive metastore. By default, the database uses the username of the FE and BE or CN processes to access your HDFS cluster and Hive metastore. You can also set the username by adding `export HADOOP_USER_NAME="<user_name>"` at the beginning of the **fe/conf/hadoop\_env.sh** file of each FE and at the beginning of the **be/conf/hadoop\_env.sh** file of each BE or the **cn/conf/hadoop\_env.sh** file of each CN. After you set the username in these files, restart each FE and each BE or CN to make the parameter settings take effect. You can set only one username for each cluster.
* When you query Paimon data, the FEs and BEs or CNs of your cluster use the HDFS client to access your HDFS cluster. In most cases, you do not need to configure your cluster to achieve that purpose, and the database starts the HDFS client using the default configurations. You need to configure your cluster only in the following situations:
  * High availability (HA) is enabled for your HDFS cluster: Add the **hdfs-site.xml** file of your HDFS cluster to the **$FE_HOME/conf** path of each FE and to the **$BE\_HOME/conf** path of each BE or the **\$CN\_HOME/conf** path of each CN.
  * View File System (ViewFs) is enabled for your HDFS cluster: Add the **core-site.xml** file of your HDFS cluster to the **$FE_HOME/conf** path of each FE and to the **$BE\_HOME/conf** path of each BE or the **\$CN\_HOME/conf** path of each CN.

> **NOTE**
>
> If an error indicating an unknown host is returned when you send a query, you must add the mapping between the host names and IP addresses of your HDFS cluster nodes to the **/etc/hosts** path.

### Kerberos authentication

If Kerberos authentication is enabled for your HDFS cluster or Hive metastore, configure your cluster as follows:

* Run the `kinit -kt keytab_path principal` command on each FE and each BE or CN to obtain Ticket Granting Ticket (TGT) from Key Distribution Center (KDC). To run this command, you must have the permissions to access your HDFS cluster and Hive metastore. Note that accessing KDC with this command is time-sensitive. Therefore, you need to use cron to run this command periodically.
* Add `JAVA_OPTS="-Djava.security.krb5.conf=/etc/krb5.conf"` to the **$FE_HOME/conf/fe.conf** file of each FE and to the **$BE\_HOME/conf/be.conf** file of each BE or the **\$CN\_HOME/conf/cn.conf** file of each CN. In this example, `/etc/krb5.conf` is the save path of the **krb5.conf** file. You can modify the path based on your needs.

## Create a Paimon catalog

### Syntax

```SQL theme={null}
CREATE EXTERNAL CATALOG <catalog_name>
[COMMENT <comment>]
PROPERTIES
(
    "type" = "paimon",
    CatalogParams,
    StorageCredentialParams,
)
```

### Parameters

#### catalog\_name

The name of the Paimon catalog. The naming conventions are as follows:

* The name can contain letters, digits (0-9), and underscores (\_). It must start with a letter.
* The name is case-sensitive and cannot exceed 1023 characters in length.

#### comment

The description of the Paimon catalog. This parameter is optional.

#### type

The type of your data source. Set the value to `paimon`.

#### CatalogParams

A set of parameters about how the database accesses the metadata of your Paimon cluster.

The following table describes the parameter you need to configure in `CatalogParams`.

| Parameter | Required | Description |
| - | - | - |
| paimon.catalog.type | Yes | The type of metastore that you use for your Paimon cluster. Set this parameter to `filesystem` or `hive`. |
| paimon.catalog.warehouse | Yes | The warehouse storage path of your Paimon data. |
| hive.metastore.uris | No | The URI of your Hive metastore. Format: `thrift://<metastore_IP_address>:<metastore_port>`. If high availability (HA) is enabled for your Hive metastore, you can specify multiple metastore URIs and separate them with commas (`,`), for example, `"thrift://<metastore_IP_address_1>:<metastore_port_1>,thrift://<metastore_IP_address_2>:<metastore_port_2>,thrift://<metastore_IP_address_3>:<metastore_port_3>"`. |

> **NOTE**
>
> If you use Hive metastore, you must add the mapping between the host names and IP addresses of your Hive metastore nodes to the `/etc/hosts` path before you query Paimon data. Otherwise, the database may fail to access your Hive metastore when you start a query.

#### StorageCredentialParams

A set of parameters about how the database integrates with your storage system. This parameter set is optional.

If you use HDFS as storage, you do not need to configure `StorageCredentialParams`.

If you use AWS S3, other S3-compatible storage system, Microsoft Azure Storage, or Google GCS as storage, you must configure `StorageCredentialParams`.

##### AWS S3

If you choose AWS S3 as storage for your Paimon cluster, take one of the following actions:

* To choose the instance profile-based authentication method, configure `StorageCredentialParams` as follows:

  ```SQL theme={null}
  "aws.s3.use_instance_profile" = "true",
  "aws.s3.endpoint" = "<aws_s3_endpoint>"
  ```

* To choose the assumed role-based authentication method, configure `StorageCredentialParams` as follows:

  ```SQL theme={null}
  "aws.s3.use_instance_profile" = "true",
  "aws.s3.iam_role_arn" = "<iam_role_arn>",
  "aws.s3.endpoint" = "<aws_s3_endpoint>"
  ```

* To choose the IAM user-based authentication method, configure `StorageCredentialParams` as follows:

  ```SQL theme={null}
  "aws.s3.use_instance_profile" = "false",
  "aws.s3.access_key" = "<iam_user_access_key>",
  "aws.s3.secret_key" = "<iam_user_secret_key>",
  "aws.s3.endpoint" = "<aws_s3_endpoint>"
  ```

The following table describes the parameters you need to configure in `StorageCredentialParams`.

| Parameter | Required | Description |
| - | - | - |
| aws.s3.use\_instance\_profile | Yes | Specifies whether to enable the instance profile-based authentication method and the assumed role-based authentication method. Valid values: `true` and `false`. Default value: `false`. |
| aws.s3.iam\_role\_arn | No | The ARN of the IAM role that has privileges on your AWS S3 bucket. If you use the assumed role-based authentication method to access AWS S3, you must specify this parameter. |
| aws.s3.endpoint | Yes | The endpoint that is used to connect to your AWS S3 bucket. For example, `https://s3.us-west-2.amazonaws.com`. |
| aws.s3.access\_key | No | The access key of your IAM user. If you use the IAM user-based authentication method to access AWS S3, you must specify this parameter. |
| aws.s3.secret\_key | No | The secret key of your IAM user. If you use the IAM user-based authentication method to access AWS S3, you must specify this parameter. |

For information about how to choose an authentication method for accessing AWS S3 and how to configure an access control policy in AWS IAM Console, see [Authentication parameters for accessing AWS S3](/documents/4.2/integrations/csp_auth/authenticate_to_aws_resources.md#authentication-parameters-for-accessing-aws-s3).

##### S3-compatible storage system

If you choose an S3-compatible storage system, such as MinIO, as storage for your Paimon cluster, configure `StorageCredentialParams` as follows to ensure a successful integration:

```SQL theme={null}
"aws.s3.enable_ssl" = "false",
"aws.s3.enable_path_style_access" = "true",
"aws.s3.endpoint" = "<s3_endpoint>",
"aws.s3.access_key" = "<iam_user_access_key>",
"aws.s3.secret_key" = "<iam_user_secret_key>"
```

The following table describes the parameters you need to configure in `StorageCredentialParams`.

| Parameter | Required | Description |
| - | - | - |
| aws.s3.enable\_ssl | Yes | Specifies whether to enable SSL connection. Valid values: `true` and `false`. Default value: `true`. |
| aws.s3.enable\_path\_style\_access | Yes | Specifies whether to enable path-style access. Valid values: `true` and `false`. Default value: `false`. For MinIO, you must set the value to `true`.  Path-style URLs use the following format: `https://s3.<region_code>.amazonaws.com/<bucket_name>/<key_name>`. For example, if you create a bucket named `DOC-EXAMPLE-BUCKET1` in the US West (Oregon) Region, and you want to access the `alice.jpg` object in that bucket, you can use the following path-style URL: `https://s3.us-west-2.amazonaws.com/DOC-EXAMPLE-BUCKET1/alice.jpg`. |
| aws.s3.endpoint | Yes | The endpoint that is used to connect to your S3-compatible storage system instead of AWS S3. |
| aws.s3.access\_key | Yes | The access key of your IAM user. |
| aws.s3.secret\_key | Yes | The secret key of your IAM user. |

##### Microsoft Azure Storage

###### Azure Blob Storage

If you choose Blob Storage as storage for your Paimon cluster, take one of the following actions:

* To choose the Shared Key authentication method, configure `StorageCredentialParams` as follows:

  ```SQL theme={null}
  "azure.blob.storage_account" = "<storage_account_name>",
  "azure.blob.shared_key" = "<storage_account_shared_key>"
  ```

  The following table describes the parameters you need to configure in `StorageCredentialParams`.

  | Parameter | Required | Description |
  | - | - | - |
  | azure.blob.storage\_account | Yes | The username of your Blob Storage account. |
  | azure.blob.shared\_key | Yes | The shared key of your Blob Storage account. |

* To choose the SAS Token authentication method, configure `StorageCredentialParams` as follows:

  ```SQL theme={null}
  "azure.blob.storage_account" = "<storage_account_name>",
  "azure.blob.container" = "<container_name>",
  "azure.blob.sas_token" = "<storage_account_SAS_token>"
  ```

  The following table describes the parameters you need to configure in `StorageCredentialParams`.

  | Parameter | Required | Description |
  | - | - | - |
  | azure.blob.storage\_account | Yes | The username of your Blob Storage account. |
  | azure.blob.container | Yes | The name of the blob container that stores your data. |
  | azure.blob.sas\_token | Yes | The SAS token that is used to access your Blob Storage account. |

###### Azure Data Lake Storage Gen2

If you choose Data Lake Storage Gen2 as storage for your Paimon cluster, take one of the following actions:

* To choose the Managed Identity authentication method, configure `StorageCredentialParams` as follows:

  ```SQL theme={null}
  "azure.adls2.oauth2_use_managed_identity" = "true",
  "azure.adls2.oauth2_tenant_id" = "<service_principal_tenant_id>",
  "azure.adls2.oauth2_client_id" = "<service_client_id>"
  ```

  The following table describes the parameters you need to configure in `StorageCredentialParams`.

  | Parameter | Required | Description |
  | - | - | - |
  | azure.adls2.oauth2\_use\_managed\_identity | Yes | Specifies whether to enable the Managed Identity authentication method. Set the value to `true`. |
  | azure.adls2.oauth2\_tenant\_id | Yes | The ID of the tenant whose data you want to access. |
  | azure.adls2.oauth2\_client\_id | Yes | The client (application) ID of the managed identity. |

* To choose the Shared Key authentication method, configure `StorageCredentialParams` as follows:

  ```SQL theme={null}
  "azure.adls2.storage_account" = "<storage_account_name>",
  "azure.adls2.shared_key" = "<storage_account_shared_key>"
  ```

  The following table describes the parameters you need to configure in `StorageCredentialParams`.

  | Parameter | Required | Description |
  | - | - | - |
  | azure.adls2.storage\_account | Yes | The username of your Data Lake Storage Gen2 storage account. |
  | azure.adls2.shared\_key | Yes | The shared key of your Data Lake Storage Gen2 storage account. |

* To choose the Service Principal authentication method, configure `StorageCredentialParams` as follows:

  ```SQL theme={null}
  "azure.adls2.oauth2_client_id" = "<service_client_id>",
  "azure.adls2.oauth2_client_secret" = "<service_principal_client_secret>",
  "azure.adls2.oauth2_client_endpoint" = "<service_principal_client_endpoint>"
  ```

  The following table describes the parameters you need to configure `in StorageCredentialParams`.

  | Parameter | Required | Description |
  | - | - | - |
  | azure.adls2.oauth2\_client\_id | Yes | The client (application) ID of the service principal. |
  | azure.adls2.oauth2\_client\_secret | Yes | The value of the new client (application) secret created. |
  | azure.adls2.oauth2\_client\_endpoint | Yes | The OAuth 2.0 token endpoint (v1) of the service principal or application. |

* To choose the Workload Identity authentication method, configure `StorageCredentialParams` as follows:

  ```SQL theme={null}
  "azure.adls2.oauth2_token_file" = "<path_to_token>",
  "azure.adls2.oauth2_tenant_id" = "<service_principal_tenant_id>",
  "azure.adls2.oauth2_client_id" = "<service_client_id>"
  ```

  The following table describes the parameters you need to configure in `StorageCredentialParams`.

  | **Parameter** | **Required** | **Description** |
  | - | - | - |
  | azure.adls2.oauth2\_token\_file | Yes | The absolute file path to the OAuth2 token file projected into the pod by the Azure Workload Identity webhook. |
  | azure.adls2.oauth2\_tenant\_id | Yes | The ID of the tenant whose data you want to access. |
  | azure.adls2.oauth2\_client\_id | Yes | The client ID (application ID) of the Azure AD application (user-assigned managed identity or app registration) associated with the workload identity. |

###### Azure Data Lake Storage Gen1

If you choose Data Lake Storage Gen1 as storage for your Paimon cluster, take one of the following actions:

* To choose the Managed Service Identity authentication method, configure `StorageCredentialParams` as follows:

  ```SQL theme={null}
  "azure.adls1.use_managed_service_identity" = "true"
  ```

  The following table describes the parameters you need to configure in `StorageCredentialParams`.

  | Parameter | Required | Description |
  | - | - | - |
  | azure.adls1.use\_managed\_service\_identity | Yes | Specifies whether to enable the Managed Service Identity authentication method. Set the value to `true`. |

* To choose the Service Principal authentication method, configure `StorageCredentialParams` as follows:

  ```SQL theme={null}
  "azure.adls1.oauth2_client_id" = "<application_client_id>",
  "azure.adls1.oauth2_credential" = "<application_client_credential>",
  "azure.adls1.oauth2_endpoint" = "<OAuth_2.0_authorization_endpoint_v2>"
  ```

  The following table describes the parameters you need to configure in `StorageCredentialParams`.

  | Parameter | Required | Description |
  | - | - | - |
  | azure.adls1.oauth2\_client\_id | Yes | The client (application) ID of the service principal. |
  | azure.adls1.oauth2\_credential | Yes | The value of the new client (application) secret created. |
  | azure.adls1.oauth2\_endpoint | Yes | The OAuth 2.0 token endpoint (v1) of the service principal or application. |

##### Google GCS

If you choose Google GCS as storage for your Paimon cluster, take one of the following actions:

* To choose the VM-based authentication method, configure `StorageCredentialParams` as follows:

  ```SQL theme={null}
  "gcp.gcs.use_compute_engine_service_account" = "true"
  ```

  The following table describes the parameters you need to configure in `StorageCredentialParams`.

  | Parameter | Default value | Value example | Description |
  | - | - | - | - |
  | gcp.gcs.use\_compute\_engine\_service\_account | FALSE | TRUE | Specifies whether to directly use the service account that is bound to your Compute Engine. |

* To choose the service account-based authentication method, configure `StorageCredentialParams` as follows:

  ```SQL theme={null}
  "gcp.gcs.service_account_email" = "<google_service_account_email>",
  "gcp.gcs.service_account_private_key_id" = "<google_service_private_key_id>",
  "gcp.gcs.service_account_private_key" = "<google_service_private_key>"
  ```

  The following table describes the parameters you need to configure in `StorageCredentialParams`.

  | Parameter | Default value | Value example | Description |
  | - | - | - | - |
  | gcp.gcs.service\_account\_email | "" | "[user@hello.iam.gserviceaccount.com](mailto:user@hello.iam.gserviceaccount.com)" | The email address in the JSON file generated at the creation of the service account. |
  | gcp.gcs.service\_account\_private\_key\_id | "" | "61d257bd8479547cb3e04f0b9b6b9ca07af3b7ea" | The private key ID in the JSON file generated at the creation of the service account. |
  | gcp.gcs.service\_account\_private\_key | "" | "-----BEGIN PRIVATE KEY----xxxx-----END PRIVATE KEY-----\n" | The private key in the JSON file generated at the creation of the service account. |

* To choose the impersonation-based authentication method, configure `StorageCredentialParams` as follows:

  * Make a VM instance impersonate a service account:

    ```SQL theme={null}
    "gcp.gcs.use_compute_engine_service_account" = "true",
    "gcp.gcs.impersonation_service_account" = "<assumed_google_service_account_email>"
    ```

    The following table describes the parameters you need to configure in `StorageCredentialParams`.

    | Parameter | Default value | Value example | Description |
    | - | - | - | - |
    | gcp.gcs.use\_compute\_engine\_service\_account | FALSE | TRUE | Specifies whether to directly use the service account that is bound to your Compute Engine. |
    | gcp.gcs.impersonation\_service\_account | "" | "hello" | The service account that you want to impersonate. |

  * Make a service account (temporarily named as meta service account) impersonate another service account (temporarily named as data service account):

    ```SQL theme={null}
    "gcp.gcs.service_account_email" = "<google_service_account_email>",
    "gcp.gcs.service_account_private_key_id" = "<meta_google_service_account_email>",
    "gcp.gcs.service_account_private_key" = "<meta_google_service_account_email>",
    "gcp.gcs.impersonation_service_account" = "<data_google_service_account_email>"
    ```

    The following table describes the parameters you need to configure in `StorageCredentialParams`.

    | Parameter | Default value | Value example | Description |
    | - | - | - | - |
    | gcp.gcs.service\_account\_email | "" | "[user@hello.iam.gserviceaccount.com](mailto:user@hello.iam.gserviceaccount.com)" | The email address in the JSON file generated at the creation of the meta service account. |
    | gcp.gcs.service\_account\_private\_key\_id | "" | "61d257bd8479547cb3e04f0b9b6b9ca07af3b7ea" | The private key ID in the JSON file generated at the creation of the meta service account. |
    | gcp.gcs.service\_account\_private\_key | "" | "-----BEGIN PRIVATE KEY----xxxx-----END PRIVATE KEY-----\n" | The private key in the JSON file generated at the creation of the meta service account. |
    | gcp.gcs.impersonation\_service\_account | "" | "hello" | The data service account that you want to impersonate. |

#### MetadataCacheParams (optional)

The database caches Paimon metadata and refreshes it in the background. These optional properties tune that cache.

| Parameter | Default value | Description |
| - | - | - |
| paimon\_meta\_cache\_ttl\_sec | 86400 | How long a cached entry lives, in seconds. |
| paimon\_table\_cache\_refresh\_interval\_sec | 60 | The minimum interval, in seconds, between two refreshes of the same table triggered by a query that read a newer snapshot. The refresh runs in the background and the query does not wait for it. Set to `0` to only refresh in the periodic background round. Supported from v4.2.0 onwards. |

### Examples

The following examples create a Paimon catalog named `paimon_catalog_fs` whose metastore type `paimon.catalog.type` is set to `filesystem` to query data from your Paimon cluster.

#### AWS S3

* If you choose the instance profile-based authentication method, run a command like below:

  ```SQL theme={null}
  CREATE EXTERNAL CATALOG paimon_catalog_fs
  PROPERTIES
  (
      "type" = "paimon",
      "paimon.catalog.type" = "filesystem",
      "paimon.catalog.warehouse" = "<s3_paimon_warehouse_path>",
      "aws.s3.use_instance_profile" = "true",
      "aws.s3.endpoint" = "<s3_endpoint>"
  );
  ```

* If you choose the assumed role-based authentication method, run a command like below:

  ```SQL theme={null}
  CREATE EXTERNAL CATALOG paimon_catalog_fs
  PROPERTIES
  (
      "type" = "paimon",
      "paimon.catalog.type" = "filesystem",
      "paimon.catalog.warehouse" = "<s3_paimon_warehouse_path>",
      "aws.s3.use_instance_profile" = "true",
      "aws.s3.iam_role_arn" = "arn:aws:iam::081976408565:role/test_s3_role",
      "aws.s3.endpoint" = "<s3_endpoint>"
  );
  ```

* If you choose the IAM user-based authentication method, run a command like below:

  ```SQL theme={null}
  CREATE EXTERNAL CATALOG paimon_catalog_fs
  PROPERTIES
  (
      "type" = "paimon",
      "paimon.catalog.type" = "filesystem",
      "paimon.catalog.warehouse" = "<s3_paimon_warehouse_path>",
      "aws.s3.use_instance_profile" = "false",
      "aws.s3.access_key" = "<iam_user_access_key>",
      "aws.s3.secret_key" = "<iam_user_secret_key>",
      "aws.s3.endpoint" = "<s3_endpoint>"
  );
  ```

#### S3-compatible storage system

Use MinIO as an example. Run a command like below:

```SQL theme={null}
CREATE EXTERNAL CATALOG paimon_catalog_fs
PROPERTIES
(
    "type" = "paimon",
    "paimon.catalog.type" = "filesystem",
    "paimon.catalog.warehouse" = "<paimon_warehouse_path>",
    "aws.s3.enable_ssl" = "true",
    "aws.s3.enable_path_style_access" = "true",
    "aws.s3.endpoint" = "<s3_endpoint>",
    "aws.s3.access_key" = "<iam_user_access_key>",
    "aws.s3.secret_key" = "<iam_user_secret_key>"
);
```

#### Microsoft Azure Storage

##### Azure Blob Storage

* If you choose the Shared Key authentication method, run a command like below:

  ```SQL theme={null}
  CREATE EXTERNAL CATALOG paimon_catalog_fs
  PROPERTIES
  (
      "type" = "paimon",
      "paimon.catalog.type" = "filesystem",
      "paimon.catalog.warehouse" = "<blob_paimon_warehouse_path>",
      "azure.blob.storage_account" = "<blob_storage_account_name>",
      "azure.blob.shared_key" = "<blob_storage_account_shared_key>"
  );
  ```

* If you choose the SAS Token authentication method, run a command like below:

  ```SQL theme={null}
  CREATE EXTERNAL CATALOG paimon_catalog_fs
  PROPERTIES
  (
      "type" = "paimon",
      "paimon.catalog.type" = "filesystem",
      "paimon.catalog.warehouse" = "<blob_paimon_warehouse_path>",
      "azure.blob.storage_account" = "<blob_storage_account_name>",
      "azure.blob.container" = "<blob_container_name>",
      "azure.blob.sas_token" = "<blob_storage_account_SAS_token>"
  );
  ```

##### Azure Data Lake Storage Gen1

* If you choose the Managed Service Identity authentication method, run a command like below:

  ```SQL theme={null}
  CREATE EXTERNAL CATALOG paimon_catalog_fs
  PROPERTIES
  (
      "type" = "paimon",
      "paimon.catalog.type" = "filesystem",
      "paimon.catalog.warehouse" = "<adls1_paimon_warehouse_path>",
      "azure.adls1.use_managed_service_identity" = "true"
  );
  ```

* If you choose the Service Principal authentication method, run a command like below:

  ```SQL theme={null}
  CREATE EXTERNAL CATALOG paimon_catalog_fs
  PROPERTIES
  (
      "type" = "paimon",
      "paimon.catalog.type" = "filesystem",
      "paimon.catalog.warehouse" = "<adls1_paimon_warehouse_path>",
      "azure.adls1.oauth2_client_id" = "<application_client_id>",
      "azure.adls1.oauth2_credential" = "<application_client_credential>",
      "azure.adls1.oauth2_endpoint" = "<OAuth_2.0_authorization_endpoint_v2>"
  );
  ```

##### Azure Data Lake Storage Gen2

* If you choose the Managed Identity authentication method, run a command like below:

  ```SQL theme={null}
  CREATE EXTERNAL CATALOG paimon_catalog_fs
  PROPERTIES
  (
      "type" = "paimon",
      "paimon.catalog.type" = "filesystem",
      "paimon.catalog.warehouse" = "<adls2_paimon_warehouse_path>",
      "azure.adls2.oauth2_use_managed_identity" = "true",
      "azure.adls2.oauth2_tenant_id" = "<service_principal_tenant_id>",
      "azure.adls2.oauth2_client_id" = "<service_client_id>"
  );
  ```

* If you choose the Shared Key authentication method, run a command like below:

  ```SQL theme={null}
  CREATE EXTERNAL CATALOG paimon_catalog_fs
  PROPERTIES
  (
      "type" = "paimon",
      "paimon.catalog.type" = "filesystem",
      "paimon.catalog.warehouse" = "<adls2_paimon_warehouse_path>",
      "azure.adls2.storage_account" = "<storage_account_name>",
      "azure.adls2.shared_key" = "<shared_key>"
  );
  ```

* If you choose the Service Principal authentication method, run a command like below:

  ```SQL theme={null}
  CREATE EXTERNAL CATALOG paimon_catalog_fs
  PROPERTIES
  (
      "type" = "paimon",
      "paimon.catalog.type" = "filesystem",
      "paimon.catalog.warehouse" = "<adls2_paimon_warehouse_path>",
      "azure.adls2.oauth2_client_id" = "<service_client_id>",
      "azure.adls2.oauth2_client_secret" = "<service_principal_client_secret>",
      "azure.adls2.oauth2_client_endpoint" = "<service_principal_client_endpoint>"
  );
  ```

* If you choose the Workload Identity authentication method, run a command like below:

  ```SQL theme={null}
  CREATE EXTERNAL CATALOG paimon_catalog_fs
  PROPERTIES
  (
      "type" = "paimon",
      "paimon.catalog.type" = "filesystem",
      "paimon.catalog.warehouse" = "<adls2_paimon_warehouse_path>",
      "azure.adls2.oauth2_token_file" = "/var/run/secrets/azure/tokens/azure-identity-token",
      "azure.adls2.oauth2_tenant_id" = "<service_principal_tenant_id>",
      "azure.adls2.oauth2_client_id" = "<service_client_id>"
  );
  ```

#### Google GCS

* If you choose the VM-based authentication method, run a command like below:

  ```SQL theme={null}
  CREATE EXTERNAL CATALOG paimon_catalog_fs
  PROPERTIES
  (
      "type" = "paimon",
      "paimon.catalog.type" = "filesystem",
      "paimon.catalog.warehouse" = "<gcs_paimon_warehouse_path>",
      "gcp.gcs.use_compute_engine_service_account" = "true"
  );
  ```

* If you choose the service account-based authentication method, run a command like below:

  ```SQL theme={null}
  CREATE EXTERNAL CATALOG paimon_catalog_fs
  PROPERTIES
  (
      "type" = "paimon",
      "paimon.catalog.type" = "filesystem",
      "paimon.catalog.warehouse" = "<gcs_paimon_warehouse_path>",
      "gcp.gcs.service_account_email" = "<google_service_account_email>",
      "gcp.gcs.service_account_private_key_id" = "<google_service_private_key_id>",
      "gcp.gcs.service_account_private_key" = "<google_service_private_key>"
  );
  ```

* If you choose the impersonation-based authentication method:

  * If you make a VM instance impersonate a service account, run a command like below:

    ```SQL theme={null}
    CREATE EXTERNAL CATALOG paimon_catalog_fs
    PROPERTIES
    (
        "type" = "paimon",
        "paimon.catalog.type" = "filesystem",
        "paimon.catalog.warehouse" = "<gcs_paimon_warehouse_path>",
        "gcp.gcs.use_compute_engine_service_account" = "true",
        "gcp.gcs.impersonation_service_account" = "<assumed_google_service_account_email>"
    );
    ```

  * If you make a service account impersonate another service account, run a command like below:

    ```SQL theme={null}
    CREATE EXTERNAL CATALOG paimon_catalog_fs
    PROPERTIES
    (
        "type" = "paimon",
        "paimon.catalog.type" = "filesystem",
        "paimon.catalog.warehouse" = "<gcs_paimon_warehouse_path>",
        "gcp.gcs.service_account_email" = "<google_service_account_email>",
        "gcp.gcs.service_account_private_key_id" = "<meta_google_service_account_email>",
        "gcp.gcs.service_account_private_key" = "<meta_google_service_account_email>",
        "gcp.gcs.impersonation_service_account" = "<data_google_service_account_email>"
    );
    ```

## View Paimon catalogs

You can use [SHOW CATALOGS](/documents/4.2/sql-reference/sql-statements/Catalog/SHOW_CATALOGS.md) to query all catalogs in the current cluster:

```SQL theme={null}
SHOW CATALOGS;
```

You can also use [SHOW CREATE CATALOG](/documents/4.2/sql-reference/sql-statements/Catalog/SHOW_CREATE_CATALOG.md) to query the creation statement of an external catalog. The following example queries the creation statement of a Paimon catalog named `paimon_catalog_fs`:

```SQL theme={null}
SHOW CREATE CATALOG paimon_catalog_fs;
```

## Drop a Paimon catalog

You can use [DROP CATALOG](/documents/4.2/sql-reference/sql-statements/Catalog/DROP_CATALOG.md) to drop an external catalog.

The following example drops a Paimon catalog named `paimon_catalog_fs`:

```SQL theme={null}
DROP Catalog paimon_catalog_fs;
```

## Create and drop Paimon databases and tables

These operations create or drop native Paimon objects. The examples use an existing `paimon_catalog_fs` catalog with its warehouse and storage credentials configured.

### CREATE DATABASE

#### Syntax

```SQL theme={null}
CREATE DATABASE [IF NOT EXISTS] <catalog_name>.<database_name>;
```

#### Parameters

* `catalog_name`: The name of an existing Paimon catalog.
* `database_name`: The name of the database to create.
* `IF NOT EXISTS`: Suppresses the error if the database already exists.

Database `PROPERTIES` are not supported. The database uses the catalog's storage configuration.

#### Example

```SQL theme={null}
CREATE DATABASE IF NOT EXISTS paimon_catalog_fs.ddl_demo;
```

### CREATE TABLE

#### Syntax

```SQL theme={null}
CREATE TABLE [IF NOT EXISTS] <catalog_name>.<database_name>.<table_name> (
    <column_name> <column_type> [NULL | NOT NULL] [DEFAULT NULL] [COMMENT '<column_comment>']
    [, ...]
)
[ENGINE = paimon]
[PRIMARY KEY (<column_name> [, ...])]
[COMMENT '<table_comment>']
[PARTITION BY (<column_name> [, ...])]
[PROPERTIES ("<key>" = "<value>" [, ...])];
```

#### Parameters

* **Table name and engine**: Specify the database and new table name in an existing Paimon catalog. You can omit `ENGINE = paimon` when the target is a Paimon catalog. `IF NOT EXISTS` suppresses the duplicate-table error, but the table definition and properties are still validated.
* **Column definitions**: Supported types are BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, FLOAT, DOUBLE, DATE, DATETIME, CHAR, VARCHAR, VARBINARY, DECIMAL with precision up to 38, ARRAY, MAP, STRUCT, and VARIANT. DATETIME maps to Paimon TIMESTAMP(6). The existing read restrictions for VARIANT still apply. Only `DEFAULT NULL` is supported, and primary key columns cannot have defaults. Use `COMMENT` for column and table comments.
* **Primary keys**: Define keys with `PRIMARY KEY (column, ...)` or the `primary-key` table property. Key columns need not be the first columns. If nullability is unspecified, they become non-nullable in the Paimon schema; explicitly declaring them as `NULL` is not allowed. If both key forms are specified, the resolved column names and their order must match.
* **Partitions**: Use `PARTITION BY (column, ...)` for ordinary partition columns. Partition expressions and explicit partition definitions are not supported.
* **Table properties**: Specify Paimon table options, such as `bucket` and `file.format`, in `PROPERTIES`. The table uses the catalog's warehouse and storage credentials. Properties that override the catalog, storage location, credentials, or schema are rejected. Unknown options are rejected. Some invalid write configurations may only be detected when writing data. Dynamic column options such as `fields.<column>.aggregate-function` are not currently supported.

#### Examples

Create an empty partitioned append-only table:

```SQL theme={null}
CREATE TABLE IF NOT EXISTS paimon_catalog_fs.ddl_demo.append_demo (
    id BIGINT NOT NULL,
    payload VARCHAR(100) COMMENT 'Payload',
    dt DATE
)
ENGINE = paimon
PARTITION BY (dt)
PROPERTIES (
    "bucket" = "-1",
    "file.format" = "parquet"
);
```

Create a partitioned primary-key table:

```SQL theme={null}
CREATE TABLE IF NOT EXISTS paimon_catalog_fs.ddl_demo.pk_demo (
    payload VARCHAR(100),
    id BIGINT,
    dt DATE
)
PRIMARY KEY (id, dt)
PARTITION BY (dt)
PROPERTIES (
    "bucket" = "2",
    "bucket-key" = "id",
    "file.format" = "parquet"
);
```

Alternatively, omit the `PRIMARY KEY (id, dt)` clause and add `"primary-key" = "id,dt"` to `PROPERTIES`.

#### Limitations

* `DISTRIBUTED BY`, `ORDER BY`, `ROLLUP`, generated columns, aggregate columns, and `AUTO_INCREMENT` are not supported.
* Non-NULL column defaults are not supported.
* `CREATE TABLE LIKE` and writing data with `UPDATE` or `DELETE` are not supported.

### CREATE TABLE AS SELECT

[CREATE TABLE AS SELECT](/documents/4.2/sql-reference/sql-statements/table_bucket_part_index/CREATE_TABLE_AS_SELECT.md) infers the target columns from the query, creates a Paimon table, and writes the query results using the same rules as `INSERT INTO`. Declare the target partition columns, primary key, and table properties in the statement when needed.

Use a Paimon catalog for the target table. The database rejects a Unified Catalog target before creating the table.

```SQL theme={null}
CREATE TABLE paimon_catalog.write_db.orders_copy
PROPERTIES ("bucket" = "-1", "file.format" = "parquet")
AS SELECT id, amount FROM paimon_catalog.write_db.orders;
```

Table creation and snapshot publication are separate operations. If the write fails after creation, the database attempts to drop the target table. With `IF NOT EXISTS`, an existing target is left unchanged. Run Paimon CTAS outside an explicit transaction.

### DROP TABLE

#### Syntax

```SQL theme={null}
DROP TABLE [IF EXISTS] <catalog_name>.<database_name>.<table_name>;
```

`IF EXISTS` suppresses the error if the table does not exist. This operation drops the native Paimon table, rather than only removing its reference in the database.

#### Example

```SQL theme={null}
DROP TABLE IF EXISTS paimon_catalog_fs.ddl_demo.append_demo;
DROP TABLE IF EXISTS paimon_catalog_fs.ddl_demo.pk_demo;
```

### DROP DATABASE

#### Syntax

```SQL theme={null}
DROP DATABASE [IF EXISTS] <catalog_name>.<database_name> [FORCE];
```

`IF EXISTS` suppresses the error if the database does not exist. A database must be empty before it can be dropped; `FORCE` does not enable cascading deletion.

#### Example

After dropping the tables in the database, drop the database:

```SQL theme={null}
DROP DATABASE IF EXISTS paimon_catalog_fs.ddl_demo;
```

## Write data to Paimon

Use `INSERT INTO ... VALUES` or `INSERT INTO ... SELECT` to write to a native file-store table in a Paimon catalog. Append-only tables support `bucket = -1` or a positive fixed bucket count. Primary-key tables require a positive fixed bucket count and the `deduplicate` merge engine. Inserting an existing primary key performs a full-row upsert; it is not a partial update.

```sql theme={null}
CREATE DATABASE IF NOT EXISTS paimon_catalog_fs.ddl_demo;
CREATE TABLE paimon_catalog_fs.ddl_demo.write_demo (
    id INT NOT NULL,
    p VARCHAR(32),
    value VARCHAR(64)
)
PARTITION BY (p)
PROPERTIES ('bucket' = '-1', 'file.format' = 'parquet');

INSERT INTO paimon_catalog_fs.ddl_demo.write_demo VALUES (1, 'a', 'one');
INSERT INTO paimon_catalog_fs.ddl_demo.write_demo PARTITION (p = 'b')
SELECT 2, 'two';
```

An explicit column list and `BY NAME` are supported. For a static partition, omit the partition columns from the input; their position in the native schema does not matter. Omitted nullable columns receive NULL. Required columns must be supplied. If a column has a native Paimon default value, provide its value explicitly: omitting it or using `DEFAULT` is not supported.

`INSERT OVERWRITE` replaces the entire table by default. An explicit `PARTITION` replaces only that partition. With `dynamic_overwrite = true`, an overwrite without an explicit partition replaces only partitions present in the input. An empty full or static overwrite clears its target; an empty dynamic overwrite is a no-op.

**Warning**

Avoid specifying the table's reserved NULL partition name as a string in `PARTITION (...)`. Paimon treats the value of `partition.default-name` (`__DEFAULT_PARTITION__` by default) as NULL when resolving the overwrite target. For example, an overwrite with `PARTITION (p = '__DEFAULT_PARTITION__')` and zero input rows can clear the NULL partition. To intentionally overwrite the NULL partition, use `PARTITION (p = NULL)`.

Writes require Parquet data files, and matching FE/BE versions with the native Paimon writer installed. The writer uses the catalog storage credentials. `paimon_reader_mode` selects a reader and does not change the write implementation. Explicit transactions, partial updates, dynamic primary-key buckets, cross-partition primary-key updates, data evolution, row tracking, global indexes, and external data paths are not supported.

Partition columns support boolean, integer, string, and date types. When writing rows, the database rejects partition strings that are empty, contain only whitespace, or match the reserved default partition name. The native SDK cannot preserve these values separately from NULL. Each sink driver defaults to at most 64 active partition/bucket writers and a 256 MiB native/Arrow allocation budget; exceeding a bound fails the statement before publication. The table options `starrocks.paimon.max-active-writers` (1–4096) and `starrocks.paimon.max-writer-memory-bytes` (2 MiB–4 GiB, in bytes) control these bounds. The query memory limit also applies.

Data becomes visible after the FE publishes the native Paimon snapshot. An empty INSERT INTO is a no-op. If the client receives a Paimon commit-outcome-unknown error, reconcile the operation before retrying: the snapshot may already have been published, and retrying an append can duplicate rows. The query profile exposes `PaimonOperationId` and `PaimonPublicationState` for this purpose.

## View the schema of a Paimon table

You can use one of the following syntaxes to view the schema of a Paimon table:

* View schema

  ```SQL theme={null}
  DESC[RIBE] <catalog_name>.<database_name>.<table_name>;
  ```

* View schema and location from the CREATE statement

  ```SQL theme={null}
  SHOW CREATE TABLE <catalog_name>.<database_name>.<table_name>;
  ```

## Query a Paimon table

1. Use [SHOW DATABASES](/documents/4.2/sql-reference/sql-statements/Database/SHOW_DATABASES.md) to view the databases in your Paimon cluster:

   ```SQL theme={null}
   SHOW DATABASES FROM <catalog_name>;
   ```

2. Use [SET CATALOG](/documents/4.2/sql-reference/sql-statements/Catalog/SET_CATALOG.md) to switch to the destination catalog in the current session:

   ```SQL theme={null}
   SET CATALOG <catalog_name>;
   ```

   Then, use [USE](/documents/4.2/sql-reference/sql-statements/Database/USE.md) to specify the active database in the current session:

   ```SQL theme={null}
   USE <db_name>;
   ```

   Or, you can use [USE](/documents/4.2/sql-reference/sql-statements/Database/USE.md) to directly specify the active database in the destination catalog:

   ```SQL theme={null}
   USE <catalog_name>.<db_name>;
   ```

3. Use [SELECT](/documents/4.2/sql-reference/sql-statements/table_bucket_part_index/SELECT/SELECT.md) to query the destination table in the specified database:

   ```SQL theme={null}
   SELECT count(*) FROM <table_name> LIMIT 10;
   ```

### Inspect the planned scan size

`EXPLAIN VERBOSE` and `EXPLAIN COSTS` include candidate file metrics for each
Paimon scan node. Plain `EXPLAIN` omits this block:

```text theme={null}
0:PaimonScanNode
   ...
   avgRowSize=2.0
   Paimon Scan Metrics:
     splits=2
     data_files=3
     data_file_bytes=12000000000
     data_file_rows=9000000000
   limit: 10
   cardinality: 10
```

These metrics summarize the splits selected by Paimon's planner, after its
partition/file pruning and any planning-time limit pruning. They use file
metadata already loaded for the scan and are independent of reader selection.
Splitting a file into multiple scan ranges does not multiply its file count,
bytes, or rows. For global-index splits, the metrics describe the underlying
candidate files, before applying the index's row ranges.

| Field | Meaning |
| - | - |
| `splits` | Number of Paimon input splits, before scan-range splitting. |
| `data_files` | Number of data-file entries across the selected splits. |
| `data_file_bytes` | Sum of those data files' on-storage sizes, in bytes. |
| `data_file_rows` | Sum of their metadata record counts, before residual filters, deletion-vector filtering, or primary-key merging. |

An empty scan reports zero. If any split lacks data-file metadata, as can happen
for system tables, the three file metrics are `-1` (unavailable), rather than
zero or a partial total. The metrics block is absent before scan planning.

`cardinality` remains the optimizer's estimated output row count, which can be
reduced by predicates and `LIMIT`. `data_file_rows` is not capped to that output
estimate. The byte count describes whole candidate data files, excludes
deletion/index files, and does not account for column projection, page pruning,
cache hits, or execution stopping early. It is a scan-size signal, not measured
I/O, output size, or an execution limit. In particular, a small `LIMIT` can still
select large files.

### Inspect Global Index decisions

Physical `EXPLAIN` shows the configured Global Index mode, the selected path,
and the result for each Paimon data scan. For a distributed index that was
applied, `EXPLAIN VERBOSE` and `EXPLAIN COSTS` include the index details.

```text theme={null}
0:PaimonScanNode
   Paimon Global Index: mode=auto, path=distributed, result=applied
     index_type=btree, indexed_columns=[id], snapshot_id=5
     shards=3/3, candidate_row_ids=1
```

`shards` reports the number of validated shard results and the expected number.
`candidate_row_ids` counts distinct row IDs returned by the distributed index,
before residual filters. An empty index result can be `applied` with zero
candidates. `Paimon Scan Metrics` shows the metadata totals of candidate files.

`sdk_managed` delegates index selection to the Paimon SDK in `local` mode.
`skipped` means the scan proceeded without a distributed request. In `auto`
mode, `fallback` means a distributed attempt failed and ordinary Paimon split
planning succeeded with SDK index evaluation disabled. The detailed plan shows
the reason for a skip or fallback, and `TRACE VALUES EXTERNAL` provides more
information about the underlying error.

## Load data from Paimon

Suppose you have an OLAP table named `olap_tbl`, you can transform and load data like below:

```SQL theme={null}
INSERT INTO default_catalog.olap_db.olap_tbl SELECT * FROM paimon_table;
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.