Repository navigation
feat(review): consumers outside dbt, engine-aware integer division, opt-in contract and column-list checks - #1724
Draft
RaghwendraSingh wants to merge 2 commits into
Draft
RaghwendraSingh wants to merge 2 commits into
RaghwendraSingh wants to merge 2 commits into
Conversation
…re integer division, empty unit-test fixtures - `adapter-capabilities.ts`: per-adapter behavior table with doc citations; engine-dependent rules read it instead of assuming one engine - integer division: correctness finding on Postgres/Redshift/Trino/Athena/SQL Server; portability advice (packages only) on Snowflake/BigQuery/Databricks/DuckDB; also matches `count(…) / count(…)` and underscore literals - a column removed from a model with `exposures` or an enforced contract names those consumers (`dbt.manifest` evidence, via a new `modelConsumers` runner method) - a new column missing from an enforced contract is reported unless `ciRunsDbtBuild: true`; a column declared in a changed yml counts - opt-in `consumerColumnLists` in `review.yml`: explicit column lists in loaders/exports must follow a model's added and removed columns - dbt unit tests whose `given` inputs are all `rows: []` are reported (cannot fail, or expect rows from nothing) - column sets come from column lineage; a `*` in the output skips the checks rather than guessing - column lineage retries without the schema when a manifest-only (partial) schema yields nothing: undocumented upstream tables made it return no columns, silently disabling column-breakage checks on projects without `catalog.json` - a manifest-only schema no longer reports `validate: Table '<x>' not found` for undocumented models (an engine warning that could gate a PR); kept when a complete `catalog.json` schema is loaded Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hes inside strings, generic docs From an adversarial generality review: - the contract-vs-`SELECT` check restates what `dbt build` enforces, so it is now opt-in (`checkContractColumns`, replaces `ciRunsDbtBuild`) and comments only (catalog origin) - integer division ignores text inside string literals (`'2024/01/15'` is not a division) - the empty-inputs unit-test finding no longer claims the test "cannot fail" (models emitting constant rows still produce output) - an adapter the review doesn't map (a community adapter) no longer counts as a known dialect, so generic advice isn't suppressed on a guess - docs: the column-list example is a generic export script, not one project's loader convention Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 of 7 tasks
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
6 of 7 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #
Stacked on #1723 (← #1722 ← #1721 ← #1720 ← #1719); merge in that order. Draft: the new rules are not yet measured on a public-repo benchmark.
Type of change
What does this PR do?
Deterministic checks that work on any dbt project, from the manifest and the diff, plus three fixes found by an end-to-end run on a real dbt project.
New checks
adapter-capabilities.tsis a per-adapter table, with each entry citing the engine's docs. Rules whose correctness depends on the engine read the table instead of assuming one engine.int / int(andcount(…) / count(…)) is a correctness finding on Postgres, Redshift, Trino/Athena and SQL Server.exposuresor an enforced contract produces a finding that names those consumers (newmodelConsumersrunner method).SELECT, opt-in (checkContractColumns). A new column missing from an enforced contract is reported. It's off by default becausedbt buildalready fails on it, and it never blocks.consumerColumnLists). For export or reverse-ETL scripts that copy a model's columns.giveninputs are allrows: []. The model's logic over its inputs is never exercised.Fixes found by the end-to-end run
catalog.json. It now retries without the schema.validate: Table '<x>' not foundwarnings. A manifest-only schema produced this engine warning for undocumented models; 50 new models meant 50 warnings and a blocked gate. It's still reported when a completecatalog.jsonschema is loaded.How did you verify your code works?
test/altimate/review-contracts-dialect.test.ts: engine table per dialect, string literals, exposures and contracts, the opt-ins, unit-test fixtures, and dialect packs.modelConsumersand the partial-schema filter, using the engine's real response shape.bun typecheckis clean, and the real-world corpus is unchanged (15/15 caught, 0/5 false positives).revenue_dashboardand the contract; 0.12.10 reports nothing for it.dbt parseonly, base from the GitHub event). Off-diff findings went from 219–427 per PR to 0 (e.g. 431 findings → 1 on a 2-file PR), and no earlier catch was lost. That's mostly from the earlier PRs in the stack; this PR's fixes keep the count at 0.Cost side effects
None. No model calls or warehouse queries. Column lineage may run a second time, without the schema, when the first call returns nothing (in-process, bounded by the number of changed models).
Screenshots / recordings
N/A (CLI).
Checklist
🤖 Generated with Claude Code
Summary by cubic
Adds deterministic review checks that run on any dbt project from the manifest and the diff, plus three fixes from an end-to-end run on a real dbt project.
New checks
int / int(andcount(…) / count(…)) is a correctness finding on Postgres, Redshift, Trino/Athena and SQL Server; on Snowflake, BigQuery, Databricks and DuckDB it is portability advice for multi-adapter packages only, and text inside string literals is ignored.exposuresor an enforced contract now names those consumers (newmodelConsumersrunner method).checkContractColumns(opt-in, never blocks): a new column missing from an enforced contract is reported;dbt buildalready fails on it, so it's off by default.consumerColumnLists(opt-in): named files outside dbt that copy a model's columns must follow added and removed columns.giveninputs are allrows: []are reported, since they never exercise the model's logic.Fixes
catalog.json.Table '<x>' not foundvalidation warnings; these are kept when a completecatalog.jsonschema is loaded.Written for commit 1522b5a. Summary will update on new commits.