About dbt snapshot command
The dbt snapshot command executes the Snapshots defined in your project. Snapshots record changes to your source data over time by implementing type-2 Slowly Changing Dimensions. Run dbt snapshot on a schedule (for example, daily) to capture changes in your source tables.
Define snapshots in YAML with a strategy and unique_key; refer to Snapshot configurations for details on how to set them up. You can also run snapshots as part of dbt build.
dbt looks for snapshots in the directories listed in snapshot-paths in your dbt_project.yml file. By default, dbt uses the snapshots/ directory. You can specify multiple paths if you organize snapshots in more than one folder.
Usage
To view the full list of supported options in your terminal, run:
dbt snapshot --help
Use --select or --exclude to choose which snapshots run. For selection syntax, refer to Node selection syntax. For other flags (such as --threads, --target, and logging options), see About flags (global configs).
Starting dbt Core v1.12, you can inspect the SQL generated for this snapshot by running dbt compile or dbt compile --select orders_snapshot.
Open the compiled SQL in target/compiled/ to inspect or debug the generated queries. Each snapshot is compiled into its own SQL file, even if multiple snapshots are defined in the same source file.
Was this page helpful?
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.