The Hologres data source provides bidirectional read and write channels for Hologres. This topic describes the Hologres data synchronization capabilities supported by DataWorks.
Limitations
The Hologres data source supports running synchronization tasks only on a serverless resource group.
Batch read and write
Hologres Writer does not support writing data to Hologres external tables.
Logic for obtaining the Hologres endpoint for data source connectivity:
For Hologres instances in the current region, the endpoint priority is: any Tunnel > Single Tunnel > Public (internet).
For Hologres instances in other regions, the endpoint priority is: Public (internet) > Single Tunnel.
Single-table real-time read
The Hologres version must be 2.1 or later.
Incremental synchronization of Hologres partitioned tables is not supported.
Synchronization of DDL change messages on Hologres tables is not supported.
Hologres incremental synchronization supports the following data types:
INTEGER, BIGINT, TEXT, CHAR(n), VARCHAR(n), REAL, JSON, SERIAL, OID, INT4[], INT8[], FLOAT8[], BOOLEAN[], TEXT[].
For single-table real-time synchronization from Hologres, you must enable Hologres Binlog on the source Hologres table. For more information, see Subscribe to Hologres Binlog.
Full-database real-time write
Real-time data synchronization tasks do not support synchronizing tables without primary keys.
When synchronizing data from a MySQL full database to Hologres in real time, data can only be written to child tables of partitioned tables. Writing to the parent table of a partitioned table is not supported.
Supported data types
Data type | Batch read (Hologres Reader) | Batch write (Hologres Writer) | Real-time write |
UUID | Not supported | Not supported | Not supported |
CHAR | Supported | Supported | Supported |
NCHAR | Supported | Supported | Supported |
VARCHAR | Supported | Supported | Supported |
LONGVARCHAR | Supported | Supported | Supported |
NVARCHAR | Supported | Supported | Supported |
LONGNVARCHAR | Supported | Supported | Supported |
CLOB | Supported | Supported | Supported |
NCLOB | Supported | Supported | Supported |
SMALLINT | Supported | Supported | Supported |
TINYINT | Supported | Supported | Supported |
INTEGER | Supported | Supported | Supported |
BIGINT | Supported | Supported | Supported |
NUMERIC | Supported | Supported | Supported |
DECIMAL | Supported | Supported | Supported |
FLOAT | Supported | Supported | Supported |
REAL | Supported | Supported | Supported |
DOUBLE | Supported | Supported | Supported |
TIME | Supported | Supported | Supported |
DATE | Supported | Supported | Supported |
TIMESTAMP | Supported | Supported | Supported |
BINARY | Supported | Supported | Supported |
VARBINARY | Supported | Supported | Supported |
BLOB | Supported | Supported | Supported |
LONGVARBINARY | Supported | Supported | Supported |
BOOLEAN | Supported | Supported | Supported |
BIT | Supported | Supported | Supported |
JSON | Supported | Supported | Supported |
JSONB | Supported | Supported | Supported |
How it works
Batch read
Hologres Reader supports two read modes:
JDBC mode (default)
Reads data from Hologres tables through PSQL. Multiple concurrent tasks are initiated based on the shard count of the table, with each shard corresponding to one concurrent Select task:
When creating a table in Hologres, you can configure the shard count of the table by running
CALL set_table_property('table_name', 'shard_count', 'xx')within the sameCREATE TABLEtransaction.By default, the database uses the default shard count, which depends on the configuration of the Hologres instance.
The Select statement filters data by shard using the built-in column hg_shard_id of the table.
Arrow mode (useArrow=true)
Reads data through the Hologres COPY OUT Arrow protocol. This mode supports LZ4 compressed transfer and provides higher performance:
Requires Hologres version >= 4.0.18.
Concurrent tasks are also split based on the shard count.
Function columns and constant columns are not supported. Only physical columns in the table are supported.
Compressed transfer is automatically enabled when the version requirement is met.
Batch write
Hologres Writer obtains protocol data generated by the Reader through the data synchronization framework. The channel and conflict resolution strategy used to write data are determined by the writeMode and conflictMode configurations.
Write mode (writeMode)
Write mode | Method | Applicable scenario | Version requirement |
INSERT | Uses Holo Client for batch writing (INSERT ON CONFLICT). | Real-time scenarios (including data retraction) and general write scenarios. | All versions |
FIXED_COPY | Uses Holo Client Fixed Copy for streaming writes. | Real-time scenarios (excluding data retraction). Can also be used for batch import scenarios. | Hologres >= 1.1 |
STAGE | First writes data to Hologres Internal Stage (Arrow format), then imports data from the stage to the destination table. | Recommended mode for batch synchronization. Best performance for large-scale imports. | Hologres >= 4.1.0 |
COPY | Uses JDBC COPY FROM STDIN to write text CSV data. | Batch import scenarios that are compatible with earlier versions. | All versions |
Scenario recommendations
Conflict handling mode (conflictMode)
You can configure conflictMode to specify how newly imported data is handled when a primary key conflict occurs with existing data:
conflictMode applies only to tables that have primary keys. For more information about the write mechanism and performance, see Write data to Hologres.
When conflictMode is set to Replace (full row update), new data overwrites old data. All columns in the row are overwritten. Columns that are not included in the column mapping are forcibly set to NULL.
When conflictMode is set to Update, new data overwrites old data. Only the columns that are included in the column mapping are overwritten.
When conflictMode is set to Ignore, the new data is ignored.
Add a data source
Before you develop a synchronization task in DataWorks, you must add the required data source to DataWorks by following the instructions in Data source management. You can view parameter descriptions in the DataWorks console to understand the meanings of the parameters when you add a data source.
Develop a data synchronization task
Single-table batch synchronization
Supported data sources: All data source types supported by the Data Integration module.
Configuration guide: Configure a batch synchronization task in the codeless UI and Configure a batch synchronization task by using the code editor. For the complete parameters and script demos available in the code editor, see Appendix: Complete parameters and script demos below.
Single-table real-time synchronization
Supported data sources: DataHub, Hologres, Kafka, and LogHub
Configuration guide: Configure a real-time synchronization task.
Full-database batch synchronization
Supported data sources: AnalyticDB for MySQL 3.0, ClickHouse, Doris, Hologres, Oracle, PolarDB, and SQL Server
Configuration guide: Configure a full-database batch synchronization task
Full-database real-time synchronization
Supported data sources: AnalyticDB for OceanBase, MongoDB, MySQL, Oracle, PolarDB, PolarDB-X 2.0, and PostgreSQL
Configuration guide: Configure a real-time synchronization task to synchronize data of a single table
Serverless full-database real-time
Supported data source: MySQL
Configuration guide: Configure a Serverless full-database real-time synchronization task
FAQ about real-time synchronization tasks: FAQ about real-time synchronization.
Appendix: Script demos and parameter description
Configure a batch synchronization task by using the code editor
If you want to configure a batch synchronization task by using the code editor, you must configure the related parameters in the script based on the unified script format requirements. For more information, see Script mode configuration. The following information describes the parameters that you must configure for data sources when you configure a batch synchronization task by using the code editor.
Reader script demos
Configure a non-partitioned table
The following example shows how to configure reading data from a Hologres non-partitioned table into memory.
{ "transform": false, "type": "job", "version": "2.0", "steps": [ { "stepType": "holo", "parameter": { "datasource": "holo_db", "envType": 1, "column": [ "tag", "id", "title", "body" ], "where": "", "table": "holo_reader_basic_src" }, "name": "Reader", "category": "reader" }, { "stepType": "stream", "parameter": { "print": false, "fieldDelimiter": "," }, "name": "Writer", "category": "writer" } ], "setting": { "executeMode": null, "failoverEnable": null, "errorLimit": { "record": "0" }, "speed": { "concurrent": 2, "throttle": false } }, "order": { "hops": [ { "from": "Reader", "to": "Writer" } ] } }The DDL statement of the Hologres table is as follows.
begin; drop table if exists holo_reader_basic_src; create table holo_reader_basic_src( tag text not null, id int not null, title text not null, body text, primary key (tag, id)); call set_table_property('holo_reader_basic_src', 'orientation', 'column'); call set_table_property('holo_reader_basic_src', 'shard_count', '3'); commit;
Configure a partitioned table
Configure reading data from a child table of a Hologres partitioned table into memory.
NotePay attention to the configuration of partition.
{ "transform": false, "type": "job", "version": "2.0", "steps": [ { "stepType": "holo", "parameter": { "selectedDatabase": "public", "partition": "tag=foo", "datasource": "holo_db", "envType": 1, "column": [ "tag", "id", "title", "body" ], "tableComment": "", "where": "", "table": "public.holo_reader_basic_part_src" }, "name": "Reader", "category": "reader" }, { "stepType":"stream", "parameter":{}, "name":"Writer", "category":"writer" } ], "setting":{ "errorLimit":{ "record":"0" }, "speed":{ "throttle":true, "concurrent":1, "mbps":"12" } }, "order":{ "hops":[ { "from":"Reader", "to":"Writer" } ] } }The DDL statement of the Hologres table is as follows.
begin; drop table if exists holo_reader_basic_part_src; create table holo_reader_basic_part_src( tag text not null, id int not null, title text not null, body text, primary key (tag, id)) partition by list( tag ); call set_table_property('holo_reader_basic_part_src', 'orientation', 'column'); call set_table_property('holo_reader_basic_part_src', 'shard_count', '3'); commit; create table holo_reader_basic_part_src_1583161774228 partition of holo_reader_basic_part_src for values in ('foo'); # Ensure that the child tables of the partitioned table have been created and data has been imported. postgres=# \d+ holo_reader_basic_part_src Table "public.holo_reader_basic_part_src" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description --------+---------+-----------+----------+---------+----------+--------------+------------- tag | text | | not null | | extended | | id | integer | | not null | | plain | | title | text | | not null | | extended | | body | text | | | | extended | | Partition key: LIST (tag) Indexes: "holo_reader_basic_part_src_pkey" PRIMARY KEY, btree (tag, id) Partitions: holo_reader_basic_part_src_1583161774228 FOR VALUES IN ('foo')
Reader script parameters
Parameter | Description | Required | Default value |
database | The name of a database in the Hologres instance. | Yes | N/A |
table | The name of the Hologres table. The | Conditionally required | N/A |
querySql | A custom query SQL statement. If this parameter is configured, the table and column parameters are ignored. This parameter is mutually exclusive with | Conditionally required | N/A |
column | The columns to read. | Yes | N/A |
partition | For partitioned tables, specifies the partition column and its value in the format Important
| No | Empty, indicating a non-partitioned table. |
where | The filter condition, which is appended to the WHERE clause of the SELECT statement. This parameter takes effect only in table mode. | No | Empty |
useArrow | Specifies whether to use the Arrow columnar format for high-performance data synchronization. When enabled, Reader uses the COPY OUT Arrow protocol to read data and passes it to the downstream Writer in columnar format for better performance. Hologres 4.0.18 or later is required. If the version does not meet the requirement, the system automatically falls back to JDBC mode. Arrow mode does not support function columns or constant columns. Currently, this mode supports full-database batch synchronization and single-table batch synchronization when both the source and destination are MaxCompute, Hologres, or Hive/OSS/HDFS (Parquet/ORC). For more information, see Use Arrow format for high-performance data synchronization. | No | false |
compress | Specifies whether to enable LZ4 compression for data transfer in Arrow mode. This parameter takes effect only when | No | true (automatically set when the version meets the requirement) |
fetchSize | The number of rows fetched from the database in each request in JDBC mode. | No | 1000 |
jdbcReadTimeout | The JDBC read timeout period. Unit: seconds. | No | 60 |
enableServerlessComputing | Specifies whether to enable Hologres Serverless Computing to accelerate queries. Note: This parameter controls the Serverless Computing capability of the Hologres instance, which is different from a DataWorks serverless resource group. | No | false |
serverlessComputingQueryPriority | The query priority for Hologres Serverless Computing. Valid values: 1 to 10. A larger value indicates a higher priority. This parameter takes effect only when | No | 3 |
serverlessComputingRequiredCores | The number of cores requested for Hologres Serverless Computing. This parameter takes effect only when | No | 5 |
Writer script demo
Configure a non-partitioned table
Configure data generated from MySQL to be imported into a regular Hologres table. The following example shows the configuration for importing data in INSERT mode.
{ "type": "job", "version": "2.0", "steps": [ { "stepType": "mysql", "parameter": { "envType": 0, "useSpecialSecret": false, "column": [ "<column1>", "<column2>", ......, "<columnN>" ], "tableComment": "", "connection": [ { "datasource": "<mysql_source_name>",//MySQL data source name "table": [ "<mysql_table_name>" ] } ], "where": "", "splitPk": "", "encoding": "UTF-8" }, "name": "Reader", "category": "reader" }, { "stepType": "holo", "parameter": { "selectedDatabase":"public", "schema": "public", "writeMode": "FIXED_COPY", "maxConnectionCount": 9, "truncate":true,//Cleanup rule "datasource": "<holo_sink_name>",//Hologres data source name "conflictMode": "ignore", "envType": 0, "column": [ "<column1>", "<column2>", ......, "<columnN>" ], "tableComment": "", "table": "<holo_table_name>", "reShuffleByDistributionKey":false }, "name": "Writer", "category": "writer" } ], "setting": { "executeMode": null, "errorLimit": { "record": "0" }, "locale": "zh_CN", "speed": { "concurrent": 2,//Job concurrency "throttle": false//Throttling } }, "order": { "hops": [ { "from": "Reader", "to": "Writer" } ] } }The DDL statement for the Hologres table is as follows.
begin; drop table if exists mysql_to_holo_test; create table mysql_to_holo_test( tag text not null, id int not null, body text not null, brrth date, primary key (tag, id)); call set_table_property('mysql_to_holo_test', 'orientation', 'column'); call set_table_property('mysql_to_holo_test', 'distribution_key', 'id'); call set_table_property('mysql_to_holo_test', 'clustering_key', 'birth'); commit;
Configure a partitioned table
NoteHologres supports only LIST partitions. Only a single partition column is supported, and the column must be of the INT4 or TEXT type.
Make sure that this parameter matches the partition configuration in the table DDL.
Configure the synchronization of data generated from MySQL to child tables of a Hologres partitioned table.
{ "type": "job", "version": "2.0", "steps": [ { "stepType": "mysql", "parameter": { "envType": 0, "useSpecialSecret": false, "column": [ "<column1>", "<column2>", ......, "<columnN>" ], "tableComment": "", "connection": [ { "datasource": "<mysql_source_name>", "table": [ "<mysql_table_name>" ] } ], "where": "", "splitPk": "<mysql_pk>",//MySQL primary key field "encoding": "UTF-8" }, "name": "Reader", "category": "reader" }, { "stepType": "holo", "parameter": { "selectedDatabase": "public", "writeMode": "insert", "maxConnectionCount": 9, "partition": "ds=20201215",//Hologres partition key "truncate": "false", "datasource": "<holo_sink_name>",//Hologres data source name "conflictMode": "ignore", "envType": 0, "column": [ "<column1>", "<column2>", ......, "<columnN>" ], "tableComment": "", "table": "<holo_table_name>", "reShuffleByDistributionKey":false }, "name": "Writer", "category": "writer" } ], "setting": { "executeMode": null, "failoverEnable": null, "errorLimit": { "record": "0" }, "speed": { "concurrent": 2,//Job concurrency "throttle": false//Throttling } }, "order": { "hops": [ { "from": "Reader", "to": "Writer" } ] } }The DDL statement of the Hologres table is as follows.
BEGIN; CREATE TABLE public.hologres_parent_table( a text , b int, c timestamp, d text, ds text, primary key(ds,b) ) PARTITION BY LIST(ds); CALL set_table_property('public.hologres_parent_table', 'orientation', 'column'); CREATE TABLE public.holo_child_1 PARTITION OF public.hologres_parent_table FOR VALUES IN('20201215'); CREATE TABLE public.holo_child_2 PARTITION OF public.hologres_parent_table FOR VALUES IN('20201216'); CREATE TABLE public.holo_child_3 PARTITION OF public.hologres_parent_table FOR VALUES IN('20201217'); COMMIT;
Writer script parameters
Basic parameters
Parameter | Description | Required | Default value |
database | The name of the database in the Hologres instance. | Yes | N/A |
table | The name of the Hologres table. Schema names in the table name are supported, such as | Yes | N/A |
writeMode | The write mode. Four modes are supported: | Yes | N/A |
conflictMode | The conflict resolution mode. Valid values: | Yes | N/A |
column | The data columns of the destination table. The columns must include the primary key set of the destination table (except for serial auto-increment primary keys and generated columns). | Yes | N/A |
partition | For partitioned tables, this parameter specifies the partition column and its corresponding value in the format of Note
| No | Empty, which indicates a non-partitioned table |
reShuffleByDistributionKey | In Hologres, batch imports to primary key tables trigger table locks by default, which limits the concurrent write capability of multiple connections. Enabling the reShuffle feature allows different tasks in batch synchronization scenarios to write data to specified Holo shards based on distribution keys, enabling concurrent batch writes and significantly improving write performance. Compared to traditional real-time writes in JDBC mode, this feature reduces the load on the Holo server and further improves write efficiency. Important This feature is available only on serverless resource groups. | No | false |
truncate | Specifies whether to clear the destination table before writing data to the Hologres table.
| No | false |
partitionFormat | The formatting rule for dynamic partition values. For Date-type source data, specify a format such as | No | N/A |
preSql | The list of SQL statements to execute before writing data. Execution on the parent table of a partitioned table is not supported. | No | N/A |
postSql | The list of SQL statements to execute after writing data. | No | N/A |
Connection and performance parameters
Parameter | Description | Required | Default value |
maxConnectionCount | The number of concurrent connections for writing. This value is automatically adjusted based on the actual task concurrency ( | No | 3 |
maxRetryCount | The number of retries upon failure. | No | 10 |
jdbcReadTimeout | The JDBC connection timeout period. Unit: seconds. | No | 120 |
maxCommitSize | The maximum number of bytes per commit, in bytes. | No | 2097152 (2 MB) |
maxCommitCount | The maximum number of records per commit. | No | 256 |
reShuffleByDistributionKey | In Hologres, batch imports into primary key tables trigger table locks by default, which limits the concurrent write capability across multiple connections. Enabling the reShuffle feature allows different tasks to write data to specific Holo shards based on the distribution key in batch synchronization scenarios. This enables concurrent batch writes and significantly improves write performance. Compared with traditional real-time writes in JDBC mode, enabling this feature reduces the load on the Holo server and further improves write efficiency. Important This feature is available only on serverless resource groups. | No | false |
removeU0000InTextColumnValue | Specifies whether to remove | No | true |
Hologres Serverless Computing parameters
The following parameters control the Serverless Computing capability of a Hologres instance. They can accelerate query reads for Reader and INSERT FROM Stage operations for Writer in STAGE mode.
Note: Hologres Serverless Computing and DataWorks serverless resource groups are different concepts. The former is the elastic computing capability within a Hologres instance, while the latter refers to the scheduling resources used by DataWorks to run synchronization tasks.
Usage notes: All modes are supported for Reader. Only STAGE mode is supported for Writer.
Parameter | Description | Required | Default value |
enableServerlessComputing | Specifies whether to enable Hologres Serverless Computing acceleration. | No | false |
serverlessComputingQueryPriority | The query priority for Serverless Computing. Valid values: 1 to 10. A larger value indicates a higher priority. | No | 3 |
serverlessComputingRequiredCores | The number of cores requested for Serverless Computing. Set this parameter to 0 to let the engine decide automatically. | No | N/A (not set) |
FIXED_COPY mode-specific parameters
Parameter | Description | Required | Default value |
isBinaryFormat | Specifies whether to use binary format for data transfer. If this parameter is set to true, binary format is used, which provides higher transfer efficiency. If this parameter is set to false, text (CSV) format is used. | No | true |
checkRecordBeforePut | Specifies whether to validate records before writing, including type checks and length checks. If this parameter is enabled, dirty data can be detected on the client side in advance. | No | true |
maxCellBufferSize | The maximum buffer size for a single row of data, in bytes. Make sure that the buffer can hold a complete row. Otherwise, the write operation fails. | No | 10485760 (10 MB) |
Parameters specific to STAGE mode
Parameter | Description | Required | Default value |
stageTTL | The time-to-live (TTL) of the internal stage, in seconds. A stage is automatically cleaned up after this period. | No | 86400 (1 day) |
stageFileSizeLimit | The maximum size of a single stage file, in bytes. A new file is automatically created when this limit is exceeded. | No | 67108864 (64 MB) |
stageMaxBatchSize | The maximum number of rows in an Arrow batch for record writing. An Arrow RecordBatch is written each time the specified number of rows is accumulated. | No | 8192 |
stageCompress | Specifies whether to enable Arrow LZ4 compression. If this parameter is enabled, stage storage space and network transfer volume are significantly reduced. This feature requires Hologres >= 4.2.8. If the version requirement is not met, compression is automatically disabled. | No | true |
Advanced parameters
Parameter | Description | Required | Default value |
useArrow | Specifies whether to use the Arrow columnar write path. If this parameter is set to true and the Hologres version is >= 4.1.0, the STAGE write mode is automatically enabled. Hologres Writer can receive Arrow-formatted data (ArrowTabularRecord) produced by any upstream reader, and can also receive standard row-based records, which are automatically converted to Arrow format for writing to the stage. For more information, see Arrow columnar write. | No | false |
default.enable | Specifies whether to automatically populate default values for columns that are defined as NOT NULL but have no values specified. | No | true |
enableWriteBitTypeWithString | Specifies whether to allow writing BIT data as strings. | No | false |
holoClient | Advanced configuration items for Holo Client in Map format. You can set any parameters of the underlying HoloConfig. Example: | No | None |