Skip to content

Sources

Databricks

Load Databricks (beta) tables, views and query results as Arrow through the Statement Execution API: connections, choosing tables, query tables, cursors, types, cost and permissions.

This source 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 source loads tables, views and query results from a Databricks SQL warehouse with Unity Catalog. SQLLoad runs one SELECT per read and downloads its result as Arrow files through the short-lived links the Statement Execution API gives. Nothing is written to a volume or a bucket, and the source only needs read access.

[connections.dbx]
kind = "databricks"
host = "https://dbc-1234.cloud.databricks.com"
client_id = "${ENV:DATABRICKS_CLIENT_ID}"
client_secret = "${ENV:DATABRICKS_CLIENT_SECRET}"
warehouse_id = "${ENV:DATABRICKS_WAREHOUSE_ID}"
catalog = "main"
[sources.marts]
kind = "databricks"
connection = "dbx"
description = "Tables of the marts schema."
include = ["marts.*"]
exclude = ["marts.tmp_*"]
write_strategy = "replace"
[sources.marts.tables."marts.events"]
description = "Events, one row per event."
cursor_column = "event_at"
write_strategy = "append"
[sources.marts.tables.recent]
description = "Orders of the last week, with their customer."
sql = """
SELECT o.*, c.name
FROM main.marts.orders o JOIN main.marts.customers c USING (customer_id)
"""
cursor_column = "ordered_at"
write_strategy = "append"

A source uses a databricks connection, the same kind a Databricks target uses: it runs on the connection’s warehouse_id and reads its catalog. A connection that only a source uses needs no volume.

include and exclude are schema.table patterns in the connection’s catalog, such as marts.*, in lower case, as Unity Catalog stores names. "{primary_key}" is the key a table declares, which Unity Catalog doesn’t enforce. Query tables, where and column settings work as for every database source; see Sources. Write where and sql in Databricks SQL, naming tables in sql as catalog.schema.table.

Each read is one SELECT of the read columns, with the cursor window and any where, so the warehouse sends only those rows. A read sees one version of each table; different reads of one run, such as batch_size windows, can see the data moments apart.

SQLLoad downloads up to eight result files at a time, without the Databricks token. A link expires within 15 minutes, and a failed download is attempted again through a fresh link, up to three attempts in all. A result the warehouse cuts short at its byte limit fails the read rather than loading fewer rows.

Databricks type Loads as
TINYINT, SMALLINT smallint
INT, BIGINT int
DECIMAL(p,s), p up to 38 decimal(p,s); a DECIMAL with no precision is decimal(10,0)
FLOAT, DOUBLE float
BOOLEAN bool
STRING text
VARCHAR(n), CHAR(n) varchar(n)
BINARY binary
DATE date
TIMESTAMP timestamp_tz, in UTC
TIMESTAMP_NTZ timestamp_ntz
TIMESTAMP(p), TIMESTAMP_NTZ(p), p over 6 none: microseconds are the most a timestamp keeps, so pin text, or exclude the column
ARRAY, MAP, STRUCT, VARIANT json
INTERVAL and others none: pin text, or exclude the column

Pin a type to load a column another way, such as columns = { total = "decimal(18,2)" }, but not array(T): arrays load as json. See Types.

A STRING with another collation than UTF8_BINARY, such as UTF8_LCASE, loads as text. As a text cursor it is compared in byte order, as the destination’s maximum is, so a case-insensitive collation doesn’t skip rows.

Reads, listing tables and describing query tables run on the connection’s SQL warehouse and bill its compute; a stopped warehouse starts for the first read. A nullable cursor column under the default null_cursor = "fail" adds a count query; see NULL cursor values.

The service principal needs CAN USE on the SQL warehouse, USE CATALOG on the catalog, USE SCHEMA on the schemas it reads, and SELECT on the tables and views. It needs no volume or storage access. A workspace that has external links turned off can’t be read this way.

Against a local fake of the Statement Execution API, and live on a real serverless SQL warehouse: tables, a view and a query table in daily cursor windows, loaded and then merged into DuckDB, Parquet files, Postgres and ClickHouse. Row counts and sums matched on every target, for every column shape from STRUCT to dates in year 1 and 9999.