Use a Hologres external table to query data in Hologres directly from MaxCompute—without importing or exporting data. MaxCompute connects to the Hologres instance via the PostgreSQL JDBC driver and reads from the Hologres storage layer. Two authentication modes are supported: STS mode and double-signature mode.
How it works
Create a Hologres external table in MaxCompute using the
CREATE EXTERNAL TABLEstatement. The statement specifies a StorageHandler, the JDBC endpoint of the Hologres instance, and authentication details.Submit a query against the external table from MaxCompute.
MaxCompute reads data from Hologres using JDBC mode (default) or direct read mode (recommended for performance).
Query results are returned to MaxCompute without duplicating the underlying data.
Choose an authentication mode
Before creating an external table, choose the authentication mode that fits your setup.
| STS mode | Double-signature mode | |
|---|---|---|
| How it works | MaxCompute assumes a RAM role to access Hologres using Security Token Service (STS) credentials | MaxCompute signs your account credentials and passes them to Hologres; no separate role configuration needed |
| IP address whitelist | Blocked—STS mode cannot pass through the Hologres IP address whitelist | Supported |
| Hologres version required | Any | V1.3 or later |
| Data write support | Read and write | Read only |
| Account requirement | A RAM (Resource Access Management) role in the same Alibaba Cloud account | The same account must exist in both MaxCompute and Hologres with read/write permissions on the target table |
| Use when | You need read/write access and are not using an IP address whitelist | You use an IP address whitelist, or you want to avoid configuring a separate RAM role |
Hologres does not support adding a RAM role from a different Alibaba Cloud account. Both STS mode and cross-account access to Hologres external tables require RAM roles from the same account.
Limitations
DML restrictions
UPDATE and DELETE are not supported on Hologres external tables.
INSERT OVERWRITE is not supported. To overwrite data from MaxCompute into Hologres, read the external table that maps to the MaxCompute table from Hologres and use Hologres's INSERT OVERWRITE semantics.
The upsert (INSERT ON CONFLICT) mechanism of Hologres is not supported when writing to an external table. If the Hologres source table has a primary key, the data you write must not violate the primary key uniqueness constraint.
Write risk
Parallel writes across multiple processes to a Hologres external table may occasionally cause data duplication.
Table type restrictions
Hologres external tables do not support the cluster property.
Hologres external tables cannot be mapped to Dynamic Tables in Hologres.
Partitioned tables in Hologres do not correspond to partitioned tables in MaxCompute. Hologres external tables do not support partitions. Exception: in direct read mode, if you query a Hologres external table mapped to a partitioned parent table in Hologres, partition pruning applies when the query conditions match the partition key columns of the child tables.
Both parent and child tables in Hologres can be mapped to a Hologres external table, but parent tables are read-only.
Schema compatibility
If the schema of the Hologres source table differs from that of the external table:
Fewer columns in Hologres than in the DDL: An error occurs when reading. For example:
column "xxx" does not exist.More columns in Hologres than in the DDL: Extra columns are ignored.
Incompatible column types: MaxCompute does not support using the INT type to receive STRING data from Hologres. Using STRING to receive INT data is allowed but not recommended.
Create a Hologres external table
Prerequisites
Before you begin, ensure that you have:
A MaxCompute project. See Create a MaxCompute project
(STS mode only) A RAM role authorized to access the Hologres instance. See Authorize a regular RAM role in STS mode for Hologres
(Double-signature mode only) An account with the same name as your MaxCompute account in Hologres, with read and write permissions on the target table; Hologres V1.3 or later
Syntax
All examples use the com.aliyun.odps.jdbc.JdbcStorageHandler StorageHandler and the org.postgresql.Driver PostgreSQL JDBC driver. The two modes differ in how authentication is specified.
STS mode
CREATE EXTERNAL TABLE [IF NOT EXISTS] <table_name>(
<col1_name> <data_type>,
<col2_name> <data_type>,
...
)
STORED BY 'com.aliyun.odps.jdbc.JdbcStorageHandler'
WITH SERDEPROPERTIES (
'odps.properties.rolearn'='<ram_arn>')
LOCATION 'jdbc:postgresql://<endpoint>:<port>/<database>?ApplicationName=MaxCompute&[currentSchema=<schema>&][useSSL={true|false}&]table=<holo_table_name>/'
TBLPROPERTIES (
'mcfed.mapreduce.jdbc.driver.class'='org.postgresql.Driver',
'odps.federation.jdbc.target.db.type'='holo',
'odps.federation.jdbc.colmapping'='<table_column1>:<source_column1>, <table_column2>:<source_column2>,...'
);Double-signature mode
-- Enable double-signature mode.
SET odps.sql.common.table.planner.ext.hive.bridge=true;
-- Create an external table.
CREATE EXTERNAL TABLE [IF NOT EXISTS] <table_name>(
<col1_name> <data_type>,
<col2_name> <data_type>,
...
)
STORED BY 'com.aliyun.odps.jdbc.JdbcStorageHandler'
LOCATION 'jdbc:postgresql://<endpoint>:<port>/<database>?ApplicationName=MaxCompute&[currentSchema=<schema>&][useSSL={true|false}&]table=<holo_table_name>/'
TBLPROPERTIES (
'mcfed.mapreduce.jdbc.driver.class'='org.postgresql.Driver',
'odps.federation.jdbc.target.db.type'='holo',
['odps.federation.jdbc.colmapping'='<table_column1>:<source_column1>, <table_column2>:<source_column2>,...']
);Double-signature mode requires that SET odps.sql.common.table.planner.ext.hive.bridge=true is set both when creating the external table and when querying it.Parameters
| Parameter | Required | Description |
|---|---|---|
IF NOT EXISTS | No | If omitted and a table with the same name exists, an error is returned. If specified, the statement succeeds regardless—even if the existing table has a different schema. The existing table's metadata is not modified. |
table_name | Yes | Name of the external table to create in MaxCompute. Table names and field names are case-insensitive. |
col_name | Yes | Column name in the external table. |
data_type | Yes | Data type of the column. See Supported data types. |
odps.properties.rolearn | STS mode only | The ARN (Alibaba Cloud Resource Name) of the RAM role for STS authentication. To find the ARN: log on to the RAM console, go to Identities > Roles, click the target role, and copy the ARN from the Basic Information section. |
LOCATION | Yes | The JDBC connection string for the Hologres instance. Parameters: |
— endpoint | Yes | The classic network domain name of the Hologres instance. To get the endpoint: log on to the Hologres console, go to Instances, click the instance, and find the classic network domain name and port in the Network Information section. Currently, only classic network domain names are supported. VPC domain names are not supported. |
— port | Yes | The network port of the Hologres instance. |
— database | Yes | The name of the Hologres database to connect to. |
— ApplicationName | Yes | Fixed value: MaxCompute. |
— currentSchema | No | The Hologres schema. Omit if the table name is unique within the database or the table is in the default schema. |
— useSSL | No | Whether to use SSL. Valid values: true, false. |
— table (holo_table_name) | Yes | The name of the Hologres source table. |
mcfed.mapreduce.jdbc.driver.class | Yes | Fixed value: org.postgresql.Driver. |
odps.federation.jdbc.target.db.type | Yes | Fixed value: holo. |
odps.federation.jdbc.colmapping | No | Maps columns in the external table to columns in the Hologres source table. Format: '<mc_col>:<holo_col>, ...'. If omitted, columns are matched by name. If a Hologres field name contains uppercase letters, enclose it in double quotation marks: 'x:"HoloCol"'. If specified for only some columns, unspecified columns are matched by name; an error is returned if their names or types do not match. |
mcfed.mapreduce.jdbc.input.query | No | A custom SELECT statement for reading from Hologres. Format: SELECT xxx FROM <holo_database_name>.<holo_schema_name>.<holo_table_name>. Column names and types in the external table must match those in the query result (including aliases). |
Examples
The following examples use this Hologres setup:
Database:
holo_external_testSchema:
publicTable:
holoClassic network endpoint:
hgprecn-cn-oew210ut****-cn-hangzhou-internal.hologres.aliyuncs.com:80
Prepare sample data
Skip this step if you already have a Hologres database, table, and data.
Create a Hologres database:
Log on to the Hologres console and select the region.Hologres Management Console
In the left navigation pane, click Instances.
If you don't have an instance, purchase one. Then click the instance name.
On the instance details page, click Connect to Instance.
Click the Metadata Management tab, then click Create Database. Enter a database name and keep the other defaults.
Create a Hologres table with sample data:
On the instance details page, click Connect to Instance, then click the SQL Editor tab.
Run the following statements:
CREATE TABLE IF NOT EXISTS holo ( id INT PRIMARY KEY, name TEXT ); INSERT INTO holo (id, name) VALUES (1, 'kate'), (2, 'mary'), (3, 'bob'), (4, 'tom'), (5, 'lulu'), (6, 'mark'), (7, 'haward'), (8, 'lilei'), (9, 'hanmeimei'), (10, 'lily'), (11, 'lucy'); SELECT * FROM holo ORDER BY id;
Create and query a Hologres external table (STS mode)
Log on to the MaxCompute client and switch to your project.
Create the external table:
CREATE EXTERNAL TABLE IF NOT EXISTS my_table_holo_jdbc ( id BIGINT, name STRING ) STORED BY 'com.aliyun.odps.jdbc.JdbcStorageHandler' WITH SERDEPROPERTIES ( 'odps.properties.rolearn'='acs:ram::139699392458****:role/<role name>') LOCATION 'jdbc:postgresql://hgprecn-cn-oew210ut****-cn-hangzhou-internal.hologres.aliyuncs.com:80/<holo database name>?ApplicationName=MaxCompute¤tSchema=public&useSSL=true&table=<table name>/' TBLPROPERTIES ( 'mcfed.mapreduce.jdbc.driver.class'='org.postgresql.Driver', 'odps.federation.jdbc.target.db.type'='holo', 'odps.federation.jdbc.colmapping'='id:id,name:name' );Query the external table:
-- Required session properties for accessing a Hologres external table. SET odps.sql.split.hive.bridge=true; SET odps.sql.hive.compatible=true; SET odps.table.api.enable.holo.table=true; -- Enable direct read mode. SELECT * FROM my_table_holo_jdbc LIMIT 10;Expected output:
+------------+------------+ | id | name | +------------+------------+ | 9 | hanmeimei | | 4 | tom | | 7 | haward | | 2 | mary | | 5 | lulu | | 8 | lilei | | 10 | lily | | 1 | kate | | 6 | mark | | 11 | lucy | +------------+------------+Write processed data back to Hologres:
SET odps.sql.split.hive.bridge=true; SET odps.sql.hive.compatible=true; SET odps.table.api.enable.holo.table=true; INSERT INTO my_table_holo_jdbc VALUES (12, 'alice');Join the Hologres external table with a MaxCompute internal table for federated analysis:
SET odps.sql.split.hive.bridge=true; SET odps.sql.hive.compatible=true; -- Create a MaxCompute internal table from the external table. CREATE TABLE holo_test AS SELECT * FROM my_table_holo_jdbc; -- Join the internal table and the external table. SELECT * FROM my_table_holo_jdbc t1 INNER JOIN holo_test t2 ON t1.id = t2.id;
Create and query a Hologres external table (double-signature mode)
Double-signature is an authentication protocol jointly developed by MaxCompute and Hologres. MaxCompute signs your account credentials and passes them to Hologres. Hologres authenticates the same account based on the agreed protocol, so you can access the external table without configuring additional credentials.
Log on to the MaxCompute client and switch to your project.
Create the external table:
-- Enable double-signature mode before creating the table. SET odps.sql.common.table.planner.ext.hive.bridge=true; CREATE EXTERNAL TABLE IF NOT EXISTS holo_mc_external_dbl ( id INT, name STRING ) STORED BY 'com.aliyun.odps.jdbc.JdbcStorageHandler' LOCATION 'jdbc:postgresql://hgpostcn-cn-****-cn-hangzhou-internal.hologres.aliyuncs.com:80/<holo database name>?ApplicationName=MaxCompute¤tSchema=public&preferQueryMode=simple&useSSL=false&table=<table name>/' TBLPROPERTIES ( 'mcfed.mapreduce.jdbc.driver.class'='org.postgresql.Driver', 'odps.federation.jdbc.target.db.type'='holo', 'odps.federation.jdbc.colmapping'='id:id,name:name' );Query the external table. The
SETcommand must be run in the same session as the query:SET odps.sql.common.table.planner.ext.hive.bridge=true; SELECT * FROM holo_mc_external_dbl;
Enable direct read from storage
By default, MaxCompute reads Hologres external tables in JDBC mode. Direct read mode reads data directly from the Hologres storage layer, which:
Significantly reduces query latency
Reduces connections to Hologres frontend (FE) nodes—most queries require only one connection
If the conditions for direct read are not met, the system falls back to JDBC mode automatically.
Requirements
| Requirement | Detail |
|---|---|
| Hologres version | V1.3.34 or later |
| Table type | Column-oriented tables only. Cold storage tables and row-oriented tables are not supported. |
| Network | MaxCompute and Hologres must be in the same region. Cross-region access returns: FAILED: ODPS-0010000:System internal error - fuxi job failed |
| Architecture | If Hologres uses a primary-secondary architecture, use the primary instance connection URL only. Replica URLs are not supported. |
| Foreign Server mode | The schema-level syntax switch must be enabled for the MaxCompute project. |
Timestamp type mapping behavior
When mapping the Hologres TIMESTAMP WITH TIME ZONE type to the MaxCompute TIMESTAMP type in direct read mode, minor time differences may occur:
| Hologres timestamp range | MaxCompute reads |
|---|---|
Earlier than 1900-12-31 15:54:15 | 5 minutes and 44 seconds later than the stored value |
1900-12-31 15:54:16 to 1969-12-31 23:59:58 | 1 second later than the stored value |
Later than 1969-12-31 23:59:59 | Matches the stored value |
Time zone offset: if MaxCompute uses UTC+8 and Hologres stores 2000-01-01 00:00:00, MaxCompute reads 2000-01-01 08:00:00. For 1969-01-01 00:00:00, MaxCompute reads 1969-01-01 08:00:01.
Enable direct read
Add the following parameter before each query to enable direct read at the statement level:
SET odps.table.api.enable.holo.table=true;To enable direct read at the project level:
-- Enable direct read for all queries in the project.
setproject odps.table.api.enable.holo.table=true; -- true: enable, false: disable
-- Disable automatic fallback to JDBC mode.
setproject odps.table.api.allow.fallback.jdbc=false; -- true: fall back, false: do not fall backVerify the read mode
View the job logs in Logview to confirm whether a query used direct read mode. For details on using Logview, see Use Logview V2.0 to view job information.
On the Summary tab, locate the external holo tables field. The format is:
<project_name>.<table_name>:<Access mode>[(<Fallback reason>)]| Field | Description |
|---|---|
project_name | The project name. |
table_name | The external table name. |
Access mode | Optimized: direct read mode is active. Fallback: the system fell back to JDBC mode. |
Fallback reason | Appears only when the access mode is Fallback. See the table below for possible values and solutions. |
Fallback reasons and solutions:
| Fallback reason | Cause | Solution |
|---|---|---|
Column type map error Column name ${ColumnName} | Column types in MaxCompute and Hologres are incompatible. | Update the external table column type to match the Hologres type mapping. |
Holo connection error | The Hologres connection is abnormal. Permissions may be incorrect or the instance may be unhealthy. | Verify that the current user has access to the Hologres database and that the instance is active. |
Odps table is partition table | The MaxCompute external table is a partitioned table, which is not supported in direct read mode. | Remove the partition definition from the external table. |
Select hg_version error, Hologres version check error, or Fetch hg_version data error | The Hologres instance version is too old. | Upgrade the instance to V1.3.34 or later. See Upgrade an instance. |
Handling fallback under heavy load:
If a task running in direct read mode hits a limit and falls back to JDBC mode during heavy load, the fallback consumes Hologres connection pool resources and data transmission efficiency drops. To prevent unexpected impacts on other services, disable automatic fallback:
SET odps.table.api.allow.fallback.jdbc=false;Import and export data
Supported data types
Type limits
DECIMAL: Fixed at
DECIMAL(38,18). If the Hologres source table uses fewer decimal places, define the column asSTRINGin the external table and useCASTfor conversion when needed.Complex types:
ARRAY,MAP, andSTRUCTare not supported in external tables. Array types (INT4[],INT8[], etc.) are supported only in JDBC read and direct read—not in JDBC write.Unsupported types: Hologres types with no MaxCompute equivalent—including
MONEY,OID,UUID,BIT(n),VARBIT(n),INTERVAL,TIMETZ,TIME,INET,RoaringBitmap, andRoaringBitmap64—cannot be read or written through external tables. Queries against columns of these types return an error.
Type mapping table
| Hologres type | MaxCompute type | JDBC read | JDBC write | Direct read | Notes |
|---|---|---|---|---|---|
| INTEGER (INT, INT4) | INT | Supported | Supported | Supported | 32-bit signed integer. |
| SMALLINT | SMALLINT | Supported | Supported | Supported | 16-bit signed integer. |
| INT2 | SMALLINT | Supported | Supported | Supported | 16-bit signed integer. |
| BIGINT (INT8) | BIGINT | Supported | Supported | Supported | 64-bit signed integer. |
| REAL (FLOAT4) | FLOAT | Supported | Supported | Supported | 32-bit binary floating-point. |
| DOUBLE PRECISION (FLOAT8) | DOUBLE | Supported | Supported | Supported | 64-bit binary floating-point. |
| BOOLEAN (BOOL) | BOOLEAN | Supported | Supported | Supported | |
| TEXT | STRING, VARCHAR | Supported | Supported | Supported | Maximum 8 MB. |
| CHAR(n) | CHAR(n) | Supported | Supported | Supported | MaxCompute maximum: 255 characters. Hologres maximum: 1 GB. |
| VARCHAR(n) | VARCHAR(n) | Supported | Supported | Supported | MaxCompute range: 1–65,535. Hologres maximum: 1 GB. |
| BYTEA | BINARY | Supported | Supported | Supported | MaxCompute maximum: 8 MB. Hologres maximum: 1 GB. |
| DATE | DATE | Supported | Supported | Supported | Format: yyyy-mm-dd. |
| TIMESTAMP | TIMESTAMP_NTZ | Supported | Not supported | Supported | Hologres stores at microsecond precision; no time zone. MaxCompute stores at nanosecond precision. Time zone errors may occur. |
| TIMESTAMP WITH TIME ZONE (TIMESTAMPTZ) | TIMESTAMP | Supported | Not supported | Supported | MaxCompute outputs without time zone. Time differences may occur in direct read mode—see Timestamp type mapping behavior. |
| DECIMAL (NUMERIC) | DECIMAL(precision,scale) | Supported | Supported | Supported | If precision is unspecified in MaxCompute, defaults to (38,18). Valid range: precision 1–38, scale 0–18. |
| SERIAL (auto-increment) | INT | Supported | Not supported | Supported | The INT column receives the value, but auto-increment is not applied during writes. |
| JSON | STRING | Supported | Not supported | Not supported | Supported in JDBC read mode. Maximum 8 MB. |
| JSONB | JSON | Not supported | Not supported | Supported | Supported in direct read mode only. |
| INT4[] | ARRAY\<INT\> | Supported | Not supported | Supported | |
| INT8[] | ARRAY\<BIGINT\> | Supported | Not supported | Supported | |
| FLOAT4[] | ARRAY\<FLOAT\> | Supported | Not supported | Supported | |
| FLOAT8[] | ARRAY\<DOUBLE\> | Supported | Not supported | Supported | |
| BOOLEAN[] | ARRAY\<BOOLEAN\> | Supported | Not supported | Supported | |
| TEXT[] | ARRAY\<STRING\> | Supported | Not supported | Supported | |
| RoaringBitmap | Not supported | Not supported | Not supported | Not supported | No corresponding MaxCompute type. Queries return an error. |
| RoaringBitmap64 | Not supported | Not supported | Not supported | Not supported | No corresponding MaxCompute type. Queries return an error. |
| BIT(n) | Not supported | Not supported | Not supported | Not supported | No corresponding MaxCompute type. Queries return an error. |
| VARBIT(n) | Not supported | Not supported | Not supported | Not supported | No corresponding MaxCompute type. Queries return an error. |
| INTERVAL | Not supported | Not supported | Not supported | Not supported | No corresponding MaxCompute type. Queries return an error. |
| TIMETZ | Not supported | Not supported | Not supported | Not supported | No corresponding MaxCompute type. Queries return an error. |
| TIME | Not supported | Not supported | Not supported | Not supported | No corresponding MaxCompute type. Queries return an error. |
| INET | Not supported | Not supported | Not supported | Not supported | No corresponding MaxCompute type. Queries return an error. |
| MONEY | Not supported | Not supported | Not supported | Not supported | No corresponding MaxCompute type. Queries return an error. |
| OID | Not supported | Not supported | Not supported | Not supported | No corresponding MaxCompute type. Queries return an error. |
| UUID | Not supported | Not supported | Not supported | Not supported | No corresponding MaxCompute type. Queries return an error. |
Troubleshooting
ODPS-0130071 error when directly reading from Hologres
When MaxCompute directly reads from Hologres, the following error appears:
ODPS-0130071:[0,0] Semantic analysis exception - physical plan generation failed:
storage/table/src/input_splits_builder.cpp(195): StorageException: Failed to split
to equal size, total size: 2143570729934, min size: 268435456, max size: 272629760,
max count: 7777, split size: 275629513, split count: 7777MaxCompute uses a default mapper split policy of input data volume / 256 MB. For large tables, this generates more concurrent mappers than the 7,777 limit. Increase the limit or the split size:
SET odps.external.holo.mapper.instances=10000; -- Maximum: 10,000
SET odps.sql.mapper.split.size=512; -- Maximum: 512 MBSlow queries on a Hologres external table
External tables support only full table scans. If you need fast lookup performance, load the data into a MaxCompute internal table instead.
Keyword used as a column name causes a syntax error
If a Hologres column name is a reserved keyword, the following errors appear:
ODPS-0123131:User defined function exception - SQLException in nextKeyValue
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near ","Use odps.federation.jdbc.colmapping to map the Hologres field explicitly. For example, if the Hologres column is named offset (a reserved keyword):
'odps.federation.jdbc.colmapping'='offset:"offset"'What's next
For more common issues with Hologres external tables, see Common issues with data lakehouse and external tables.