Skip to main content

dbt-polars

dbt-polars integrates the flexibility and performance of Polars with the data governance and lineage capabilities of dbt.

Why dbt-polars

Bring dbt to your Polars code
  • Organize Polars code in a familiar dbt project structure.
  • Get lineage and documentation for every model out of the box.
  • Test your models with dbt tests, written in SQL or Python.

See dbt compatibility for the full list of supported features.

Combine SQL and Python models
  • Freely mix SQL and Python models, even when they are ephemeral.
  • Minimize data transfer by delaying model execution until write.
  • Python models provide an escape hatch for complex SQL logic.

SQL and Python models both compile to a Polars LazyFrame, so they can ref() each other freely. The same model, written both ways:

SQL: models/revenue_per_country.sql Python: models/revenue_per_country.py
select
    country,
    sum(amount) as revenue
from {{ ref('orders') }}
where status = 'paid'
group by country
import polars as pl

def model(dbt, session):
    orders = dbt.ref("orders")
    paid = orders.filter(
        pl.col("status") == "paid"
    )
    return paid.group_by("country").agg(
        revenue=pl.col("amount").sum()
    )

Python ephemeral models

Unlike most dbt adapters, dbt-polars supports ephemeral Python models thanks to Polars' lazy frames. This is how it works:

An ephemeral Python model inlined into a SQL model
  1. Polars runs inside the dbt process, so Python models need no separate compute.
  2. ref() returns a LazyFrame: a reference to storage. No data is read yet.
  3. The ephemeral Python model returns a LazyFrame, which the downstream SQL or Python model uses like any other table. Both add to one query plan.
  4. On write, Polars optimizes the full plan, reads only the data it needs, and streams the result to storage.
Adaptable to your platform
  • Run Polars on any compute, avoiding lock-in to a costly warehouse.
  • Write to Databricks, Snowflake, Azure Blob Storage, Fabric, ...
  • Or write a custom catalog extension to perfectly fit your platform.

dbt-polars uses catalogs to define where data is stored. Each catalog maps to a storage backend. You can configure multiple catalogs in a single profile and reference them from your models. See the Catalog overview.

Supported catalogs

Catalog extensions define where dbt-polars reads and stores data.

TargetCatalog
Local filesystemlocal
Azure Blob Storage / ADLS Gen2azure
Databricks Unity Catalogdatabricks (Delta, Iceberg)
Microsoft Fabric OneLakefabric (Delta, Iceberg)
Snowflake Horizon Catalogsnowflake (Iceberg)
Other Iceberg catalogsiceberg (any pyiceberg backend, e.g. SQLite, REST, Glue)
Other platformsWrite your own catalog extension

To support another platform, you can write your own catalog. See Custom catalogs.

Limitations

  • Views are not supported, as there is no database to hold them. Use table or ephemeral instead.
  • The hash macro is not supported. Use a Python model for hashing instead.

See dbt compatibility for the full overview, including supported macros.

Getting started

The first steps are below. For the full walkthrough, see the Getting started guide.

Install dbt-polars and create a new dbt project:

pip install dbt-polars
dbt init

When prompted, choose polars as the database and local as the catalog type. This creates a profile that writes tables to your local disk:

my_project:
  target: dev
  outputs:
    dev:
      type: polars
      schema: main
      catalog_type: local
      root: ./data

dbt-polars does not support views, so replace the models: block in dbt_project.yml with:

models:
  my_project:
    +materialized: table

Then build the example models:

dbt run

The Getting started guide continues from here with other catalogs, seeds, ephemeral models, docs, tests and incremental ingestion.

Documentation

The full documentation is available at datamindedbe.github.io/incubator-dbt-polars.

Metadata

Release files for dbt-polars-catalog-local 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dbt-polars-catalog-local 0.5.0
File Size Uploaded Provenance
dbt_polars_catalog_local-0.5.0.tar.gz 7.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dbt-polars-catalog-local 0.5.0
File Interpreter ABI Platform
dbt_polars_catalog_local-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.6 kB

Release files / dbt_polars_catalog_local-0.5.0.tar.gz

Download URL dbt_polars_catalog_local-0.5.0.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1768cd4daa2398e8477100db3e51cd0b7de7566496bcb0af2fb20a523f228c77
BLAKE2b-256 checksum
How to use checksums
34d23966b5f37fa93a0743493e51bf0ac0684884808708851551330b187fae9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / dbt_polars_catalog_local-0.5.0-py3-none-any.whl

Download URL dbt_polars_catalog_local-0.5.0-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00ec6c888493b2bc119083128dbdecef7b397a6bd766979b757e4cf1011def8b
BLAKE2b-256 checksum
How to use checksums
e8b81f1d24dcd977023272c95d79f46bfa37ef709189e9398bf615b3b9809222
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for dbt-polars-catalog-local 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page