Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo/tsa october #90

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ on-run-end:
# to use, and what query tag to provide on the snowflake site.
# These settings can be overridden in the individual model files
# using the `{{ config(...) }}` macro.
tests:
+store_failures: true

models:
my_snowflake_dbt_project:
# When you rename the project up top, remember to rename it here too.
Expand Down
46 changes: 46 additions & 0 deletions models/example/donors.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{{
config(
materialized='table'
)
}}

with source_data as

(
select
1 as donor_id,
'Jack' as donor_name,
to_date('2023-01-01') as updated_dt

union

select
2 as donor_id,
'Jill' as donor_name,
to_date('2023-02-01') as updated_dt

union

select
3 as donor_id,
'Ben' as donor_name,
to_date('2023-02-01') as updated_dt

union

select
4 as donor_id,
'Susie' as donor_name,
to_date('2023-10-03') as updated_dt

union

select
5 as donor_id,
'Katie' as donor_name,
to_date('2023-10-03') as updated_dt

)


select * from source_data
24 changes: 24 additions & 0 deletions models/example/incremental_donors.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{
config(
materialized='incremental',
unique_key='donor_id'
)
}}

with data as

(

select * , current_timestamp() as dbt_update_dt
from {{ ref('donors') }}

{% if is_incremental() %}

where updated_dt >= (select max(updated_dt) from {{ this }})


{% endif %}

)

select * from data
20 changes: 18 additions & 2 deletions models/example/my_first_dbt_model.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,29 @@ with source_data as
(
select
1 as id,
1 / 2 as value
1 / 2 as value,
to_date('2023-01-01') as updated_dt

union

select
2 as id,
2 / 2 as value
2 / 2 as value,
to_date('2023-02-01') as updated_dt

union

select
3 as id,
2 / 2 as value,
to_date('2023-02-01') as updated_dt

union

select
4 as id,
2 / 3 as value,
to_date('2023-10-02') as updated_dt

)

Expand Down
4 changes: 2 additions & 2 deletions models/example/my_incremental_dbt_model.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ with data as

(

select *
select * , current_timestamp() as dbt_update_dt
from {{ ref('my_first_dbt_model') }}

{% if is_incremental() %}

where id >= (select max(id) from {{ this }})
where updated_dt >= (select max(updated_dt) from {{ this }})


{% endif %}
Expand Down
1 change: 0 additions & 1 deletion models/marts/core/dim_customers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ save on storage costs. Non-transient Snowflake objects store the history of the
as idempotent (https://discourse.getdbt.com/t/understanding-idempotent-data-transformations/518)

Full documentation: https://docs.getdbt.com/reference/resource-configs/snowflake-configs#transient-tables

*/

{{
Expand Down
12 changes: 12 additions & 0 deletions snapshots/donor_snapshot.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% snapshot donor_snapshot %}
{{
config(
unique_key='donor_id',
strategy='timestamp' ,
updated_at='updated_dt',
target_schema = 'dbt_kbrock' )
}}

select * from {{ ref('donors') }}

{% endsnapshot %}