SQL Server to Apache Iceberg: CDC with OLake Go
SQL Server to Apache Iceberg usually means Debezium through Kafka into an Iceberg sink connector, or a Spark job that re-reads whole tables over Java Database Connectivity (JDBC). This guide takes a shorter route. Change data capture (CDC), built into SQL Server, fills change tables from the transaction log, and OLake Go reads them and commits the rows as Iceberg tables into an Apache Polaris catalog.
Polaris is an open source Iceberg REST (Representational State Transfer) catalog you run yourself, with the files in your own bucket. Apache Spark, DuckDB and Trino all read the tables through that one endpoint. Nothing else is in the path: no Kafka, no Debezium, no cluster that runs all day.
Key takeaways
- OLake Go replicates SQL Server into Iceberg tables in Polaris: a full historical snapshot first, then CDC from the change tables SQL Server already maintains, with no Kafka or Debezium in between.
- Updates land as Iceberg row-level deletes in a format every target engine reads, so each table holds one current row per primary key after every sync.
- Spark, DuckDB and Trino read the same tables through the same catalog, with no export and no second copy. In the run on this page all three returned identical rows.
The short answer. To replicate SQL Server to Apache Iceberg with change data capture (CDC), enable CDC on the database and tables. Run OLake Go with a read-only login as the source and an Iceberg REST catalog such as Apache Polaris as the destination.
The first sync copies each table in full; every later sync replays inserts, updates and deletes from the change tables. Spark, DuckDB and Trino query the result.
How SQL Server CDC reaches Apache Iceberg here
Two things happen in order, and OLake Go does both on its own. The first sync records the current log sequence number (LSN), reads each table in parallel chunks and writes Parquet data files. Every later sync reads the change tables from the saved LSN and replays what changed since, so nothing written during the snapshot is lost.
Each sync ends with one commit to Polaris. OLake Go asks Polaris for short-lived storage credentials, uploads the data and delete files, then posts the new snapshot. Spark, DuckDB and Trino see it on their next query.
One thing to keep an eye on: the change tables are SQL Server's replay window, and the Agent is what fills them. The cleanup job drops change rows older than three days by default, so a job paused longer needs a fresh snapshot. A stopped Agent means no new change rows at all, with no error on the SQL Server side.
What you need
- SQL Server 2016 SP1 or later on Developer, Standard or Enterprise edition, with CDC available and the SQL Server Agent running. The tables on this page ran on SQL Server 2022 Developer in Docker. Hosted SQL Server on Amazon Relational Database Service (RDS), Azure SQL Managed Instance or Cloud SQL works the same way; step 1 names each setup procedure.
- An Apache Polaris server and a bucket, both reachable from OLake Go and from the engines. The run on this page used Polaris 1.8.0 and MinIO in Docker; on AWS, use an S3 bucket and an IAM role instead.
- At least one Iceberg reader. The run on this page used Apache Spark 3.5.6 with Iceberg 1.10.0, DuckDB 1.5.5 and Trino 484.
- OLake UI from the Docker Compose install with the OLake Go MSSQL source. The run on this page used v1.1.0.
- Docker, and about 40 minutes.
Step 1: Prepare SQL Server for CDC
Most readers point OLake Go at tables they already have. If you want to follow along with the exact data from this page, create these two tables first:
The two sample tables used on this page
CREATE TABLE dbo.customers (
id INT IDENTITY(1,1) PRIMARY KEY,
name NVARCHAR(100), email NVARCHAR(200), city NVARCHAR(100), tier NVARCHAR(20),
created_at DATETIME2 DEFAULT SYSUTCDATETIME(),
updated_at DATETIME2 DEFAULT SYSUTCDATETIME());
CREATE TABLE dbo.orders (
id INT IDENTITY(1,1) PRIMARY KEY,
customer_id INT REFERENCES dbo.customers(id),
product NVARCHAR(100), amount DECIMAL(10,2), status NVARCHAR(20),
created_at DATETIME2 DEFAULT SYSUTCDATETIME(),
updated_at DATETIME2 DEFAULT SYSUTCDATETIME());
-- Then insert whatever you like. This page started with 8 customers and 40 orders.
OLake Go reads SQL Server changes from the change tables that SQL Server's own change data capture (CDC) feature fills from the transaction log. Four things must be in place before the first sync.
| Setting | Value | Why it matters |
|---|---|---|
| CDC on the database | sys.sp_cdc_enable_db | Creates the cdc schema and the capture jobs for the database. |
| CDC on each table | sys.sp_cdc_enable_table per table | Creates the capture instance whose change table OLake Go reads. |
| SQL Server Agent | running | The capture job that copies log records into the change tables is an Agent job; without it nothing lands in cdc.*. On Amazon RDS and Azure SQL Managed Instance the agent is on by default. |
| A login for OLake Go | SELECT on the table schema, on the cdc schema and on msdb.dbo.cdc_jobs | The snapshot reads the tables; the change stream reads the change tables; the source test reads the capture job definition. Without the msdb grant the test fails with no SELECT on msdb.dbo.cdc_jobs. |
-- 1. CDC on the database (Developer, Standard 2016 SP1+ or Enterprise edition)
USE shop;
EXEC sys.sp_cdc_enable_db;
-- 2. CDC on every table you sync. @role_name = NULL skips the gating role.
EXEC sys.sp_cdc_enable_table @source_schema = N'dbo', @source_name = N'customers', @role_name = NULL;
EXEC sys.sp_cdc_enable_table @source_schema = N'dbo', @source_name = N'orders', @role_name = NULL;
-- 3. A login for OLake Go
USE master;
CREATE LOGIN olake WITH PASSWORD = '<password>';
USE shop;
CREATE USER olake FOR LOGIN olake;
GRANT SELECT ON SCHEMA :: dbo TO olake;
GRANT SELECT ON SCHEMA :: cdc TO olake;
GRANT VIEW DATABASE STATE TO olake;
-- 4. OLake Go checks the capture job definition in msdb before each sync
USE msdb;
CREATE USER olake FOR LOGIN olake;
GRANT SELECT ON dbo.cdc_jobs TO olake;
Check the result before moving on:
SELECT name, is_cdc_enabled FROM sys.databases WHERE name = 'shop'; -- 1
SELECT capture_instance FROM cdc.change_tables; -- dbo_customers, dbo_orders
EXEC msdb.dbo.sp_help_job @job_name = N'cdc.shop_capture'; -- the Agent job exists
Hosted SQL Server uses its own procedure to enable CDC on the database: EXEC msdb.dbo.rds_cdc_enable_db 'shop' on Amazon RDS, EXEC msdb.dbo.gcloudsql_cdc_enable_db 'shop' on Cloud SQL; the table step is the same. The full walk-through is the SQL Server connector page.
The cleanup job removes change rows older than three days (sys.sp_cdc_change_job @job_type = 'cleanup' changes it). A job paused longer than that loses its position and needs a fresh snapshot. Lengthen retention before a planned pause.
Step 2: Set up the Polaris catalog
An Iceberg table is a set of files plus a pointer to its current metadata, and the catalog holds that pointer. Apache Polaris is the catalog this page uses: OLake Go commits into it, and every reader asks it where the current snapshot is. The files sit in your own S3 or MinIO bucket; Polaris holds only the pointers and the permissions.
The Polaris catalog page lists which engines read it and how. Any Iceberg REST client with OAuth2 works, which covers Spark, DuckDB, Trino, ClickHouse, Flink and PyIceberg.
| Catalog | OLake Go writes | Apache Iceberg reads | Verified on this page |
|---|---|---|---|
| Apache Polaris | Yes | Yes: any Iceberg REST client with OAuth2 | Yes, end to end |
- Apache Polaris
Apache Polaris is an open source Iceberg REST catalog. It keeps the table metadata pointers, hands out short-lived storage credentials to engines, and applies its own role-based access control. OLake Go writes to it through the standard Iceberg REST API, and ClickHouse, Trino, DuckDB and Spark read from the same endpoint. The files live in an S3 bucket or an S3-compatible store that you own.
Three things need to exist before OLake Go can write: a Polaris server, a catalog inside it that points at your bucket, and a principal (a client id and secret) with the right to manage that catalog. The run on this page used Polaris 1.8.0 and MinIO in Docker; on AWS, swap the MinIO endpoint for a plain S3 bucket and an IAM role.
services:
minio:
image: minio/minio
hostname: lake-minio
command: server /data --console-address ":9001"
environment: { MINIO_ROOT_USER: minioadmin, MINIO_ROOT_PASSWORD: minioadmin }
ports: ["9000:9000", "9001:9001"]
polaris:
image: apache/polaris:latest
depends_on: [minio]
ports: ["8181:8181", "8182:8182"]
environment:
AWS_REGION: us-east-1
AWS_ACCESS_KEY_ID: minioadmin
AWS_SECRET_ACCESS_KEY: minioadmin
POLARIS_BOOTSTRAP_CREDENTIALS: POLARIS,root,<root-secret>
polaris.realm-context.realms: POLARIS
Polaris stores its own state in memory with this setup, so it starts empty every time; a production deployment points it at Postgres. Once it is up, create the bucket, the catalog and the principal through the management API. root is the bootstrap principal; the olake principal is the one OLake Go and the engines use.
P=http://localhost:8181
# 1. A bucket for the tables (MinIO; on AWS create it in the console or with aws s3 mb)
aws --endpoint-url http://localhost:9000 s3 mb s3://lakehouse
# 2. A root token
TOKEN=$(curl -s $P/api/catalog/v1/oauth/tokens -H 'Polaris-Realm: POLARIS' \
-d grant_type=client_credentials -d client_id=root -d client_secret=<root-secret> \
-d scope=PRINCIPAL_ROLE:ALL | jq -r .access_token)
H=(-H "Authorization: Bearer $TOKEN" -H 'Polaris-Realm: POLARIS' -H 'Content-Type: application/json')
# 3. The catalog: where the files go, and how Polaris and the engines reach the store
curl -s "${H[@]}" $P/api/management/v1/catalogs -d '{"catalog": {
"name": "olake", "type": "INTERNAL", "readOnly": false,
"properties": {"default-base-location": "s3://lakehouse/olake"},
"storageConfigInfo": {"storageType": "S3", "allowedLocations": ["s3://lakehouse/olake"],
"endpoint": "http://<minio-host>:9000/", "endpointInternal": "http://lake-minio:9000",
"pathStyleAccess": true, "region": "us-east-1"}}}'
# 4. A principal for OLake Go and the engines. The response holds clientId and clientSecret: keep them.
curl -s "${H[@]}" $P/api/management/v1/principals -d '{"principal": {"name": "olake"}}'
# 5. Roles and the grant that lets the principal create namespaces and tables in the catalog
curl -s "${H[@]}" $P/api/management/v1/principal-roles -d '{"principalRole": {"name": "olake_role"}}'
curl -s "${H[@]}" $P/api/management/v1/catalogs/olake/catalog-roles -d '{"catalogRole": {"name": "olake_catalog_role"}}'
curl -s -X PUT "${H[@]}" $P/api/management/v1/principals/olake/principal-roles -d '{"principalRole": {"name": "olake_role"}}'
curl -s -X PUT "${H[@]}" $P/api/management/v1/principal-roles/olake_role/catalog-roles/olake -d '{"catalogRole": {"name": "olake_catalog_role"}}'
curl -s -X PUT "${H[@]}" $P/api/management/v1/catalogs/olake/catalog-roles/olake_catalog_role/grants -d '{"type": "catalog", "privilege": "CATALOG_MANAGE_CONTENT"}'
What each block is for:
endpointis the store address Polaris hands to engines along with vended credentials;endpointInternalis the address Polaris itself uses. On AWS S3 leave both out. On MinIO both are required, or Polaris tries to reach AWS and fails. Keep the trailing slash onendpoint: ClickHouse 26.8 and 26.10 build the object path from it, and without the slash every read fails with a 404 (the fix is explained under troubleshooting on this page).- Polaris vends credentials through the store's STS endpoint. MinIO exposes one, so nothing else is needed. For a store without STS, add
"stsUnavailable": trueand give Polaris static keys to hand out. CATALOG_MANAGE_CONTENTlets the principal create namespaces and tables and read and write their data. Scope it to a namespace instead when several teams share the catalog.- The principal's secret is shown once, in the response to step 4. It is what goes into OLake Go as
<client_id>:<client_secret>.
Polaris is a Java service, and Java's URI parser rejects hostnames that contain an underscore. A MinIO container named lab_minio makes every table creation fail with host must not be null or Expected scheme-specific part at index 5: http:. Use a hyphen in the hostname (lake-minio), as above.
You can check the principal outside OLake Go by exchanging its credentials for a token, the same call OLake Go makes on every sync:
curl -s http://localhost:8181/api/catalog/v1/oauth/tokens -H 'Polaris-Realm: POLARIS' \
-d grant_type=client_credentials -d client_id=<client_id> -d client_secret=<client_secret> \
-d scope=PRINCIPAL_ROLE:ALL
A good principal returns a JSON object with an access_token. Running Polaris on Kubernetes, with Postgres behind it, or with an external identity provider is covered on the Polaris catalog page.
Step 3: Connect SQL Server to OLake Go
- OLake UI
- OLake CLI
- In the OLake UI, open Sources and click Create Source. Pick MSSQL as the connector, give the source a name and keep the OLake Go version on the latest release.
- Under Change data capture (CDC), leave Enable CDC on. Turn on Manage Capture Instance if you want OLake Go to create a new capture instance by itself after a schema change (it then needs
db_owner); leave it off to manage capture instances by hand. - Under Connection details, fill in the host, port, database name, username and password. Keep SSL off for a local test; on hosted SQL Server use the provider's certificate.
- Click Set up source. OLake Go tests the connection, then checks that CDC is on for the database and that the tables have capture instances, and shows the current and recommended value for anything that fails.
Here is the source form from the run on this page. SQL Server ran in another container, so the host is host.docker.internal; the login is the one from step 1, with VIEW DATABASE STATE and SELECT on dbo, cdc and msdb.dbo.cdc_jobs.
Set up source runs the connection test and the CDC checks before anything is saved: CDC on the database, a capture instance per table, a readable capture job. When one fails, the dialog names the setting and what to run.
The full field reference, including SSL modes and SSH tunnels, is on the SQL Server connector page.
Create source.json in your config folder. The update_method block is what turns CDC on:
{
"host": "mssql-server-host",
"port": 1433,
"database": "MSSQL DBName",
"username": "MSSQL Username",
"password": "MSSQL Password",
"max_threads": 3,
"retry_count": 3,
"ssl": {
"mode": "disable"
},
"update_method": {
"type": "CDC"
}
}
Then confirm OLake Go can reach the database:
docker run --pull=always \
-v "$PWD/config:/mnt/config" \
olakego/source-mssql:latest \
check --config /mnt/config/source.json
A working setup returns "status": "SUCCEEDED" together with the CDC prerequisite checks. Every field is described on the SQL Server connector page.
Step 4: Configure the Iceberg destination
- Apache Polaris
- OLake UI
- OLake CLI
- Open Destinations and click Create Destination.
- Pick Apache Iceberg as the connector and Polaris as the catalog type.
- Choose OAuth2 as the authentication type. REST Catalog URI is the Polaris catalog endpoint (
http://<polaris-host>:8181/api/catalog), Polaris Catalog Name the catalog from the setup (olake), REST Auth URI the token endpoint, and REST Credential the principal's<client_id>:<client_secret>. - Fill in the store: AWS Region, and for MinIO the S3 Endpoint with the AWS Access Key and AWS Secret Key. On AWS S3 leave the endpoint empty.
- Click Create. OLake Go exchanges the credentials for a token, creates a namespace and a test table through Polaris, writes to the bucket and drops the test table again.
Here is the destination form from the run on this page. Polaris and MinIO ran in other containers, so both addresses use host.docker.internal; the credential is the olake principal from step 2.
Polaris Configuration Parameters
| Parameter | Sample Value | Description |
|---|---|---|
REST Catalog URIrequired | http://<REST_ENDPOINT>:8181/api/catalog | Endpoint URL for the Polaris REST catalog service. |
Authentication Typerequired | oauth2 | Authentication method OLake Go uses for Polaris REST catalog requests. Set to match your catalog's authentication configuration. |
Polaris Catalog Namerequired | <POLARIS_CATALOG_NAME> | Name of the Polaris catalog to use, OLake Go passes this to the Polaris REST catalog as the warehouse identifier, so catalog operations are routed to that catalog and its pre-configured S3 storage and IAM settings. |
REST Auth URIrequired | http://<REST_ENDPOINT>:8181/api/catalog/v1/oauth/tokens | URL of the REST catalog’s OAuth2 token endpoint. OLake Go uses this with REST Credential to request an access token during OAuth2 client-credentials authentication. |
REST Credentialrequired | <olake_user_client_id>:<olake_user_client_secret> | Specifies the client ID and secret for OAuth2, formatted as client_id:client_secret. Used with REST Auth URI when OLake Go requests an access token from the catalog’s auth service. Not needed when using REST Token or other auth types. |
AWS Regionrequired | ap-south-1 | AWS Region where your S3 bucket exists. Required so OLake Go calls the correct regional S3 endpoint. |
| REST Scope | PRINCIPAL_ROLE:ALL | Required for OAuth2 client-credentials auth. Scopes are space-separated. Used with REST Auth URI and REST Credential for OAuth2 client-credentials auth. Values are catalog-specific. Not needed when using REST Token or other auth types. |
| S3 Endpoint | http://<S3_ENDPOINT>:9000 | S3 API endpoint for writing Iceberg data files. Leave empty for AWS S3 but required for S3-compatible storage like MinIO. |
| AWS Access Key | XXX | AWS access key ID for authentication. Optional if using IAM roles or instance profiles. If using IAM: Docker Compose: add the required IAM environment variables under x-envs in your compose file. See Service Environment Variables for setup details.Kubernetes: set up pod IAM in Cloud Integration. |
| AWS Secret Key | XXX | AWS secret access key for authentication. Optional if using IAM roles or instance profiles. If using IAM: Docker Compose: add the required IAM environment variables under x-envs in your compose file. See Service Environment Variables for setup details.Kubernetes: set up pod IAM in Cloud Integration. |
| Enable Arrow Writes | false | Writes data and delete files using Apache Arrow based writer and registers them in Iceberg. |
| Catalog Name | olake_iceberg | Name of the Iceberg catalog OLake Go registers tables under. Defaults to olake_iceberg if left empty. |
Create destination.json next to source.json:
{
"type": "ICEBERG",
"writer": {
"catalog_type": "polaris",
"catalog_name": "polaris",
"rest_catalog_url": "http://<polaris-host>:8181/api/catalog",
"iceberg_s3_path": "olake",
"rest_auth_type": "oauth2",
"oauth2_uri": "http://<polaris-host>:8181/api/catalog/v1/oauth/tokens",
"credential": "<client_id>:<client_secret>",
"scope": "PRINCIPAL_ROLE:ALL",
"aws_region": "us-east-1",
"s3_endpoint": "http://<minio-host>:9000",
"aws_access_key": "<minio access key>",
"aws_secret_key": "<minio secret key>",
"arrow_writes": false
}
}
Polaris Configuration Parameters
| Parameter | Sample Value | Description |
|---|---|---|
catalog_typerequired | polaris | Defines the catalog type used by the writer. |
rest_catalog_urlrequired | http://<REST_ENDPOINT>:8181/api/catalog | Endpoint URL for the Polaris REST catalog service. |
iceberg_s3_pathrequired | <POLARIS_CATALOG_NAME> | Name of the Polaris catalog to use, OLake Go passes this to the Polaris REST catalog as the warehouse identifier, so catalog operations are routed to that catalog and its pre-configured S3 storage and IAM settings. |
rest_auth_typerequired | oauth2 | Authentication method OLake Go uses for Polaris REST catalog requests. Set to match your catalog's authentication configuration. |
oauth2_urirequired | http://<REST_ENDPOINT>:8181/api/catalog/v1/oauth/tokens | URL of the REST catalog’s OAuth2 token endpoint. OLake Go uses this with REST Credential to request an access token during OAuth2 client-credentials authentication. |
credentialrequired | <olake_user_client_id>:<olake_user_client_secret> | Specifies the client ID and secret for OAuth2, formatted as client_id:client_secret. Used with REST Auth URI when OLake Go requests an access token from the catalog’s auth service. |
aws_regionrequired | ap-south-1 | AWS Region where your S3 bucket exists. Required so OLake Go calls the correct regional S3 endpoint. |
| scope | PRINCIPAL_ROLE:ALL | Required for OAuth2 client-credentials auth. Scopes are space-separated. Used with REST Auth URI and REST Credential for OAuth2 client-credentials auth. Values are catalog-specific. |
| s3_endpoint | http://<S3_ENDPOINT>:9000 | S3 API endpoint for writing Iceberg data files. Leave empty for AWS S3 but required for S3-compatible storage like MinIO. |
| aws_access_key | XXX | AWS access key ID for authentication. Optional if using IAM roles or instance profiles. If using IAM: Docker Compose: add the required IAM environment variables under x-envs in your compose file. See Service Environment Variables for setup details.Kubernetes: set up pod IAM in Cloud Integration. |
| aws_secret_key | XXX | AWS secret access key for authentication. Optional if using IAM roles or instance profiles. If using IAM: Docker Compose: add the required IAM environment variables under x-envs in your compose file. See Service Environment Variables for setup details.Kubernetes: set up pod IAM in Cloud Integration. |
| arrow_writes | false | Writes data and delete files using Apache Arrow based writer and registers them in Iceberg. |
| catalog_name | olake_iceberg | Name of the Iceberg catalog OLake Go registers tables under. Defaults to olake_iceberg if left empty. |
Step 5: Create the job and run the first sync
- OLake UI
- OLake CLI
- Open Jobs and click Create Job. Give it a name and a schedule. Every Day at a fixed hour, or a cron expression, both work; the schedule is how often the change stream is drained, not how often a full copy runs.
- Select the source and the destination you created.
- Under Advanced Settings, set Target Query Engines to Apache Spark, DuckDB and Trino. OLake Go then resolves an Iceberg delete format every one of those engines can read, so you never pick one by hand.
- Click Next. OLake Go discovers the tables and opens the Streams page.
- Tick the tables to replicate. For each one, set the sync mode to Full Refresh + CDC and the ingestion mode to Upsert. Leave the Upsert Type as OLake Go resolved it (Positional Deletes in the run on this page).
- Click Create Job, then open the job's menu and choose Sync Now for the first run.
The target query engines on this job are Apache Spark, DuckDB and Trino. OLake Go offers only the delete formats all three read, which here is all three Iceberg formats.
The run used Positional Deletes on Iceberg v2, readable by every current release of each engine. Leave systranschemas unticked; troubleshooting entry 2 explains why.

Discover the tables, choose the streams, then sync:
docker run --pull=always \
-v "$PWD/config:/mnt/config" \
olakego/source-mssql:latest \
discover --config /mnt/config/source.json
discover writes two files: available_streams.json (every table it found, do not edit) and selected_streams.json (the tables you want and their settings). In selected_streams.json, set sync_mode to {props.cliSyncMode ?? 'cdc'} for each table and pick the delete format your readers can open:
{
"selected_streams": {
"dbo": [
{
"stream_name": "customers",
"sync_mode": "cdc",
"normalization": true,
"append_mode": false,
"update_type": "pos"
}
]
}
}
update_type accepts eq (equality deletes, the default), pos (positional deletes) and dv (deletion vectors). Positional deletes and deletion vectors keep a small index between runs, so give the container a persistent directory for it through OLAKE_INDEX_DB_DIR. The first sync runs without a state file; OLake Go writes one at the end of the run:
docker run --pull=always \
-v "$PWD/config:/mnt/config" \
-e OLAKE_INDEX_DB_DIR=/mnt/config/index-db \
olakego/source-mssql:latest \
sync \
--config /mnt/config/source.json \
--selected-streams /mnt/config/selected_streams.json \
--available-streams /mnt/config/available_streams.json \
--destination /mnt/config/destination.json
Every later run adds --state /mnt/config/state.json to the same command, which is how OLake Go knows to replay only the changes since the last run. The full selected_streams.json reference is on the Docker CLI page; the index directory is described under index DB setup.
On this page the first run copied 8 customers and 40 orders (48 records, 3.05 KB) and finished in 44 seconds, container start included. OLake Go names the Iceberg namespace after the job, the source database and the schema, so sql_server_to_iceberg on database shop produced sql_server_to_iceberg_shop_dbo. The Iceberg DB field at the top of the Streams page changes it before the first sync.
Step 6: Query the Iceberg tables
DuckDB is the quickest reader to try: one process, no server. It attaches the whole Polaris catalog and reads the tables in place.
- Apache Polaris
There is no registration step. DuckDB attaches the whole Polaris catalog with ATTACH, lists every table OLake Go committed, and reads the files straight from the bucket. DuckDB fetches the OAuth2 token itself from the principal's client id and secret. On a laptop, where the store address Polaris hands out may not resolve, add an S3 secret for the store and turn credential vending off:
INSTALL iceberg; LOAD iceberg;
INSTALL httpfs; LOAD httpfs;
CREATE SECRET polaris_secret (
TYPE iceberg,
CLIENT_ID '<client_id>', CLIENT_SECRET '<client_secret>',
OAUTH2_SERVER_URI 'http://<polaris-host>:8181/api/catalog/v1/oauth/tokens',
OAUTH2_SCOPE 'PRINCIPAL_ROLE:ALL'
);
-- MinIO, or any store whose address differs from the one Polaris vends
CREATE SECRET store_secret (
TYPE s3, KEY_ID '<access key>', SECRET '<secret key>',
ENDPOINT '<minio-host>:9000', URL_STYLE 'path', USE_SSL false, REGION 'us-east-1'
);
ATTACH 'olake' AS polaris (
TYPE iceberg,
ENDPOINT 'http://<polaris-host>:8181/api/catalog',
SECRET polaris_secret,
ACCESS_DELEGATION_MODE 'none'
);
SHOW ALL TABLES;
-- What OLake Go created (schema = <job name>_<source database>)
SELECT id, name, city, tier FROM polaris.sql_server_to_iceberg_shop_dbo.customers ORDER BY id;
With Polaris on AWS S3, drop the S3 secret and the ACCESS_DELEGATION_MODE line: DuckDB then reads with the credentials Polaris vends. The attached catalog is read-only from DuckDB; OLake Go is the writer.
OLake Go adds four columns to every table: _olake_id (a hash of the primary key), _op_type, _olake_timestamp and _cdc_timestamp. _op_type is r for a row from the first snapshot, c for an insert, u for an update and d for a delete. Filter them out of dashboards, or use them to see when a row last changed.
Step 7: Change rows in SQL Server and sync again
To see the change path work, the run on this page made 12 changes in SQL Server after the first sync:
INSERT INTO dbo.customers (name, email, city, tier) VALUES
(N'Maya Patel', 'maya@example.com', N'Pune', 'silver'),
(N'Lucas Silva', 'lucas@example.com', N'São Paulo', 'bronze');
INSERT INTO dbo.orders (customer_id, product, amount, status) VALUES
(9, 'Laptop', 1299.00, 'placed'), (9, 'Mouse', 25.50, 'placed'),
(10, 'Monitor', 349.99, 'placed'), (3, 'Keyboard', 89.00, 'placed'), (7, 'Webcam', 79.90, 'placed');
UPDATE dbo.customers SET tier = 'gold', updated_at = SYSUTCDATETIME() WHERE name = N'Liam Carter';
UPDATE dbo.customers SET city = N'Abu Dhabi', updated_at = SYSUTCDATETIME() WHERE name = N'Zara Ali';
UPDATE dbo.orders SET status = 'delivered', updated_at = SYSUTCDATETIME() WHERE id IN (1, 4, 7);
The second sync read 12 records (855 bytes) from the change tables and finished in 24 seconds end to end. For orders that meant one new data file with 8 rows: 5 inserts plus the new versions of 3 updated rows.
One small positional delete file retires the 3 old versions by file and row position. OLake Go's commit report in the sync log shows it directly: addedDataFiles=1, addedRecords=8, addedPositionalDeleteFiles=1, addedPositionalDeletes=3, and no equality delete files.

customers has the same shape with 4 rows and 2 deletes. Every reader shows the result on its next query: Liam Carter is gold, Zara Ali moved to Abu Dhabi, and the two new customers are there. The _op_type column shows how each row arrived: r for the snapshot, c for the inserts and u for the updates.
Schema changes. A column added in SQL Server is not part of the existing capture instance. Create a new capture instance for the table, or let OLake Go do it with Manage Capture Instance on the source.
OLake Go then adds the column to the Iceberg table on the next sync; narrowing or incompatible type changes fail the sync rather than corrupt the table. Full rules are on the schema evolution page.
Query the same tables from Trino and Spark
This is the point of writing Iceberg. Nothing is exported, copied or refreshed: each engine reads the files OLake Go wrote, through the same Polaris endpoint.
- Trino
- Apache Spark
Trino reaches Polaris through its Iceberg connector in REST mode. One catalog properties file does it; Trino fetches the OAuth2 token with the principal's credentials and reads the files with the credentials Polaris vends.
connector.name=iceberg
iceberg.catalog.type=rest
iceberg.rest-catalog.uri=http://<polaris-host>:8181/api/catalog
iceberg.rest-catalog.warehouse=olake
iceberg.rest-catalog.security=OAUTH2
iceberg.rest-catalog.oauth2.credential=<client_id>:<client_secret>
iceberg.rest-catalog.oauth2.scope=PRINCIPAL_ROLE:ALL
iceberg.rest-catalog.oauth2.server-uri=http://<polaris-host>:8181/api/catalog/v1/oauth/tokens
iceberg.rest-catalog.vended-credentials-enabled=true
fs.native-s3.enabled=true
s3.region=us-east-1
# MinIO or another S3-compatible store only:
s3.endpoint=http://<minio-host>:9000
s3.path-style-access=true
SHOW SCHEMAS FROM polaris;
SELECT id, name, city, tier FROM polaris.sql_server_to_iceberg_shop_dbo.customers ORDER BY id;
Trino 484 read the tables on this page with no further settings. Equality and positional deletes are read on every current release; deletion vectors from Trino 480, where the docs still mark them experimental.
Open source Spark reaches Polaris through the Iceberg REST catalog. The warehouse is the Polaris catalog name, and credential is the principal's client ID and secret, which Spark trades for an OAuth2 token.
spark-sql \
--packages org.apache.iceberg:iceberg-spark-runtime-3.5_2.12:1.10.0,org.apache.iceberg:iceberg-aws-bundle:1.10.0 \
--conf spark.sql.extensions=org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions \
--conf spark.sql.catalog.polaris=org.apache.iceberg.spark.SparkCatalog \
--conf spark.sql.catalog.polaris.type=rest \
--conf spark.sql.catalog.polaris.uri=http://<polaris-host>:8181/api/catalog \
--conf spark.sql.catalog.polaris.warehouse=olake \
--conf spark.sql.catalog.polaris.credential=<client_id>:<client_secret> \
--conf spark.sql.catalog.polaris.scope=PRINCIPAL_ROLE:ALL \
--conf spark.sql.catalog.polaris.header.X-Iceberg-Access-Delegation=vended-credentials \
--conf spark.sql.catalog.polaris.client.region=us-east-1
SELECT id, name, city, tier FROM polaris.sql_server_to_iceberg_shop_dbo.customers ORDER BY id;
On MinIO or another S3-compatible store, also set spark.sql.catalog.polaris.s3.endpoint and spark.sql.catalog.polaris.s3.path-style-access=true. The run on this page used Spark 3.5.6 with Iceberg 1.10.0 against MinIO, with the MinIO keys passed as s3.access-key-id and s3.secret-access-key instead of vended credentials.
Spark 3.5.6 with Iceberg 1.10.0 returned the same 10 customers and 45 orders in the run on this page.
An orders roll-up matched SQL Server to the cent in all three engines: 45 orders for 25579.19 in total. By status it gave 16 delivered orders for 8659.68, 18 placed for 10522.26, 11 shipped for 6397.25.
Data types: SQL Server to Apache Iceberg
OLake Go maps SQL Server types to Iceberg types itself; each engine then shows the Iceberg type in its own terms. Integers and strings pass through. Numbers with a scale and the date types are the groups to know about.
| SQL Server | Iceberg (written by OLake Go) | Notes |
|---|---|---|
tinyint, smallint, int | int | The IDENTITY keys on this page arrived as int. |
bigint | long | |
decimal, numeric, money, smallmoney, float | double | OLake Go stores decimals as doubles. The orders.amount sums on this page matched SQL Server to the cent in every engine; round at query time when you need exact decimal arithmetic. |
real | float | |
bit | boolean | |
date, smalldatetime, datetime, datetime2, datetimeoffset | timestamptz (UTC) | datetime2 has no zone in SQL Server; it is read as UTC. datetimeoffset is converted to UTC. |
char, varchar, nchar, nvarchar, text, ntext, uniqueidentifier, xml, json, sql_variant | string | A uniqueidentifier arrives as its 36-character text form. |
binary, varbinary, image, rowversion, geometry, geography, hierarchyid | string | Binary and spatial values arrive as text; keep large binaries out of the sync. |
SQL Server types in the table come from the SQL Server connector reference. OLake Go also adds _cdc_start_lsn and _cdc_seqval on SQL Server tables, the log position each change came from.
Cost and maintenance
- Storage is your bucket: you pay S3 or MinIO rates for the Parquet and delete files, and nothing to Polaris for holding pointers.
- Compute. OLake Go runs wherever you run Docker, for the length of a sync; the change sync on this page took 24 seconds. Readers spend compute only when they query.
- Maintenance. Nothing compacts the tables for you. A CDC table that gets a new small file and delete file per sync wants compaction; OLake Fusion does this for the catalogs OLake Go writes to, and Spark's
rewrite_data_filesworks through the same Polaris endpoint. - Change table disk. Every captured change is a row in the
cdcschema until the cleanup job removes it. Shorten retention once the job runs reliably every hour. - Credential rotation. Polaris principals do not expire by default. Rotate the
olakeprincipal's secret on your own schedule; a rotated secret fails the next sync at the token exchange, before any data moves.
Troubleshooting
1. The source test fails on the capture job
required CDC prerequisites not met: cdc_capture_job ... no SELECT on msdb.dbo.cdc_jobs
OLake Go reads the capture job definition from msdb to pick a safe start position. Create a user for the login in msdb and grant SELECT ON dbo.cdc_jobs, as in step 1.
2. The first sync fails on a table you did not create
failed to run change stream: failed in pre cdc run for driver[mssql]: CDC is not enabled for stream dbo.systranschemas
Enabling CDC or replication on a database adds dbo.systranschemas to it, and discovery lists it next to your tables. It has no capture instance, so a job that selects every stream fails before the snapshot. Untick it on the Streams page, along with any other table without a capture instance.
3. Discovery fails right after SQL Server starts
FATAL failed to connect to MSSQL: failed to ping database: EOF
The server accepted the connection before recovery finished. A fresh container needs until the log shows Recovery is complete; retry discovery then. On a long-running server, check that the port is the SQL Server listener and not a proxy that closes the connection.
4. A recreated job writes nothing on its first sync
Table[<namespace>.customers]: stream index is already up to date at snapshot[...]
chunk min[1] and max[<nil>] already committed, skipping
A job deleted and created again with the same name writes into the same Iceberg namespace. OLake Go sees the chunks of the earlier snapshot as already committed and skips them, so the snapshot writes nothing. Drop the old tables from Polaris first, or give the new job a different Iceberg DB name.
5. The destination test fails at the token exchange
OLake Go's destination test exchanges the principal's credentials at /api/catalog/v1/oauth/tokens before anything else. Three causes cover nearly every failure: a wrong client id or secret, a principal with no role that carries CATALOG_MANAGE_CONTENT on the catalog, or a wrong Polaris Catalog Name. Run the token check from the catalog setup; it returns the same error Polaris gives OLake Go.
How this compares with other ways to move SQL Server data to Apache Iceberg
| Method | Freshness | Updates and deletes | Where the data lands | What you run |
|---|---|---|---|---|
| Debezium SQL Server connector, Kafka and the Iceberg Kafka Connect sink | Seconds to minutes | Yes, with the sink's upsert settings | Iceberg tables in your catalog | Kafka, Kafka Connect, the Debezium connector and the sink connector |
| Spark job over JDBC | Hours to daily | Only with your own MERGE logic | Iceberg tables in your catalog | A Spark cluster, a scheduler and the merge code |
Export (bcp or SSIS to files), then load with Spark | Hours to daily | No; full reloads only | Iceberg tables in your catalog | A script, a scheduler, a staging bucket and a Spark job |
| Managed ELT (Fivetran, Estuary, Airbyte Cloud) | Minutes, by plan | Varies by tool | Their managed destination, often a warehouse table | Nothing; priced per row, per GB or per connector |
| OLake Go to Iceberg on Polaris (this guide) | CDC on a schedule down to one minute | Yes, as Iceberg row-level deletes | Apache Iceberg tables in your bucket and your catalog | One Docker Compose stack, open source; your bucket plus your own compute |
Debezium through Kafka is the simpler choice when you already run Kafka and need seconds of latency. OLake Go is one container per sync with no broker in between, which matters when Kafka would exist only to carry this one pipeline.
When not to use this
- You need seconds of latency. OLake Go syncs on a schedule, one minute at the shortest. Use a streaming pipeline for a continuous feed.
- The edition has no CDC. SQL Server Express and Web cannot enable change data capture. Full Refresh and Full Refresh + Incremental on an
updated_atcolumn still work there. - Tables have no primary key. Inserts replicate; updates and deletes cannot be matched to a row and are not applied. Add a primary key or a unique index first.
FAQs
How do I replicate SQL Server to Apache Iceberg without Kafka or Debezium?
Run OLake Go (open source, Apache 2.0) against a SQL Server database with change data capture enabled, and point it at an Iceberg REST catalog such as Apache Polaris. The first sync copies the tables in full, every later sync reads only the rows SQL Server's capture job wrote to the change tables, and the result lands as Iceberg tables in your own bucket. No Kafka, no Debezium and no Spark job sit in the path.
Which Iceberg delete format does OLake Go write for SQL Server updates?
The one every target query engine on the job reads. With Apache Spark, DuckDB and Trino as targets, OLake Go offered equality deletes, positional deletes and deletion vectors; the run on this page used positional deletes on Iceberg v2, which all three read on every current release. Trino reads deletion vectors only from release 480, where its docs still mark them experimental.
Does OLake Go copy the existing SQL Server data before it reads the change tables?
Yes, automatically. A job in Full Refresh + CDC mode records the current log sequence number, copies every selected table in parallel chunks, then reads the change tables from that position. Nothing written during the copy is lost, and there is no separate backfill job.
What does SQL Server need for OLake Go CDC?
Change data capture on the database and on each table, which needs Developer, Standard (2016 SP1 or later) or Enterprise edition, plus a running SQL Server Agent to fill the change tables. The OLake Go login needs SELECT on the table schema, on the cdc schema and on msdb.dbo.cdc_jobs. Amazon RDS and Azure SQL Managed Instance expose the same feature through their own stored procedures.
Can I use a catalog other than Polaris?
Yes. OLake Go also writes to AWS Glue, Lakekeeper, Amazon S3 Tables, Nessie, Hive Metastore, a JDBC catalog and any Iceberg REST catalog. This page uses Polaris because it is open source, runs next to your bucket and vends storage credentials to every reader; the job and the queries stay the same with another catalog.
How long does SQL Server keep change rows for OLake Go?
Three days by default. The CDC cleanup job removes change rows older than its retention setting, and a job paused for longer than that cannot resume and needs a fresh snapshot. Raise retention with sys.sp_cdc_change_job before a planned pause.
Related guides
Deeper reading on this site: