Skip to content

Derive the dbt contract id from the manifest's project_name - #1403

Merged
simonharrer merged 2 commits into
datacontract:mainfrom
DMZ22:dbt-import-contract-id
Jul 29, 2026
Merged

Derive the dbt contract id from the manifest's project_name#1403
simonharrer merged 2 commits into
datacontract:mainfrom
DMZ22:dbt-import-contract-id

Conversation

@DMZ22

@DMZ22 DMZ22 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Closes #1221.

import_dbt_manifest called create_odcs() with no arguments, so odcs_helper.create_odcs's id=id or "my-data-contract" default applied to every dbt import. The project name was already being read one line later for odcs.name, so the information was there — just not used for the id.

$ datacontract import --format dbt --source manifest_jaffle_duckdb.json
  before:  id: my-data-contract    name: jaffle_shop
  after:   id: jaffle_shop         name: jaffle_shop

I normalise the id with .lower().replace(" ", "-"), matching powerbi_importer.py, which is the only other importer that sets an id today. dbt project names are already snake_case by dbt's own naming rules, so this is a no-op for real manifests and only matters for hand-edited ones — happy to drop it and assign project_name verbatim if you'd rather keep it literal.

A manifest with no project_name still falls back to my-data-contract, so nothing changes for malformed input.

Tests. The four expected fixtures all asserted id: my-data-contract, so they are updated to jaffle_shop. Three new tests cover the behaviour directly: the id comes from the project name (checked against both jaffle_shop and test_project), it is slugified for a name with spaces and capitals, and it still falls back when project_name is absent.

Reverting only dbt_importer.py while keeping the tests takes tests/test_import_dbt.py from 15 passed to 6 failed, so the new tests do guard the change rather than just restate it.

No regressions. pytest -k import --continue-on-collection-errors gives 24 failed / 34 errors both before and after — all of them optional backends (S3, Trino, SQL Server) that need extras I don't have installed locally — while passes go 73 → 76, which is exactly the three new tests.

  • Tests pass (uv run pytest)
  • Code formatted (uv run ruff check --fix && uv run ruff format)
  • Docs updated (if relevant) — docs/docs/imports/dbt.md shows no sample contract, so nothing to change
  • CHANGELOG.md entry added

DMZ22 and others added 2 commits July 24, 2026 15:03
import_dbt_manifest called create_odcs() with no arguments, so odcs_helper's
`id or "my-data-contract"` default applied to every dbt import regardless of
the project. The project name was already read for odcs.name, so use it for
the id too, normalising it the way the Power BI importer does.

A manifest without a project_name still falls back to the previous default.
@simonharrer
simonharrer merged commit f32e98f into datacontract:main Jul 29, 2026
16 of 17 checks passed
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.

dbt importer leaves contract id as placeholder my-data-contract

2 participants