All Products
Search
Document Center

MaxCompute:Hologres external tables

Last Updated:Mar 25, 2026

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

  1. Create a Hologres external table in MaxCompute using the CREATE EXTERNAL TABLE statement. The statement specifies a StorageHandler, the JDBC endpoint of the Hologres instance, and authentication details.

  2. Submit a query against the external table from MaxCompute.

  3. MaxCompute reads data from Hologres using JDBC mode (default) or direct read mode (recommended for performance).

  4. 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 modeDouble-signature mode
How it worksMaxCompute assumes a RAM role to access Hologres using Security Token Service (STS) credentialsMaxCompute signs your account credentials and passes them to Hologres; no separate role configuration needed
IP address whitelistBlocked—STS mode cannot pass through the Hologres IP address whitelistSupported
Hologres version requiredAnyV1.3 or later
Data write supportRead and writeRead only
Account requirementA RAM (Resource Access Management) role in the same Alibaba Cloud accountThe same account must exist in both MaxCompute and Hologres with read/write permissions on the target table
Use whenYou need read/write access and are not using an IP address whitelistYou 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:

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

ParameterRequiredDescription
IF NOT EXISTSNoIf 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_nameYesName of the external table to create in MaxCompute. Table names and field names are case-insensitive.
col_nameYesColumn name in the external table.
data_typeYesData type of the column. See Supported data types.
odps.properties.rolearnSTS mode onlyThe 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.
LOCATIONYesThe JDBC connection string for the Hologres instance. Parameters:
endpointYesThe 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.
portYesThe network port of the Hologres instance.
databaseYesThe name of the Hologres database to connect to.
ApplicationNameYesFixed value: MaxCompute.
currentSchemaNoThe Hologres schema. Omit if the table name is unique within the database or the table is in the default schema.
useSSLNoWhether to use SSL. Valid values: true, false.
table (holo_table_name)YesThe name of the Hologres source table.
mcfed.mapreduce.jdbc.driver.classYesFixed value: org.postgresql.Driver.
odps.federation.jdbc.target.db.typeYesFixed value: holo.
odps.federation.jdbc.colmappingNoMaps 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.queryNoA 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_test

  • Schema: public

  • Table: holo

  • Classic 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:

  1. Log on to the Hologres console and select the region.Hologres Management Console

  2. In the left navigation pane, click Instances.

  3. If you don't have an instance, purchase one. Then click the instance name.

  4. On the instance details page, click Connect to Instance.

  5. 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:

  1. On the instance details page, click Connect to Instance, then click the SQL Editor tab.

  2. 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)

  1. Log on to the MaxCompute client and switch to your project.

  2. 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&currentSchema=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'
    );
  3. 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       |
    +------------+------------+
  4. 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');
  5. 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.

  1. Log on to the MaxCompute client and switch to your project.

  2. 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&currentSchema=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'
    );
  3. Query the external table. The SET command 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

RequirementDetail
Hologres versionV1.3.34 or later
Table typeColumn-oriented tables only. Cold storage tables and row-oriented tables are not supported.
NetworkMaxCompute and Hologres must be in the same region. Cross-region access returns: FAILED: ODPS-0010000:System internal error - fuxi job failed
ArchitectureIf Hologres uses a primary-secondary architecture, use the primary instance connection URL only. Replica URLs are not supported.
Foreign Server modeThe 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 rangeMaxCompute reads
Earlier than 1900-12-31 15:54:155 minutes and 44 seconds later than the stored value
1900-12-31 15:54:16 to 1969-12-31 23:59:581 second later than the stored value
Later than 1969-12-31 23:59:59Matches 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 back

Verify 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>)]
FieldDescription
project_nameThe project name.
table_nameThe external table name.
Access modeOptimized: direct read mode is active. Fallback: the system fell back to JDBC mode.
Fallback reasonAppears only when the access mode is Fallback. See the table below for possible values and solutions.

Fallback reasons and solutions:

Fallback reasonCauseSolution
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 errorThe 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 tableThe 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 errorThe 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

  • To import data from Hologres into a MaxCompute table or partition, use the LOAD command.

  • To export data from MaxCompute to Hologres for use by other compute engines, use the UNLOAD command.

Supported data types

