dbt OSS support (experimental)#
Note
Available since Cosmos 1.16.0.
Warning
Support for dbt OSS is experimental. The behavior may change between Cosmos releases, and it is not recommended for production yet. Cosmos CI runs the integration tests against BigQuery and DuckDB, and only the Databricks metric view and Snowflake semantic view tests against the other adapters (see #3101).
Context#
dbt OSS is the open-source (Apache 2.0) distribution of dbt 2. See Comparing dbt and dbt OSS for how it differs from dbt Core 1.x and dbt Fusion.
It is published on PyPI as dbt-oss and includes its adapters, so you do not install dbt-<adapter> packages. See the dbt supported data platforms for the adapters it supports. Adapters that dbt OSS marks as experimental, such as Postgres, need DBT_ALLOW_EXPERIMENTAL_ADAPTERS=true. Of these, Cosmos tests BigQuery and DuckDB, and Databricks and Snowflake for metric and semantic views only.
How to use#
Install dbt OSS in the environment where dbt runs
dbt OSS and dbt Core 1.x both provide the
dbtPython package, so install dbt OSS in an environment without dbt Core 1.x.pip install "astronomer-cosmos[dbt-oss]>=1.16.0"
Use Cosmos as usual
from cosmos import DbtDag, ProjectConfig, ProfileConfig DbtDag( project_config=ProjectConfig("/usr/local/airflow/dbt/my_project"), profile_config=ProfileConfig( profile_name="my_profile", target_name="dev", profiles_yml_filepath="/usr/local/airflow/dbt/my_project/profiles.yml", ), dag_id="my_dbt_oss_dag", ..., )
Cosmos detects dbt OSS from the Python environment that Airflow runs in. It does not look at
dbt_executable_path. It treats the environment as dbt 2 whendbt-oss,dbt-coreordbtis installed at version 2, so installingdbt2.x also takes the dbt OSS code paths.
How Cosmos behaves with dbt OSS#
These are the differences between dbt OSS and dbt Core 1.x that Cosmos accounts for.
Area |
What Cosmos does |
|---|---|
DAG parsing ( |
Runs |
Missing dbt packages |
dbt OSS installs them itself during |
|
Runs the producer task in a subprocess, because the |
Watcher modes, upstream failure |
dbt OSS reports the nodes it skips after an upstream failure with the |
Test warnings and failures ( |
Reads the text output of dbt OSS to count test warnings and to find source freshness warnings for |
|
dbt OSS leaves |
dbt docs |
|
|
Cosmos writes dict values for these flags as one-line flow YAML, for example |
|
Add dbt OSS to |
Container modes, working directory ( |
Start the pod in the dbt project directory and keep its |
Limitations#
Area |
Limitation |
|---|---|
Partial parsing |
|
Event callbacks |
The |
Empty models |
|
Projects with the same name ( |
dbt OSS keeps the macros of a project by package name for the lifetime of the Python process, so two dbt projects with the same |
Python models |
dbt OSS rejects them on DuckDB with |
|
Not supported. The |
Configuration that dbt 1.x accepts |
dbt OSS rejects some of it. Cosmos CI runs |
dbt-loom |
dbt-loom is reported not to work with dbt OSS, which blocks the plugin hook it uses. See dbt-loom issue 192. The dbt-loom example DAGs are disabled in the dbt OSS CI job (#3105). |
Tracking#
dbt OSS work is tracked in the dbt-oss tracking issue. Related issues and pull requests have the dbt-oss-v2 label.