Skip to content

Wire dbt module to optionally target DuckDB (#593) - #599

Open
RonaldHensbergen wants to merge 2 commits into
mainfrom
feat/593-wire-dbt-duckdb
Open

Wire dbt module to optionally target DuckDB (#593)#599
RonaldHensbergen wants to merge 2 commits into
mainfrom
feat/593-wire-dbt-duckdb

Conversation

@RonaldHensbergen

@RonaldHensbergen RonaldHensbergen commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Summary

Extends the experimental dbt module so it can optionally target the new DuckDB warehouse module (introduced in #596) instead of Postgres, selected by a new warehouseType config field. This is the dbt half of the remaining #593 checklist.

Changes

  • modules-experimental/transformation/dbt/module.yaml
    • Added warehouseType config field (postgres | duckdb, default postgres).
    • Both targetDatabase (sql-database) and the new targetWarehouseFile (file-database) consumes entries are now optional; target selection and required-env enforcement moved to the container entrypoint.
    • dbt-run gains a DuckDB bind-mount, guarded by a new enabledFrom: "config.warehouseType==duckdb" per-entry condition, plus DBT_WAREHOUSE_TYPE/DBT_DUCKDB_PATH env vars; existing Postgres env vars are now ifNonempty:-wrapped so they resolve safely when Postgres isn't the active target.
  • cli/renderer.py
    • Bind-mount entries inside a service's volumes: list can now carry an enabledFrom guard (previously only whole services and named top-level volumes supported this), so a DuckDB-only mount never leaks into rendered output when Postgres is selected.
    • _resolve_expr gained a "<path>==<value>" equality expression form (renderer only), since the existing enabledFrom only supported boolean flags, not string/enum comparisons.
  • images/dbt/: profiles.yml now defines two named outputs (postgres, duckdb) selected via DBT_WAREHOUSE_TYPE; entrypoint.sh validates required env vars per target; requirements.txt adds dbt-duckdb==1.11.0; README.md documents the dual-target env vars and volumes.
  • docs/architecture.md / docs/roadmap.md: reflect dbt's new dual-target capability.
  • Added renderer unit tests for the new per-item enabledFrom volume filtering and the == equality expression.

Testing

  • make lint — clean.
  • Full suite: python -m unittest discover -s tests -p "test_*.py" — 629 tests pass.
  • Manually verified with a (not committed) scratch profile wiring postgres, duckdb, and two dbt instances (one per target): both render correctly, and the DuckDB-targeting instance's bind-mount source matches the duckdb module's own data directory — confirming real cross-module file sharing via the file-database contract.

Out of scope / follow-up

Part of #593 (see also #596). dlt wiring and a combined demo profile remain outstanding, so #593 is not fully resolved yet.

RonaldHensbergen and others added 2 commits September 3, 2026 22:05
Introduces a new file-database contract and a
modules-experimental/warehouse/duckdb/ module providing DuckDB as an
embedded, file-based analytical warehouse alongside postgres.

- New shared/contracts/file-database.yaml contract (hostDirectory,
  filename, path, readOnly) for embedded databases that have no
  network protocol, distinct from sql-database.
- New duckdb-init one-shot compose service that bind-mounts a shared
  host directory and prepares the database file with permissive
  file modes so non-root consumer containers (dlt, dbt) can open it
  directly with their own DuckDB client library.
- Digest-pinned, hardened per repo conventions (read_only, cap_drop,
  no-new-privileges, disabled healthcheck).
- tests/test_duckdb_hardening.py covers module metadata, config
  schema, contract shape, and service hardening.
- docs/architecture.md and docs/roadmap.md updated to list DuckDB as
  an experimental storage/compute option.

DuckDB's experimental label reflects that the file-database contract
shape is new to CDS and not yet exercised by real consumers, not any
immaturity in DuckDB itself -- it is a fast, production-grade,
vectorized/columnar OLAP engine competitive with distributed engines
like Spark for single-node analytics.

Wiring dlt/dbt to consume this contract and adding a demo profile are
deferred to a follow-up PR to keep this change reviewable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Extends the experimental dbt module to support two mutually exclusive
targets, selected by a new warehouseType config field:

- postgres (existing): consumes sql-database, unchanged behavior.
- duckdb (new): consumes the file-database contract from the new
  DuckDB warehouse module, mounting its shared data directory into
  the dbt container and pointing dbt-duckdb at the shared .duckdb
  file.

Renderer changes needed to support this cleanly:
- Individual bind-mount entries in a service's volumes list can now
  carry an enabledFrom guard, mirroring the existing service-level
  and named-volume-level mechanism, so a DuckDB-only mount never
  reaches rendered output when Postgres is the active target.
- _resolve_expr gained a "<path>==<value>" equality expression form
  (renderer only), since the prior enabledFrom only supported boolean
  flags, not string/enum comparisons like warehouseType==duckdb.

images/dbt/profiles.yml, entrypoint.sh, requirements.txt (adds
dbt-duckdb==1.11.0), and README.md updated accordingly.

Verified manually with a scratch profile wiring one dbt instance per
target plus the postgres and duckdb modules: both render correctly,
and the DuckDB instance's bind-mount source matches the duckdb
module's own data directory, confirming real cross-module file
sharing via the file-database contract.

dlt wiring and a combined demo profile remain deferred to a follow-up
PR, pending the dlt module's own PR merging to main.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Base automatically changed from feat/593-duckdb-warehouse-module to main September 4, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant