
Disclaimer: This is a personal project. It is
not affiliated with, endorsed by, or supported by any employer or vendor.
duckrun runs SQL in DuckDB over
Delta Lake tables — locally or on OneLake / S3 / GCS / ADLS. It's just
glue: DuckDB executes and writes the parquet · delta-rs
commits it · dbt orchestrates. Two ways to use it:
connect() — a notebook helper to query and write Delta straight from SQL (this page);
- a dbt adapter that materializes models as Delta tables.
Concurrent writers are first-class: every write is snapshot-pinned and fails loud rather than
silently interleaving.
Install
In a Microsoft Fabric notebook, upgrade and restart the kernel (duckrun needs duckdb ≥ 2.0.1,
which is newer than the bundled stable build; it fails loud at connect() otherwise):
!pip install duckrun --upgrade
notebookutils.session.restartPython()
For the dbt adapter, install the extra instead: pip install "duckrun[dbt]".
Quickstart — OneLake in a notebook
import duckrun
# Read-only by default — explore a lakehouse safely, no chance of an accidental write.
# Use the workspace + lakehouse GUIDs (friendly names hit an upstream OneLake read bug for now).
conn = duckrun.connect("abfss://<workspace_id>@onelake.dfs.fabric.microsoft.com/<lakehouse_id>/Tables/dbo")
conn.sql("SHOW TABLES").show()
conn.sql("select status, count(*) from orders group by status").show()
conn.sql("select * from orders").df() # native DuckDB relation → pandas (.arrow(), .pl() too)
# Time travel, DuckDB's syntax
conn.sql("select * from orders at (version => 0)").show()
Need to write? Opt in with read_only=False — everything is SQL:
conn = duckrun.connect("abfss://…/Tables/dbo", read_only=False)
# write Delta straight from SQL — DuckDB writes the files, delta-rs commits them
conn.sql("CREATE OR REPLACE TABLE clean_orders AS SELECT * FROM orders WHERE amount > 0")
# raw DML works the same way (insert / update / delete / alter / drop)
conn.sql("delete from clean_orders where amount = 0")
# upsert — snapshot-pinned automatically, nothing extra to pass
conn.sql("""
MERGE INTO clean_orders t USING updates s ON t.id = s.id
WHEN MATCHED THEN UPDATE SET *
WHEN NOT MATCHED THEN INSERT *
""")
conn.close()
Multiple catalogs — attach more lakehouses and read/join across them by three-part name. In
Fabric a Warehouse is just a write-locked Lakehouse, so attach it read_only=True next to a writable
one:
conn.attach("abfss://…/warehouse.Warehouse/Tables", name="warehouse", read_only=True)
conn.attach("/data/reference", name="local")
conn.sql("select * from warehouse.mart.facts f join local.dbo.lookup l on l.id = f.id").show()
Works the same against a local path, s3://, gs://, or az://. Full method map:
Connection API · API reference ·
live multi-catalog demo.
dbt adapter
duckrun is also a dbt adapter — a thin wrapper around
dbt-duckdb that adds Delta-backed table / incremental
materializations (everything else dbt-duckdb gives you is inherited). Point a profile at a lakehouse
and dbt run:
# ~/.dbt/profiles.yml
my_project:
outputs:
dev:
type: duckrun
root_path: "abfss://<workspace_id>@onelake.dfs.fabric.microsoft.com/<lakehouse_id>/Tables"
Multiple lakehouses in one project — declare extra write roots as named catalogs: and send a
model to one with the standard dbt +database: <alias> config (e.g. a Bronze/Silver/Gold medallion
across three Fabric Lakehouses). ref() and joins resolve across them:
dev:
type: duckrun
root_path: "abfss://[email protected]/LH_Silver.Lakehouse/Tables" # default
catalogs:
lh_bronze: { root_path: "abfss://[email protected]/LH_Bronze.Lakehouse/Tables" }
lh_gold: { root_path: "abfss://[email protected]/LH_Gold.Lakehouse/Tables" }