OceanBase Database V4.3.5 BP2 and later support the catalog feature. This feature adds a catalog layer to the traditional Database → Table two-level model, forming a three-level architecture of Catalog → Database → Table.
With the ODPS catalog feature, you can directly query data from tables in Alibaba Cloud MaxCompute (formerly known as ODPS) without manually creating external table mappings. This feature is suitable for accelerating offline data warehouse queries.
- Direct query without ETL: You can directly access tables in MaxCompute without the need to create external tables.
- Unified metadata: The database and table structures in ODPS projects are automatically synchronized.
- Cross-source JOIN: You can perform JOIN queries between OceanBase Database internal tables and MaxCompute tables.
Supported capabilities
- Read-only queries: Supports analytical operations such as
SELECT,JOIN, andGROUP BY. - No write operations: Prohibits DML/DDL operations such as
INSERT,UPDATE, andDROP TABLE. - Partition and column pruning: Automatically pushes down filter conditions to reduce data transfer.
Limitations
| Limitation | Description |
|---|---|
| Complex data types | Does not support nested complex types such as ARRAY<MAP<STRING, BIGINT>> |
| Performance dependency | Query speed is affected by MaxCompute Tunnel quotas and network bandwidth |
| Environment dependency | Requires deployment of Java SDK (as MaxCompute SDK is based on Java) |
For more information about environment dependencies, see Deploy OceanBase Java SDK environment.
Prerequisites
Permissions
- The current user must have the
CREATE CATALOGpermission (MySQL-compatible mode) or theCREATE CATALOGsystem permission (Oracle-compatible mode). - The user must have the
USE CATALOGpermission (which can be granted to a specific catalog or globally) for queries.
- The current user must have the
Access credentials
- You have obtained the AccessKey ID and Secret of MaxCompute (or an STS token).
- The OceanBase cluster can access the MaxCompute endpoint and tunnel endpoint.
Authorization configuration
- The MaxCompute project has authorized the RAM user used by OceanBase (at least
Readpermission). For more information, see Overview of MaxCompute storage access.
- The MaxCompute project has authorized the RAM user used by OceanBase (at least
Syntax for creating an ODPS catalog
CREATE EXTERNAL CATALOG [IF NOT EXISTS] catalog_name
PROPERTIES (
TYPE = 'ODPS',
[ACCESSTYPE = 'aliyun' | 'sts' | 'app'],
ACCESSID = 'your-access-id',
ACCESSKEY = 'your-access-key',
[STSTOKEN = 'your-sts-token'], -- Required only when ACCESSTYPE='sts'
ENDPOINT = 'http://service.cn-hangzhou.maxcompute.aliyun.com/api',
TUNNEL_ENDPOINT = 'http://dt.cn-hangzhou.maxcompute.aliyun.com',
PROJECT_NAME = 'your_odps_project',
[QUOTA_NAME = 'your_quota'],
[COMPRESSION = 'zlib' | 'zstd' | 'lz4' | 'odps_lz4'],
API_MODE = {"tunnel_api" | "storage_api"},
SPLIT = {"byte" | "row"}
REGION = 'region_name'
);
Parameter description
| Parameter | Required | Description |
|---|---|---|
| TYPE | Yes | Fixed to 'ODPS' |
| ACCESSTYPE | No | The account type. Default value: aliyun. Valid values: aliyun, sts, and app. |
| ACCESSID / ACCESSKEY | Yes | The AccessKey of the RAM user (not the main account AK). |
| STSTOKEN | Conditional | Required only when ACCESSTYPE = 'sts'. |
| ENDPOINT | Yes | The endpoint of MaxCompute, including the region. |
| TUNNEL_ENDPOINT | Yes | The tunnel endpoint, used for efficient data retrieval. |
| PROJECT_NAME | Yes | The name of the MaxCompute project (equivalent to a database). |
| QUOTA_NAME | No | The name of the compute resource quota (if applicable). |
| COMPRESSION | No | The data compression format (must match the ODPS table). If not specified, compression is disabled. |
| API_MODE | Yes | Specifies the API mode for accessing ODPS. For more information, see the details below. |
| SPLIT | Yes | When using storage_api, specifies whether to split tasks by byte or row. If the data size of each row in a table varies significantly, set SPLIT to byte. Otherwise, set it to row. |
| REGION | Yes | The region where MaxCompute is enabled. |
API_MODE
Starting from OceanBase Database V4.3.5 BP3, the API_MODE and SPLIT parameters are supported in OceanBase Database V4.3.5:
tunnel_api (default):
No special network configuration is required: applicable to all deployment scenarios, without the need for OceanBase Database and MaxCompute to be in the same VPC (Virtual Private Cloud).
No additional MaxCompute permissions are required: only the AccessID and AccessKey are needed for authentication, without the need to enable MaxCompute Storage API permissions.
Applicable environments:
- OceanBase Database and MaxCompute are not deployed in the same VPC.
- MaxCompute Storage API is not enabled.
- Data transmission is not latency-sensitive.
storage_api:
Network dependency: requires OceanBase Database and MaxCompute to be deployed in the same VPC to achieve low latency and high throughput data transmission.
Permission dependency: requires enabling the Storage API in MaxCompute and ensuring the AccessKey has the necessary permissions.
Quota requirements: when using the storage_api mode, the QUOTA parameter must be set to pay-as-you-go (on-demand) quota to ensure normal billing and execution of Storage API calls. For more information, see: Overview of MaxCompute Storage API.
Applicable environments:
- OceanBase Database and MaxCompute are in the same VPC.
- MaxCompute Storage API is enabled.
- Large volumes of data or high real-time requirements.
Example
CREATE EXTERNAL CATALOG odps_prod
PROPERTIES (
TYPE = 'ODPS',
ACCESSID = 'LTAI5tXXXXXX',
ACCESSKEY = 'xxxxxxxxxxxxxx',
ENDPOINT = 'http://service.cn-hangzhou.maxcompute.aliyun.com/api',
TUNNEL_ENDPOINT = 'http://dt.cn-hangzhou.maxcompute.aliyun.com',
PROJECT_NAME = 'sales_analytics',
REGION = 'cn-hangzhou'
);
Security recommendations:
- Use RAM subaccounts and follow the principle of least privilege.
- Avoid hardcoding plaintext AKs in SQL; instead, inject them using variables or a key management service.
Usage
Switch catalog
-- Method 1: Switch only the catalog
SET CATALOG odps_prod;
-- Method 2: Switch both the catalog and database
USE odps_prod.sales_db;
Query ODPS tables
-- If the catalog has been switched to odps_prod, you can directly query
SELECT * FROM user_log
WHERE dt = '20250401'
LIMIT 10;
-- Federated query (JOIN with internal tables)
SELECT o.order_id, u.city
FROM internal.test_db.orders o
JOIN users u ON o.user_id = u.id;
Metadata operations
-- View table structure
DESC odps_prod.sales_db.user_log;
-- View create table statement
SHOW CREATE TABLE odps_prod.sales_db.user_log;
-- List all catalogs in the current tenant
SHOW CATALOGS;
-- View create catalog statement
SHOW CREATE CATALOG odps_prod;
Delete a catalog
DROP CATALOG IF EXISTS odps_prod;