Skip to content

Commit

Permalink
Merge pull request #116 from dbt-labs/feat/snapshots_refactor
Browse files Browse the repository at this point in the history
Refactor snapshots to new method as of dbt core 1.9
  • Loading branch information
faithebear authored Nov 8, 2024
2 parents f348361 + 833d85c commit 281c438
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
with order_snapshot as (
{# with order_snapshot as (
select
* exclude dbt_valid_to,
coalesce(dbt_valid_to, cast('{{ var("future_proof_date") }}' as timestamp)) as dbt_valid_to
Expand Down Expand Up @@ -47,3 +47,4 @@ final as (
)

select * from final
#}
14 changes: 0 additions & 14 deletions snapshots/_samples/example_generate_schema_snapshot.sql

This file was deleted.

14 changes: 0 additions & 14 deletions snapshots/_samples/example_orders_line_items_snapshot.sql

This file was deleted.

14 changes: 0 additions & 14 deletions snapshots/_samples/example_orders_snapshot.sql

This file was deleted.

51 changes: 51 additions & 0 deletions snapshots/jaffle_snapshots.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: 2

snapshots:
# This is a pretty standard snapshot
- name: snapshot_stg_payments
relation: source('stripe', 'payment')
config:
enabled: true
strategy: timestamp
updated_at: _BATCHED_AT
unique_key: ID
persist_docs:
relation: true
columns: true
# Another standard snapshot but this time with a different table.
- name: snapshot_example_orders
relation: ref('example_orders_source_for_snapshot')
config:
enabled: true
strategy: timestamp
updated_at: order_updated_at
unique_key: order_id
persist_docs:
relation: true
columns: true
invalidate_hard_deletes: true

# This snapshot has the check_cols example
- name: snapshot_int_line_items
relation: ref('int_line_items_amounts_calculated')
config:
enabled: true
strategy: check
check_cols: ['gross_item_sales_amount', 'net_item_sales_amount']
unique_key: order_item_id
persist_docs:
relation: true
columns: true
# This snapshot has invalidate hard deletes as an example
- name: snapshot_orders_line_items
relation: ref('example_orders_line_items_source_for_snapshot')
config:
enabled: true
strategy: timestamp
unique_key: id
updated_at: order_updated_at
invalidate_hard_deletes: true
persist_docs:
relation: true
columns: true

22 changes: 0 additions & 22 deletions snapshots/snapshot_int_line_items.sql

This file was deleted.

16 changes: 0 additions & 16 deletions snapshots/snapshot_stg_payments.sql

This file was deleted.

0 comments on commit 281c438

Please sign in to comment.