Create a Sync from Clickhouse to Batch Profile Attributes
Before you start
To create a ClickHouse → Batch sync, you'll need:
Access to the Batch dashboard
A ClickHouse table or view containing one row per profile
Your ClickHouse credentials (Host, Port, Database, Username, Password)
A table (or view) that follows the Cloud Sync input format (see below)
1) Prepare your ClickHouse table or view
Cloud Sync expects your ClickHouse source (table or view) to include:
A profile identifier (to know which profile to update)
A cursor field (to know what changed since the last run)
Any number of attribute columns (sent to Batch as profile attributes)
1.1 One row per profile
Your source must contain one row per profile. Each row is interpreted as an update to a single Batch profile.
1.2 Required columns
Your table (or view) must include:
custom_id
✅
The profile identifier in Batch
last_updated_at
✅
Cursor used for incremental sync
last_updated_at must be updated every time any synced attribute changes, otherwise updates may not be picked up by the next run.
1.3 Attribute naming rules (ClickHouse-compatible)
Cloud Sync reads ClickHouse columns and converts them into Batch profile attributes.
ClickHouse column names do not support characters like $, (, or ). Cloud Sync relies on prefixes in column names to represent typed or native fields.
Supported prefixes
date__
Date attribute
date__birthday
url__
URL attribute
url__avatar
batch__
Native profile fields (instead of $...)
batch__email_address
1.4 Handling arrays
Array attributes must be passed as a String column containing a stringified JSON array. Native ClickHouse Array() types are not supported.
Example:
1.5 Example schema (e-commerce)
How this maps in Batch:
custom_ididentifies the profilebatch__email_addressupdates the profile's native email fieldplan,country,lifetime_value,is_vipbecome standard attributesinterestsis interpreted as an array attribute (must be a stringified JSON array)url__avataris interpreted as a URL attributedate__birthdayanddate__last_purchaseare interpreted as date attributes
1.6 Using a View
If your raw table doesn't match the expected naming or format, create a ClickHouse View that converts your schema into the correct conventions.
This approach lets you:
rename fields with the correct prefixes (
batch__,date__,url__)compute a reliable
last_updated_atstringify array columns correctly
ensure you always expose one row per profile
1.7 Handling nulls
If a column value is NULL, Batch interprets it as attribute removal for that profile.
If you don't want an attribute removed:
ensure your view returns a non-null value, or
exclude the column from the sync entirely.
1.8 Attributes limits and constraints
All attributes sent through Cloud Sync must respect the same limits and constraints as the Batch Profile API. See Profile API documentation, the attributes object.
2) Create the Sync in the Batch dashboard
Cloud Sync is configured from the dashboard via a dedicated Sync module.
Open the Batch dashboard
Go to Data → Cloud Sync
Click Create Sync
Select ClickHouse as the source
2.1 Configure your ClickHouse connection
Enter the following fields:
Host
Your ClickHouse server hostname (e.g. your-host.example.com)
Port
ClickHouse HTTP(S) port — defaults to 8123
Database
The database containing your source table/view (default: default)
Username
Your ClickHouse username
Password
Your ClickHouse password
SSL
Toggle on to use a secure connection (recommended for production)
Table
The table or view name
Batch validates the connection before continuing.
2.2 Configure profile mapping
Cloud Sync applies a simple mapping model:
custom_id→ identifies which Batch profile to updateall other columns → mapped to profile attributes
last_updated_at→ used only for incremental sync logic
3) How incremental sync works
Cloud Sync uses incremental processing, which means it does not re-import your full dataset at every run. Instead, it fetches only the rows that changed since the last successful sync.
3.1 The last_updated_at cursor
Batch stores the last successful cursor value internally.
At each run, Batch fetches only rows where:
last_updated_atis greater than the last stored cursor
This makes sync runs faster, more scalable, and more cost-efficient.
3.2 Inserts, updates, and deletes
Incremental syncs naturally capture:
✅ inserts
✅ updates
They do not automatically capture:
❌ deletes
If you need deletions reflected in Batch, rely on a different pipeline or implement soft deletes by setting all attributes to null in the ClickHouse view when a profile is deleted.
3.3 Best practices for reliable incremental syncs
To avoid missing changes:
Ensure
last_updated_atupdates every time a synced column changesAvoid timestamps that only reflect partial updates
Use a View if you need computed fields or type conversions
Use
ReplacingMergeTreeand order bylast_updated_atfor large tables
4) Test and enable your Sync
Before enabling the schedule:
Run a test sync
Verify:
Profiles are created or updated correctly
batch__,date__, andurl__fields are interpreted correctlyArray attributes are correctly stringified (e.g.
["art","design"])Null values behave as expected (null → attribute removal)
Once enabled, Batch automatically handles batching and retries.
Last updated

