Skip to content

feat: add --no-full-refresh flag to dbt compile#12628

Open
dtaniwaki wants to merge 1 commit intodbt-labs:mainfrom
dtaniwaki:worktree-recursive-strolling-eclipse
Open

feat: add --no-full-refresh flag to dbt compile#12628
dtaniwaki wants to merge 1 commit intodbt-labs:mainfrom
dtaniwaki:worktree-recursive-strolling-eclipse

Conversation

@dtaniwaki
Copy link

Resolves #10918

Thanks for maintaining dbt-core! I'd appreciate a review on this small addition.

Problem

When compiling incremental models with dbt compile, is_incremental() always returns False because it requires the target relation to exist in the database. This makes it impossible to inspect the incremental SQL path (e.g., for linting with SQLFluff or dry-run validation in CI) without actually running the model.

Setting full_refresh: false in model config does not help here — even with that config, is_incremental() returns False if the table doesn't exist yet.

Solution

Add a --no-full-refresh flag to dbt compile that forces is_incremental() to return True during compilation, without querying the database. This is compile-only and intentionally not available for dbt run, where the absence of the target relation would cause execution to fail.

dbt compile --select my_incremental_model --no-full-refresh

Also available via environment variable:

DBT_NO_FULL_REFRESH=true dbt compile --select my_incremental_model

The implementation follows the same pattern used by microbatch, which injects is_incremental = lambda: True into the Jinja context.

Checklist

  • I have read the contributing guide and understand what's expected of me.
  • I have run this code in development, and it appears to resolve the stated issue.
  • This PR includes tests, or tests are not required or relevant for this PR.
  • This PR has no interface changes (e.g., macros, CLI, logs, JSON artifacts, config files, adapter interface, etc.) or this PR has already received feedback and approval from Product or DX.
  • This PR includes type annotations for new and modified functions.

@dtaniwaki dtaniwaki requested a review from a team as a code owner March 10, 2026 07:53
@cla-bot cla-bot bot added the cla:yes label Mar 10, 2026
@github-actions
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@github-actions github-actions bot added the community This PR is from a community member label Mar 10, 2026
@dtaniwaki dtaniwaki force-pushed the worktree-recursive-strolling-eclipse branch from 1623d73 to f2fd732 Compare March 10, 2026 07:54
Signed-off-by: Daisuke Taniwaki <daisuketaniwaki@gmail.com>
@dtaniwaki dtaniwaki force-pushed the worktree-recursive-strolling-eclipse branch from f2fd732 to 2b60482 Compare March 10, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla:yes community This PR is from a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add --force-incremental flag to dbt compile

1 participant