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

Upgrade stg user history to an incremental model #38

Open
wants to merge 4 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# dbt_iterable_source v0.9.1
[PR #38](https://github.com/fivetran/dbt_iterable_source/pull/38) contains the following updates:

## Feature Updates
- Updated the `stg_iterable__user_history` model to be incremental. No new columns were introduced in this change.

# dbt_iterable_source v0.9.0
[PR #31](https://github.com/fivetran/dbt_iterable_source/pull/31) contains the following updates:

Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
config-version: 2
name: 'iterable_source'

version: '0.9.0'
version: '0.9.1'
require-dbt-version: [">=1.3.0", "<2.0.0"]

models:
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
config-version: 2
name: 'iterable_source_integration_tests'

version: '0.9.0'
version: '0.9.1'
profile: 'integration_tests'

vars:
Expand Down
12 changes: 12 additions & 0 deletions models/stg_iterable__user_history.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
{{ config(
materialized='incremental',
unique_key=['_fivetran_user_id','updated_at'],
incremental_strategy='insert_overwrite' if target.type in ('bigquery', 'spark', 'databricks') else 'delete+insert',
partition_by={"field": "updated_at", "data_type": "date"} if target.type not in ('spark','databricks') else ['updated_at'],
file_format='parquet',
on_schema_change='fail'
)
}}

with base as (

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

{% if is_incremental() %}
where updated_at >= coalesce((select max(updated_at) from {{ this }} ), '2010-01-01')
{% endif %}
),

fields as (
Expand Down