Paimon data source

Updated at:

Use a Paimon catalog to run federated queries on Apache Paimon data directly from ApsaraDB for SelectDB, without moving or copying data.

What you can do:

ScenarioDescription
Query accelerationUse SelectDB's distributed query engine to run analytical queries on Paimon data.
Data integrationRead Paimon data and write it into SelectDB internal tables.
Data write-backNot supported. ApsaraDB for SelectDB can only read data in external catalogs.

Prerequisites

Before you begin, make sure that:

Usage notes

  • Supported Paimon versions depend on your SelectDB version:

    • SelectDB V3.0: Paimon 0.7 and earlier

    • SelectDB V4.0: Paimon 0.8 and earlier

  • OSS-backed Paimon warehouses are supported in ApsaraDB for SelectDB V3.0.6 and later.

Step 1: Connect to a SelectDB instance

Connect to your SelectDB instance using a MySQL client. For details, see Connect to an ApsaraDB for SelectDB instance by using a MySQL client.

Step 2: Create a Paimon catalog

SelectDB integrates external data sources through external catalogs. Paimon supports two metastore types:

  • File system metastore (default): stores both Paimon metadata and data in a file system.

  • Hive metastore: stores Paimon metadata as tables in a Hive metastore, queryable directly from Hive.

Create a catalog based on your metastore type and storage backend.

Create a catalog with a file system metastore

HDFS-backed warehouse

CREATE CATALOG `paimon_catalog` PROPERTIES (
    "type" = "paimon",
    "warehouse" = "hdfs://HDFS8000871/user/paimon",
    "dfs.nameservices" = "HDFS8000871",
    "dfs.ha.namenodes.HDFS8000871" = "nn1,nn2",
    "dfs.namenode.rpc-address.HDFS8000871.nn1" = "172.21.0.1:4007",
    "dfs.namenode.rpc-address.HDFS8000871.nn2" = "172.21.0.2:4007",
    "dfs.client.failover.proxy.provider.HDFS8000871" = "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider",
    "hadoop.username" = "hadoop"
);
Important

Parameters with names starting with dfs map one-to-one to parameters in the Paimon configuration file hdfs-site.xml. Use the same parameter names and values as in your hdfs-site.xml.

Parameters

ParameterRequiredDescription
typeYesThe catalog type. Set to paimon.
warehouseYesThe Hadoop Distributed File System (HDFS) path of the warehouse.
hadoop.usernameNoThe username for logging in to HDFS.
dfs.nameservicesNoThe name of the nameservice.
dfs.ha.namenodes.[nameservice ID]NoThe IDs of the NameNodes.
dfs.namenode.rpc-address.[nameservice ID].[name node ID]NoThe Remote Procedure Call (RPC) addresses of the NameNodes. Provide one address per NameNode.
dfs.client.failover.proxy.provider.[nameservice ID]NoThe Java class that handles active NameNode connections for the HDFS client. Default: org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider.

OSS-backed warehouse

CREATE CATALOG `paimon_oss_catalog` PROPERTIES (
    "type" = "paimon",
    "warehouse" = "oss://paimon-zd/paimonoss",
    "oss.endpoint" = "oss-cn-beijing.aliyuncs.com",
    "oss.access_key" = "<your-access-key-id>",
    "oss.secret_key" = "<your-access-key-secret>"
);

Parameters

ParameterRequiredDescription
typeYesThe catalog type. Set to paimon.
warehouseYesThe Object Storage Service (OSS) path of the warehouse.
oss.endpointYesThe endpoint for accessing OSS. For endpoint values by region, see Regions and endpoints.
oss.access_keyYesThe AccessKey ID for accessing OSS.
oss.secret_keyYesThe AccessKey secret for accessing OSS.

Create a catalog with a Hive metastore

If your Paimon metadata is stored in a Hive metastore, create a catalog with "paimon.catalog.type" = "hms". For the full list of Hive metastore parameters, see Hive data source.

CREATE CATALOG `paimon_hms` PROPERTIES (
    "type" = "paimon",
    "paimon.catalog.type" = "hms",
    "warehouse" = "hdfs://HDFS8000871/user/zhangdong/paimon2",
    "hive.metastore.uris" = "thrift://172.21.0.44:7004",
    "dfs.nameservices" = "HDFS8000871",
    "dfs.ha.namenodes.HDFS8000871" = "nn1,nn2",
    "dfs.namenode.rpc-address.HDFS8000871.nn1" = "172.21.0.1:4007",
    "dfs.namenode.rpc-address.HDFS8000871.nn2" = "172.21.0.2:4007",
    "dfs.client.failover.proxy.provider.HDFS8000871" = "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider",
    "hadoop.username" = "hadoop"
);

Step 3: Verify the catalog

Run SHOW CATALOGS to confirm the catalog was created:

SHOW CATALOGS;

Expected output:

+--------------+----------------+----------+-----------+-------------------------+---------------------+------------------------+
| CatalogId    | CatalogName    | Type     | IsCurrent | CreateTime              | LastUpdateTime      | Comment                |
+--------------+----------------+----------+-----------+-------------------------+---------------------+------------------------+
| 436009309195 | paimon_catalog | paimon   |           | 2024-08-06 17:09:08.058 | 2024-07-19 18:04:37 |                        |
|            0 | internal       | internal | yes       | UNRECORDED              | NULL                | Doris internal catalog |
+--------------+----------------+----------+-----------+-------------------------+---------------------+------------------------+

Step 4: Query Paimon data

After creating the catalog, query Paimon data using any of the following approaches:

-- Option 1: Switch to the catalog, then use a database
SWITCH paimon_catalog;
USE test_db;
SELECT * FROM test_t;

-- Option 2: Use a fully qualified table name without switching
SELECT * FROM paimon_catalog.test_db.test_t;
Note

After connecting to a SelectDB instance, the internal catalog is active by default. Switch to an external catalog before querying its data.

To explore available databases and tables:

SHOW DATABASES;
SHOW TABLES;

Column data type mappings

Note

MapType and ArrayType can be nested within each other in Paimon, and Map and Array can be nested in SelectDB.

Paimon data typeApsaraDB for SelectDB data type
BooleanTypeBoolean
TinyIntTypeTinyInt
SmallIntTypeSmallInt
IntTypeInt
FloatTypeFloat
BigIntTypeBigInt
DoubleTypeDouble
VarCharTypeVarChar
CharTypeChar
DecimalType(precision, scale)Decimal(precision, scale)
TimestampType, LocalZonedTimestampTypeDateTime
DateTypeDate
MapTypeMap
ArrayTypeArray
VarBinaryType, BinaryTypeBinary