Type limits

  • DECIMAL: Fixed at DECIMAL(38,18). If the Hologres source table uses fewer decimal places, define the column as STRING in the external table and use CAST for conversion when needed.

  • Complex types: ARRAY, MAP, and STRUCT are 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, and RoaringBitmap64—cannot be read or written through external tables. Queries against columns of these types return an error.

Type mapping table

Hologres typeMaxCompute typeJDBC readJDBC writeDirect readNotes
INTEGER (INT, INT4)INTSupportedSupportedSupported32-bit signed integer.
SMALLINTSMALLINTSupportedSupportedSupported16-bit signed integer.
INT2SMALLINTSupportedSupportedSupported16-bit signed integer.
BIGINT (INT8)BIGINTSupportedSupportedSupported64-bit signed integer.
REAL (FLOAT4)FLOATSupportedSupportedSupported32-bit binary floating-point.
DOUBLE PRECISION (FLOAT8)DOUBLESupportedSupportedSupported64-bit binary floating-point.
BOOLEAN (BOOL)BOOLEANSupportedSupportedSupported
TEXTSTRING, VARCHARSupportedSupportedSupportedMaximum 8 MB.
CHAR(n)CHAR(n)SupportedSupportedSupportedMaxCompute maximum: 255 characters. Hologres maximum: 1 GB.
VARCHAR(n)VARCHAR(n)SupportedSupportedSupportedMaxCompute range: 1–65,535. Hologres maximum: 1 GB.
BYTEABINARYSupportedSupportedSupportedMaxCompute maximum: 8 MB. Hologres maximum: 1 GB.
DATEDATESupportedSupportedSupportedFormat: yyyy-mm-dd.
TIMESTAMPTIMESTAMP_NTZSupportedNot supportedSupportedHologres stores at microsecond precision; no time zone. MaxCompute stores at nanosecond precision. Time zone errors may occur.
TIMESTAMP WITH TIME ZONE (TIMESTAMPTZ)TIMESTAMPSupportedNot supportedSupportedMaxCompute outputs without time zone. Time differences may occur in direct read mode—see Timestamp type mapping behavior.
DECIMAL (NUMERIC)DECIMAL(precision,scale)SupportedSupportedSupportedIf precision is unspecified in MaxCompute, defaults to (38,18). Valid range: precision 1–38, scale 0–18.
SERIAL (auto-increment)INTSupportedNot supportedSupportedThe INT column receives the value, but auto-increment is not applied during writes.
JSONSTRINGSupportedNot supportedNot supportedSupported in JDBC read mode. Maximum 8 MB.
JSONBJSONNot supportedNot supportedSupportedSupported in direct read mode only.
INT4[]ARRAY\<INT\>SupportedNot supportedSupported
INT8[]ARRAY\<BIGINT\>SupportedNot supportedSupported
FLOAT4[]ARRAY\<FLOAT\>SupportedNot supportedSupported
FLOAT8[]ARRAY\<DOUBLE\>SupportedNot supportedSupported
BOOLEAN[]ARRAY\<BOOLEAN\>SupportedNot supportedSupported
TEXT[]ARRAY\<STRING\>SupportedNot supportedSupported
RoaringBitmapNot supportedNot supportedNot supportedNot supportedNo corresponding MaxCompute type. Queries return an error.
RoaringBitmap64Not supportedNot supportedNot supportedNot supportedNo corresponding MaxCompute type. Queries return an error.
BIT(n)Not supportedNot supportedNot supportedNot supportedNo corresponding MaxCompute type. Queries return an error.
VARBIT(n)Not supportedNot supportedNot supportedNot supportedNo corresponding MaxCompute type. Queries return an error.
INTERVALNot supportedNot supportedNot supportedNot supportedNo corresponding MaxCompute type. Queries return an error.
TIMETZNot supportedNot supportedNot supportedNot supportedNo corresponding MaxCompute type. Queries return an error.
TIMENot supportedNot supportedNot supportedNot supportedNo corresponding MaxCompute type. Queries return an error.
INETNot supportedNot supportedNot supportedNot supportedNo corresponding MaxCompute type. Queries return an error.
MONEYNot supportedNot supportedNot supportedNot supportedNo corresponding MaxCompute type. Queries return an error.
OIDNot supportedNot supportedNot supportedNot supportedNo corresponding MaxCompute type. Queries return an error.
UUIDNot supportedNot supportedNot supportedNot supportedNo 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: 7777

MaxCompute 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 MB

Slow 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.