Skip to content

Targets

Databricks

Load into Databricks (beta), a SQL warehouse with Unity Catalog: Parquet in S3 copied where it lies through an external location, everything else staged in a volume, then COPY INTO, one statement per write.

This target is in beta: it is tested, but gets less everyday use than the other connectors, so expect rough edges, and please report them in GitHub issues.

A Databricks target loads into a Unity Catalog SQL warehouse with COPY INTO: from Parquet files in S3 where they lie, through an external location, and otherwise from Parquet SQLLoad writes to a Unity Catalog volume. There is no INSERT fallback.

SQLLoad signs in with a service principal’s OAuth machine-to-machine credentials:

[connections.lakehouse]
kind = "databricks"
host = "${ENV:DATABRICKS_HOST}"
client_id = "${ENV:DATABRICKS_CLIENT_ID}"
client_secret = "${ENV:DATABRICKS_CLIENT_SECRET}"
warehouse_id = "${ENV:DATABRICKS_WAREHOUSE_ID}"
catalog = "main"
volume = "main.raw.sqlload_stage" # catalog.schema.volume
[targets.lakehouse]
connection = "lakehouse"
loader_schema = "raw"
Key Meaning
host The workspace URL, such as https://dbc-1234.cloud.databricks.com.
client_id, client_secret The service principal’s OAuth credentials.
warehouse_id The SQL warehouse statements run on.
catalog The Unity Catalog catalog tables load into.
volume An existing volume load files are staged in, as catalog.schema.volume. Anything else fails plan. Only a connection a target loads into needs one; a source doesn’t.

The service principal needs USE CATALOG, USE SCHEMA and CREATE TABLE where it loads (CREATE SCHEMA too when the schema doesn’t exist yet), ownership of or MANAGE on the tables it replaces or rewrites, and READ VOLUME and WRITE VOLUME on the volume. sqlload debug checks that the volume lists.

Each batch is written as Parquet to <volume>/sqlload/<load id>/<batch>/, loaded with one COPY INTO, and its folder removed, whether the COPY commits or fails. The next load removes folders a failed run left once they are a day old.

Parquet files of a files source in S3 load straight from the bucket, with no row passing through SQLLoad, when a Unity Catalog external location covers their folder and the service principal has READ FILES on it. plan checks it can list the folder:

CREATE EXTERNAL LOCATION lake URL 's3://example-bucket/events/'
WITH (STORAGE CREDENTIAL lake_reader);
GRANT READ FILES ON EXTERNAL LOCATION lake
TO `<service principal application id>`;
route Databricks COPYs directly from s3://example-bucket/events/ (nothing through the loader)

Parquet in S3 that no external location covers fails plan, naming the folder and the fix; it never goes through SQLLoad instead.

Each batch is one COPY INTO, or more when it holds over 1,000 files or files that hold one column as different types, such as 32-bit and 64-bit integers. Every strategy but append copies into a staging or build table, so a batch publishes whole. An append copies straight into the table; if a later COPY fails, or the rows inserted differ from the files’ footers, it deletes this load’s rows from the batch’s files before the load fails.

Files go through SQLLoad, staged in the volume, when Databricks can’t load them exactly itself, and plan says why: CSV and JSON files; a table that masks columns, has checks or flattens objects; a column held in a way a cast wouldn’t keep exactly (nanoseconds, a type other than the one it loads as); a time, a UUID or a list; an S3-compatible endpoint (on the connection or in AWS_ENDPOINT or AWS_ENDPOINT_URL); and files in a local folder or over SFTP. copy_to_internal_stage is for Snowflake and is refused here.

A Snowflake source with a stage url that an external location covers loads the same way, through a staging or build table even for append; see Databricks and ClickHouse read the files themselves.

Each write is one statement, in its own transaction; the run record commits after it.

Strategy Statements
append COPY INTO the table. A logged table goes through a staging table, then one INSERT.
merge COPY INTO a staging table, then one MERGE on the key.
delete_insert COPY INTO a staging table, then one MERGE that inserts the batch and deletes the rows it replaces.
replace COPY INTO a build table, then CREATE OR REPLACE TABLE ... AS SELECT from it.
postgres_cdc One MERGE per table (a truncate in the batch is its WHEN NOT MATCHED BY SOURCE clause), or one INSERT for a changelog. See Postgres CDC.
deletes, deletes_from A key scan is one UPDATE (soft) or DELETE (hard) of the rows whose key the source no longer lists. Tombstones are one MERGE (soft) or DELETE (hard). See Rows deleted at the source.

replace keeps the table’s history and grants, and copies the rows once more, as Delta has no metadata-only swap.

Type Databricks
bool BOOLEAN
smallint SMALLINT
int BIGINT
decimal(p,s) DECIMAL(p,s)
float DOUBLE
text STRING
varchar(n) STRING ¹
date DATE
time STRING ¹
timestamp_tz TIMESTAMP ¹
timestamp_ntz TIMESTAMP_NTZ
json VARIANT
uuid STRING ¹
binary BINARY

¹ Held with a loss, which plan notes: the length limit isn’t enforced, times and UUIDs are stored as text, and TIMESTAMP keeps the instant but not the offset.

Widening a type uses Delta’s type widening where it applies, and rewrites the table where it doesn’t, such as an integer becoming a float.

Every pathway plan accepts was run against a real Databricks SQL warehouse (2X-Small): a first load, a re-run, a re-run with an exclusive cursor, source and schema changes, then the contract commands, with row counts and values checked against each source after every round.

Source append replace delete_insert merge
Postgres live live live live
Local files live live live refused at plan
Files in S3 live live live refused at plan
Python rows live live live live
Python Arrow data live live live live
sl.http (paginated JSON) live live live live
ODBC (SQL Server, MySQL) not run live not run live
BigQuery not run live not run live
Files on an SFTP server (gzip CSV, Parquet) live not run not run refused at plan

Parquet in S3 copied through an external location was run live under append, replace and delete_insert, including files mixing 32-bit and 64-bit integers, and compared row for row with the same files loaded through SQLLoad. The rounds also covered NULL cursors under delete_insert, an added column, widening a decimal in place, and a load that failed midway, which committed no rows and left the volume’s sqlload/ folder empty.