Paimon data source
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:
| Scenario | Description |
|---|---|
| Query acceleration | Use SelectDB's distributed query engine to run analytical queries on Paimon data. |
| Data integration | Read Paimon data and write it into SelectDB internal tables. |
| Data write-back | Not supported. ApsaraDB for SelectDB can only read data in external catalogs. |
Prerequisites
Before you begin, make sure that:
All Paimon cluster nodes and the SelectDB instance are in the same virtual private cloud (VPC). If they reside in different VPCs, resolve network connectivity first. For details, see What do I do if a connection fails to be established between an ApsaraDB for SelectDB instance and a data source?
The IP addresses of all Paimon cluster nodes are added to the IP address whitelist of the SelectDB instance. For details, see Configure an IP address whitelist.
The VPC IP addresses of the SelectDB instance are added to the Paimon cluster's IP address whitelist (if the Paimon cluster supports a whitelist mechanism). To find the VPC IP addresses of your SelectDB instance, see How do I view the IP addresses in the VPC to which my ApsaraDB SelectDB instance belongs?
You understand how catalogs work in SelectDB. For background, see Data lakehouse.
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"
);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
| Parameter | Required | Description |
|---|---|---|
type | Yes | The catalog type. Set to paimon. |
warehouse | Yes | The Hadoop Distributed File System (HDFS) path of the warehouse. |
hadoop.username | No | The username for logging in to HDFS. |
dfs.nameservices | No | The name of the nameservice. |
dfs.ha.namenodes.[nameservice ID] | No | The IDs of the NameNodes. |
dfs.namenode.rpc-address.[nameservice ID].[name node ID] | No | The Remote Procedure Call (RPC) addresses of the NameNodes. Provide one address per NameNode. |
dfs.client.failover.proxy.provider.[nameservice ID] | No | The 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
| Parameter | Required | Description |
|---|---|---|
type | Yes | The catalog type. Set to paimon. |
warehouse | Yes | The Object Storage Service (OSS) path of the warehouse. |
oss.endpoint | Yes | The endpoint for accessing OSS. For endpoint values by region, see Regions and endpoints. |
oss.access_key | Yes | The AccessKey ID for accessing OSS. |
oss.secret_key | Yes | The 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;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
MapType and ArrayType can be nested within each other in Paimon, and Map and Array can be nested in SelectDB.
| Paimon data type | ApsaraDB for SelectDB data type |
|---|---|
| BooleanType | Boolean |
| TinyIntType | TinyInt |
| SmallIntType | SmallInt |
| IntType | Int |
| FloatType | Float |
| BigIntType | BigInt |
| DoubleType | Double |
| VarCharType | VarChar |
| CharType | Char |
| DecimalType(precision, scale) | Decimal(precision, scale) |
| TimestampType, LocalZonedTimestampType | DateTime |
| DateType | Date |
| MapType | Map |
| ArrayType | Array |
| VarBinaryType, BinaryType | Binary |