Snapshot properties
Snapshots properties can be declared in .yml
files in:
- your
snapshots/
directory (as defined by thesnapshot-paths
config) - your
models/
directory (as defined by themodel-paths
config)
We recommend that you put them in the snapshots/
directory. You can name these files whatever_you_want.yml
, and nest them arbitrarily deeply in subfolders within the snapshots/
or models/
directory.
version: 2
snapshots:
- name: <snapshot name>
description: <markdown_string>
meta: {<dictionary>}
docs:
show: true | false
node_color: <color_id> # Use name (such as node_color: purple) or hex code with quotes (such as node_color: "#cd7f32")
config:
<snapshot_config>: <config_value>
tests:
- <test>
- ...
columns:
- name: <column name>
description: <markdown_string>
meta: {<dictionary>}
quote: true | false
tags: [<string>]
tests:
- <test>
- ... # declare additional tests
- ... # declare properties of additional columns
- name: ... # declare properties of additional snapshots
Define snapshots in YAML
Defining a snapshot in YAML treats snapshots as a distinct resource type, separate from models, allowing for improved organization and consistency within your code.
They don't contain logic, similar to exposures, sources, and tests. To add extra logic to your snapshot, you can break it out into an ephemeral model for cleaner development and testing, and then create a snapshot of that model.
# snapshots/my_snapshots.yml
snapshots:
- name: orders_snapshot
relation: source('jaffle_shop', 'orders')
config:
schema: snapshots
database: analytics
unique_key: id
strategy: timestamp
updated_at: updated_at
In this example, the snapshot configuration tracks changes to the orders table over time. The transformation in this snapshot is: select * from {{ source('jaffle_shop', 'orders') }}
.