When dbt seems to ignore a model change, show outdated information, or behave differently after a project update, clearing its cache may help. The tricky part is that “dbt cache” can mean several things: files used to speed up project parsing, metadata kept during a command, or cached results in your data warehouse. Each has a different fix.
For most local projects, the first step is to clear dbt’s generated target directory with dbt clean, then rebuild dependencies if needed. If you want to remove only the partial-parsing cache, you can delete its file or run a command with partial parsing disabled. This guide explains the options, when to use them, and what not to delete.
What Does “dbt Cache” Mean?
dbt uses cached or generated information to make development and execution more efficient. When someone asks how to clear dbt’s cache, they may be referring to one of several different things:
- Partial-parsing cache: A local file that helps dbt identify project changes without parsing every file from scratch.
- Generated project artifacts: Files in the target directory, such as a manifest, run results, and compiled SQL.
-
Installed packages: Project dependencies stored in a directory such as
dbt_packages. These are not strictly a cache, but they are often removed during cleanup. - Runtime metadata: Information dbt holds while a command is running. It is generally temporary and is not usually cleared by deleting a local file.
- Warehouse or BI-tool cache: Cached query results or dashboards managed by your warehouse or reporting platform, not by dbt.
Identifying the problem first prevents unnecessary cleanup. For example, deleting local dbt files will not refresh a cached dashboard, and a full rebuild of warehouse tables is usually not needed just because parsing seems stale.
The Quickest Fix: Run dbt Clean
From your dbt project directory, run:
dbt clean
This removes the directories listed under clean-targets in your dbt_project.yml. Many projects configure this to include target and dbt_packages. The target directory contains generated files, including the partial-parsing cache when partial parsing is in use.
Check your project configuration before running the command. For example:
clean-targets:
- "target"
- "dbt_packages"
The configured paths can vary. If your project lists additional directories, dbt clean may remove those too. Make sure you understand what each path contains before proceeding, especially in a customized project.
If you removed dbt_packages, reinstall the project’s dependencies before running commands that rely on them:
dbt deps
You can then run the command you originally needed, such as dbt parse, dbt compile, or dbt run. Cleaning generated files does not, by itself, rebuild warehouse tables.
Clear Only the Partial-Parsing Cache
If the issue appears related to dbt parsing changes in your project, you may not need to remove every directory listed in clean-targets. In a typical project, the partial-parsing cache is stored at:
target/partial_parse.msgpack
Close any running dbt command, then remove that file. On macOS or Linux, for example:
rm -f target/partial_parse.msgpack
In PowerShell, you can use:
Remove-Item .\target\partial_parse.msgpack -ErrorAction SilentlyContinue
The next dbt command will need to parse the project without relying on that saved partial-parse state. The exact location can differ if your project uses a custom target path or environment-specific configuration. If you cannot find the file, check your project settings and the target path shown in your dbt output.
Removing only this file is a narrower option than running dbt clean. It leaves package installations and other generated files in place.
Run a Command Without Partial Parsing
To test whether partial parsing is causing the problem, you can disable it for a single command using the --no-partial-parse option. For example:
dbt parse --no-partial-parse
You can also use the option with other dbt commands where it is supported, such as:
dbt compile --no-partial-parse
This is useful as a diagnostic step: if the command succeeds when partial parsing is disabled, the saved parsing state may have been stale or inconsistent. Option availability and command behavior can vary by dbt version, so check the help output for your installed version if the option is rejected:
dbt --help
dbt parse --help
Disabling partial parsing for a command does not necessarily remove the cache file permanently. It tells dbt not to use partial parsing for that invocation. If you want to reset the saved state itself, delete the file or use dbt clean.
Does dbt Clean Clear Warehouse Query Caches?
No. dbt clean operates on project files and configured cleanup paths. It does not clear cached query results maintained by a data warehouse, cloud platform, or BI tool. For example, a dashboard may display an old result because the reporting tool has its own refresh schedule or cache settings.
If dbt has successfully built the expected table but you still see outdated values, check the data platform and reporting tool separately. Depending on your environment, you may need to refresh a dashboard, change a query-result caching setting, wait for a warehouse cache to expire, or run a query that confirms the current table contents. The appropriate action depends on the platform.
Also distinguish a stale result from a stale model definition. If the compiled SQL is outdated, investigate project parsing and compilation. If the compiled SQL is correct but the warehouse table is old, investigate whether the model ran successfully, which target it used, and whether you are looking at the expected database and schema.
When a Full Refresh Is—and Is Not—Appropriate
A full refresh is not the same as clearing a dbt cache. For an incremental model, --full-refresh asks dbt to rebuild the model rather than applying only its incremental logic. Use it when you have a specific reason to recreate an incremental model’s data, and follow your team’s procedures for production workloads.
dbt run --full-refresh --select my_incremental_model
This can involve substantial warehouse work, such as dropping and recreating a relation or processing a large amount of data, depending on the adapter, materialization, and project configuration. It is usually excessive if your only concern is a local partial-parsing file.
Similarly, deleting the target directory does not automatically rebuild every warehouse object. It removes local generated files; the next dbt command determines what work is performed.
Clearing Cache in dbt Cloud and Team Environments
In dbt Cloud, the same general distinction applies: local or environment-generated project files are different from warehouse and dashboard caches. If you have access to a dbt Cloud command line or IDE terminal, you may be able to run dbt clean in the project environment. The available workflow depends on the product interface, job setup, and permissions.
For a scheduled job that behaves unexpectedly, first review its logs, Git commit, target, environment variables, and dbt version. A local cache reset cannot fix a job that is checking out a different branch, using different variables, or connecting to another environment. Avoid changing shared job settings or deleting shared resources unless you understand the impact.
For team projects, agree on the cleanup approach before modifying custom directories. A command that is harmless in a developer’s working copy could remove files another process relies on if the project configuration has been customized.
A Safe Troubleshooting Sequence
Use this sequence to narrow down the cause without doing more cleanup than necessary:
- Confirm which project directory and dbt environment you are using.
- Check the command output and logs for parsing, compilation, connection, or execution errors.
- Run
dbt parse --no-partial-parseif your dbt version supports it. - If that resolves the parsing issue, remove
target/partial_parse.msgpackor rundbt clean. - If packages were removed, run
dbt depsto install them again. - Run the intended dbt command and confirm that it targets the expected environment.
- If warehouse data or a dashboard remains outdated, investigate the model run and the platform’s own cache separately.
Keep in mind that clearing a cache will not repair every kind of error. A broken connection, invalid SQL, missing permission, incorrect selector, or failed incremental strategy needs its own fix. If the problem returns immediately, compare the project files, dbt version, adapter version, and environment configuration rather than repeatedly deleting generated files.
Conclusion
For a typical local dbt cache issue, start with dbt clean after checking the paths in clean-targets. If you only want to reset partial parsing, remove target/partial_parse.msgpack, or test a command with --no-partial-parse when your dbt version supports it. Reinstall packages with dbt deps if cleanup removed them.
Most importantly, remember that dbt’s local parsing files, warehouse query caches, and incremental model data are separate things. Choose the fix that matches the symptom, and avoid a full refresh or broad deletion unless you have a clear reason to do it.
Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.