What you will be able to do
- State the plan, feature-flag and data-platform prerequisites for Advanced CI's compare changes
- Enable dbt compare on a CI job and say why it needs a primary key, a deferred environment and a sensible timeout
- Use event_time to stop compare changes from reporting false deleted or new rows
- Explain which credentials compare changes uses, where results show up, and how long cached samples are kept
Key concept
Compare changes (Advanced CI) — An opt-in setting on a CI job. On every pull request open or push, dbt diffs the data each modified model produces against the same model in production, then reports differences in primary keys, rows and columns as well as whether the build passed.
1.What Advanced CI adds to a CI job
A standard CI job answers one question: does the changed code build, and do its tests pass? It runs dbt build --select state:modified+ in a temporary schema and posts a pass or fail status to the pull request. Code can pass every test and still change the data it produces, for example a join that quietly duplicates rows or a filter that drops a region. Advanced CI closes that gap. Its main feature, compare changes, shows you the data differences a code change causes, not only whether it ran.
Advanced CI is something you switch on. It is not part of every account. Three conditions must all hold before the option appears. The account is on a dbt Enterprise or Enterprise+ plan. An administrator has enabled Advanced CI features for the account. The warehouse is BigQuery, Databricks, Postgres, Redshift or Snowflake. Miss any one and the CI job settings page has no compare checkbox at all. If you are on the Starter plan, you still get CI jobs, concurrent CI checks and smart cancellation of stale builds, but not compare changes.
The results appear in two places. In dbt, the Compare tab on the job run details page lists the changes to primary keys, rows and columns. In the Git provider, dbt posts a summary of the same comparison as a comment on the pull request, so a reviewer sees the data impact next to the code diff.
Checkpoint 1 of 8· Check yourself
A team on the Starter plan runs a Snowflake project and wants pull request comments summarising row-level data changes. What blocks them?
Snowflake is supported and pull request triggers are the normal setup. The plan tier, plus an administrator enabling Advanced CI, is what puts the dbt compare option in the job settings.
“For the compare changes feature, your dbt account must be on an Enterprise-tier plan and have enabled Advanced CI features.”Source: docs.getdbt.com
Checkpoint 2 of 8· Exam question
A data platform admin on dbt Cloud Enterprise turns on Advanced CI for a project's pull-request jobs. After the next PR run completes, which two categories of differences will the Compare tab surface between the production state and the PR branch's rebuilt models? (Select two)(Select 2)
Correct answers: A, B — Primary key mismatches between the production table and the PR branch's rebuilt table, flagged when a key present in one version is missing from the other.; Changes in row counts for modified models, showing how many rows were added or removed between the production version and the version built from the pull request branch.
- A. Advanced CI reports primary-key level differences, flagging rows whose key appears on only one side of the comparison. This is one of the core data-diff categories the Compare tab is built to surface.
- B. Row count changes for modified models are a core comparison category, showing how many rows were added or removed between the production state and the PR branch's rebuilt version. This directly answers the question of whether the code change altered the resulting dataset size.
- C. Advanced CI compares data outcomes, not warehouse query plans or optimizer decisions. Execution-plan differences are a warehouse performance concern, not something the Compare tab reports.
- D. Advanced CI's output focuses on row, column, and key-level data differences, not cost or runtime metrics. Credit consumption is tracked elsewhere in dbt Cloud's job run details, not in the Compare tab's diff output.
2.Turning on dbt compare in a CI job
Compare changes is a single checkbox, dbt compare, in the Execution settings of a CI job. It sits beside the Commands and Linting options. Turning it on tells dbt to compare the last applied state of production with the latest commit on the pull request. The rest of the setup decides whether that comparison is useful.
A primary key is how dbt matches a row in the CI build with the same row in production. Without one it cannot tell whether a row changed, was added or was removed, so it reports a "Primary key missing" error for that model. Add a uniqueness test or a primary key constraint to every model you expect reviewers to rely on in the Compare tab.
Compare changes also needs something to compare against, and deferral supplies it. Deferral points the CI job at another environment's latest successful run and uses the artifacts that run left behind, such as its manifest, as the reference state. dbt relies on that state twice: to find which models changed, so state:modified+ selects only those, and as the production baseline the CI build is diffed against. The Compare changes against an environment (Deferral) setting defaults to Production, and state comparison only works when a deferred environment is selected. The baseline is the latest successful run in that environment, and that run can come from any job that updates artifacts there. If many jobs with different settings write to the deferred environment, the comparison baseline moves in ways that are hard to predict. How deferral itself is configured is covered in [setting up a CI job with deferral](lesson:4.1).
Comparisons cost warehouse time, and two settings keep that cost in check. Run timeout cancels the job once it runs too long, and turning on dbt compare changes its default to 3600 seconds (one hour). The comparison command can also be customised. For example, a very large model that takes ages to diff can be left out with --exclude, and custom syntax can also change how deferral is used or exclude groups of models by tag.
Checkpoint 3 of 8· Check yourself
After an administrator enables dbt compare on a CI job, the next run is cancelled after one hour, although no one set a timeout. Why?
The 3600-second value is a default that dbt compare applies to guard against long comparisons. It is not a fixed cap, and it does not come from the deferred environment.
“If you enable the dbt compare option, the timeout value defaults to 3600 (one hour) to prevent long-running comparisons.”Source: docs.getdbt.com
Checkpoint 4 of 8· Exam question
When a dbt Cloud CI job runs against a pull request, dbt Cloud builds the modified models into a temporary schema scoped to that PR. What naming convention must this temporary schema follow for dbt Cloud's automatic cleanup to correctly drop it once the PR is merged or closed?
Correct answer: A — The schema name must contain the prefix `dbt_cloud_pr_` followed by the job and PR numbers, the pattern dbt Cloud uses to recognize and later drop PR-specific schemas automatically.
- A. dbt Cloud's automatic cleanup logic looks for the `dbt_cloud_pr_` prefix followed by identifying numbers to recognize which schemas belong to a pull request. If a custom `generate_schema_name` macro overrides this prefix, cleanup can no longer find and drop the schema.
- B. There is no supported `_ci_temp` suffix convention in dbt Cloud; cleanup relies on the `dbt_cloud_pr_` prefix appearing in the schema name, not on a suffix appended after a custom schema name.
- C. Schema names are generated from the PR and job identifiers dbt Cloud tracks internally, not from the literal git branch name, so a branch-name-based scheme would not match what the cleanup process looks for.
- D. Cleanup is automatic and pattern-based rather than driven by a manually maintained registry; there is no environment setting where schemas must be pre-registered before a CI run can use them.
3.Using event_time to compare matching time ranges
Many teams build only part of the data in CI, often controlled by an environment variable or the target name. That keeps CI fast and cheap, but it makes a naive data diff misleading. Suppose CI builds only the last 7 days. Compare changes then reads every older production row as missing and reports them as "deleted rows", even though the code deleted nothing. The reverse also happens. If the CI job ran more recently than production, its fresher rows show up as "new" data when they are simply newer.
Setting event_time on a model fixes both cases. With it set, compare changes limits the comparison to the timeframe that exists in both the CI and production environments. Only real differences are reported, and the comparison finishes faster because it scans less. event_time can be set on models, seeds, snapshots and sources. Point it at the column that records when the row's event actually happened, such as account_created_at, rather than an ingestion date.
models:
- name: model_name
config:
event_time: my_time_fieldCheckpoint 5 of 8· Fill the gap
Which config key makes compare changes limit its comparison to the overlapping timeframe?
models:
- name: model_name
config:
? : my_time_fieldevent_time tells dbt when each row occurred. Compare changes uses it to compare only the time range present in both CI and production.
Source: docs.getdbt.com4.Credentials, cached samples and the same-host rule
Compare changes runs SQL with the same credentials as the CI job, meaning the connection set in the CI job's environment. That choice has a consequence for governance. Every user on the account can see the comparison results and the cached sample rows. Whatever the CI credentials can read can therefore end up in front of anyone with access to the account. Restricting those credentials is the dbt administrator's job, and using synthetic data in CI is a valid choice when pre-production data is sensitive.
Dynamic data masking does not carry through. Masking in the warehouse depends on who runs the query, but the cached Advanced CI output is fixed when the CI credentials fetch it. A user who would normally see masked values may see unmasked ones in the Compare tab. To avoid this, limit access to unmasked data for the CI connection, or test with synthetic data.
To show example changes without querying the warehouse again, dbt caches a small sample of at most 100 records per modified model. The cache is encrypted, stored in Amazon S3 or Azure blob storage in the account's region, and kept for up to 30 days. If you open a CI run older than that, you see a message that the data has expired instead of comparison results. Review data changes while the pull request is still active.
Compare changes also has a hard requirement that is easy to miss: the CI model and the production model must live on the same database host or connection. The comparison is a query run in the CI environment that reads both, for example ci.dbt_cloud_123.foo against prod.analytics.foo. If the CI environment connects to abc123.rds.amazonaws.com and production to def456.rds.amazonaws.com, the CI connection cannot reach the production object, so the comparison does not work.
Checkpoint 6 of 8· Check yourself
A CI environment points at a staging Postgres host, and the Production environment it defers to sits on a separate Postgres host. Builds and tests pass, but compare changes does not work as expected. What is the cause?
Postgres is supported, and event_time only affects time-range overlap. The comparison query runs from the CI environment and cannot read production objects on a different host.
“Compare Changes only works if both CI and production models live on the same database host/connection.”Source: docs.getdbt.com
Checkpoint 7 of 8· Exam question
A team's CI job builds only the last 7 days of data for a large events model to keep pull-request runs fast, while the Production job builds the full multi-year history. Without any special configuration, Advanced CI's compare step flags millions of rows as 'deleted' on every PR, even when no rows actually changed. Which model-level configuration eliminates these false positives by aligning the comparison window to the overlapping time range?
Correct answer: A — Setting the `event_time` config on the model so Advanced CI limits its row and column comparison to the timeframe that both the CI build and the production table actually cover.
- A. `event_time` tells Advanced CI which timestamp column to use to align the comparison window, so it only compares the overlapping timeframe instead of penalizing the CI build for lacking older history it never built. This is the documented fix for exactly this false-positive pattern.
- B. Forcing a full refresh would make the CI run rebuild years of data on every pull request, defeating the purpose of scoping CI to a fast 7-day window and adding significant warehouse cost without addressing the comparison window mismatch.
- C. `unique_key` controls incremental merge behavior for the model's own build, not how Advanced CI aligns comparison timeframes between two differently-scoped builds; it would not stop older rows from being flagged as missing.
- D. Disabling the model in the CI environment would stop it from being compared at all, losing visibility into real changes to that model rather than fixing the comparison window that causes the false positives.
Sources1
5.Compare changes in development versus Advanced CI
The same idea also exists in development, and the exam can test which one fits a situation. Compare changes in development runs on demand in the dbt VS Code extension, which is powered by dbt v2. It previews the data effect of local edits to one model at a time, before any pull request exists. Advanced CI runs automatically for every modified model when a pull request opens or updates. It uses the CI job's credentials and posts its summary where reviewers will see it.
| Aspect | In development (compare changes) | In deployment (Advanced CI) |
|---|---|---|
| Affects | Development for one modified model at a time | Deployment for all modified models in a project |
| Trigger | On-demand in editor | PR open/update and CI job |
| Output location | Compare panel in VS Code/Cursor; no PR comment | Deployment job compare tab and PR summary comment in Git provider |
| Governance | Local development credentials | Production credentials |
Use the editor version to catch a bad join while you are still writing the model, when fixing it costs nothing. Use Advanced CI when a reviewer needs a record of the data impact attached to the pull request, covering every model the change touches.
Checkpoint 8 of 8· Match them up
Match each compare changes mode or output to its description
Tap a term, then the definition that fits it.
Development compare is on demand, covers one model, and posts no PR comment. Advanced CI runs on PR events for all modified models and posts a Git comment.
“Compare panel in VS Code/Cursor. Does not create a PR comment in Git provider”Source: docs.getdbt.com
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.Compare changes is available on any plan that supports CI jobs.Why is that wrong?
CI jobs are available on all plans, but compare changes needs an Enterprise or Enterprise+ account with Advanced CI features enabled by an administrator.
Covered in What Advanced CI adds to a CI job
2.Once dbt compare is ticked, every modified model gets a row-level diff automatically.Why is that wrong?
Record-level comparison and primary key analysis need a primary key constraint or uniqueness test on the model. Without one, dbt reports "Primary key missing".
Covered in Turning on dbt compare in a CI job
3.Deleted rows in a compare report always mean the code change removed data.Why is that wrong?
When CI builds only a subset of dates, compare changes reads the excluded rows as deleted unless event_time limits the comparison to the overlapping timeframe.
4.Warehouse dynamic masking protects values shown in the Advanced CI Compare tab.Why is that wrong?
The cached sample is fetched with the CI job's credentials and is not re-masked for each viewer, so unmasked values can reach users who would normally see masked ones.
Covered in Credentials, cached samples and the same-host rule
Sources
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.https://docs.getdbt.com/docs/deploy/advanced-ciOfficial docs
“You use a supported data platform: BigQuery, Databricks, Postgres, Redshift, or Snowflake.”
↩︎ What Advanced CI adds to a CI job“You can opt into Advanced CI in dbt.”
↩︎ What Advanced CI adds to a CI job“Shows the changes (if any) to the data's primary keys, rows, and columns in the Compare tab from the Job run details page.”
↩︎ What Advanced CI adds to a CI job“Shows a summary of the changes as a Git comment.”
↩︎ What Advanced CI adds to a CI job“compares the changes between the last applied state of the production environment (defaulting to deferral for lower compute costs)”
↩︎ Turning on dbt compare in a CI job“compare changes would flag the additional rows as "new" data”
↩︎ Using event_time to compare matching time ranges“The compare changes feature uses the same credentials as the CI job”
↩︎ Credentials, cached samples and the same-host rule“dbt stores a cache of no more than 100 records for each modified model for preview purposes.”
↩︎ Credentials, cached samples and the same-host rule“The selected data is cached on dbt Labs' systems for up to 30 days.”
↩︎ Credentials, cached samples and the same-host rule“If you access a CI job run that's more than 30 days old, you will not be able to see the comparison results.”
↩︎ Credentials, cached samples and the same-host rule“Compare changes in development is available through the dbt VS Code extension, which is powered by dbt v2.”
↩︎ Compare changes in development versus Advanced CI“dbt compares the changes between the last applied state of the production environment”
↩︎ Key concept“You have a dbt Enterprise or Enterprise+ account.”
↩︎ Exam trap 1“compare changes would interpret the excluded data as "deleted rows."”
↩︎ Exam trap 3“the cached data will no longer be dynamically masked in the Advanced CI output”
↩︎ Exam trap 4“Compare Changes only works if both CI and production models live on the same database host/connection.”
↩︎ Checkpoint - 2.https://docs.getdbt.com/docs/deploy/ci-jobsOfficial docs
“After enablement, the dbt compare option becomes available in the CI job settings.”
↩︎ What Advanced CI adds to a CI job“Importantly, state comparison can only happen when there is a deferred environment selected to compare state to.”
↩︎ Turning on dbt compare in a CI job“The latest successful run in the environment can come from any job that updates artifacts there.”
↩︎ Turning on dbt compare in a CI job“This option allows dbt to check the state of the code in the PR against the code running in the deferred environment”
↩︎ Turning on dbt compare in a CI job“you can exclude them to speed up the process using the --exclude flag.”
↩︎ Turning on dbt compare in a CI job“To enable record-level comparison and primary key analysis, you must add a primary key constraint or uniqueness test.”
↩︎ Exam trap 2“For the compare changes feature, your dbt account must be on an Enterprise-tier plan and have enabled Advanced CI features.”
↩︎ Checkpoint“To enable record-level comparison and primary key analysis, you must add a primary key constraint or uniqueness test.”
↩︎ Prediction“If you enable the dbt compare option, the timeout value defaults to 3600 (one hour) to prevent long-running comparisons.”
↩︎ Checkpoint - 3.https://docs.getdbt.com/guides/set-up-ciOfficial docs
“To be able to find modified nodes, dbt needs to have something to compare against.”
↩︎ Turning on dbt compare in a CI job - 4.
“you can optimize performance when running comparisons by using custom dbt syntax to customize deferral usage, exclude specific large models”
↩︎ Turning on dbt compare in a CI job - 5.
“highly recommended for Advanced CI's compare changes in CI/CD workflows”
↩︎ Using event_time to compare matching time ranges - 6.https://docs.getdbt.com/docs/dbt/vs-compare-changesOfficial docs
“Compare panel in VS Code/Cursor. Does not create a PR comment in Git provider”
↩︎ Compare changes in development versus Advanced CI