CertSafari
    DBT Architect· Lessons

    Domain 4 · Lesson 24/39

    Advanced CI in dbt: compare changes on pull requests

    Configuring Advanced CI

    14 min read
    2.56% of exam
    6 sources
    Published 13 Oct 2026
    Docs as of 12 Oct 2026

    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?

    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)

    Sources12

    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?

    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?

    Sources2314

    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.

    Setting event_time on a model in a properties YAML fileyaml
    models:
      - name: model_name
        config:
          event_time: my_time_field

    Checkpoint 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_field

    Sources15

    4.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?

    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?

    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.

    Compare changes in development versus in deployment
    AspectIn development (compare changes)In deployment (Advanced CI)
    AffectsDevelopment for one modified model at a timeDeployment for all modified models in a project
    TriggerOn-demand in editorPR open/update and CI job
    Output locationCompare panel in VS Code/Cursor; no PR commentDeployment job compare tab and PR summary comment in Git provider
    GovernanceLocal development credentialsProduction 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.

    Sources61

    Exam traps

    Each one states something that sounds right. Open it to see what is actually true.

    1. 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. 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. 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.

      Covered in Using event_time to compare matching time ranges

    4. 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. 1.
      “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. 2.
      “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. 3.
      “To be able to find modified nodes, dbt needs to have something to compare against.”
      ↩︎ Turning on dbt compare in a CI job
    4. 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. 5.
      “highly recommended for Advanced CI's compare changes in CI/CD workflows”
      ↩︎ Using event_time to compare matching time ranges
    6. 6.
      “Compare panel in VS Code/Cursor. Does not create a PR comment in Git provider”
      ↩︎ Compare changes in development versus Advanced CI

    Ready to test yourself?

    Practise the 8 questions on this subdomain.

    Spotted a mistake, or was something unclear? Tell us.