Skip to content

feat(dbt): report row counts on table-materialized models - #56

Draft
tillywoodfield wants to merge 2 commits into
devfrom
feat/51-report-dbt-row-counts
Draft

tillywoodfield wants to merge 2 commits into
devfrom
feat/51-report-dbt-row-counts

Conversation

@tillywoodfield

@tillywoodfield tillywoodfield commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

What & why

No dbt model reported a row count in Dagster, so a model that lost rows showed nothing in the UI. This sets include_metadata: [row_count] on the dbt component, so dagster-dbt runs one count(*) per table-materialized model after each build and reports it as dagster/row_count. Views report nothing.

Closes #51

Changes

  • defs/dbt_ingest/defs.yaml sets include_metadata to row_count
  • tests/dbt_ingest/test_defs.py builds every dbt asset through the project's definitions against the CI fixtures and checks each table's count against the database

Notes for reviewers

  • Locally, on DuckDB, dagster-dbt holds every event from a dbt build until the dbt process exits, since it can't open the database file while dbt holds the lock. During a run, the asset graph shows the dbt models and their checks all at once when the build ends. The dbt logs still stream, models that succeed before a failure are still recorded, and automation reads the events once they exist. On BigQuery, events stream as each model finishes.
  • The count query uses each node's relation_name from the component's prepared manifest, which carries the catalog from the DUCKDB_PATH file name at preparation. dg dev re-prepares on every load. A run from a manifest prepared against a differently named DuckDB file, such as after switching DUCKDB_PATH outside dg dev, logs an error per count and materializes without one. On BigQuery the relation names come from the profile's project and dataset, so they match while the deployment prepares and runs against the same target.
  • The test sets DAGSTER_IS_DEV_CLI so the manifest is prepared against its temporary database, and counts rows in a subprocess because dbt's in-process DuckDB connection outlives the run. It takes about 30 seconds.

Checklist

  • Addresses one issue, linked above
  • Tests updated where relevant
  • Docs updated where relevant
  • Self-reviewed the diff

Testing: pre-commit run --all-files (with CI's UV_NO_ENV_FILE=1), dg check defs, dbt build on the CI fixtures and pytest all pass, 445 tests. The new test fails with all 40 tables missing a count when include_metadata is removed, and fails with count errors when the manifest is left prepared against another database.

🤖 Generated with Claude Code

@tillywoodfield

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-27T16:46:42.116718Z 032f984 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a6dc8131be

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/dfo_pipelines/defs/dbt_ingest/defs.yaml
@tillywoodfield

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 032f98475c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/dfo_pipelines/defs/dbt_ingest/defs.yaml
@tillywoodfield

Copy link
Copy Markdown
Collaborator Author

@codex review

This branch has not been deployed

No deployments
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.

Report row counts on dbt models

1 participant