-
Notifications
You must be signed in to change notification settings - Fork 6
feature/add-journey-models #84
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
Merged
+521
−8
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8b872bc
feature/add-journey-models
fivetran-savage 4b4c717
Generate dbt docs via GitHub Actions
fivetran-data-model-bot 40c8f71
add_data_to_vars
fivetran-savage 19cefcd
remove_rate_calculations
fivetran-savage 0a66a53
Generate dbt docs via GitHub Actions
fivetran-data-model-bot db35e6c
update_readme
fivetran-savage 902d896
Merge branch 'feature/add-journey-models' of https://github.com/fivet…
fivetran-savage 8b60017
Apply batched suggestions from code review
fivetran-savage a7793eb
update_yml
fivetran-savage 3c0c059
Generate dbt docs via GitHub Actions
fivetran-data-model-bot 6d773e9
Apply batched suggestions from code review
fivetran-savage 52e2ed5
Generate dbt docs via GitHub Actions
fivetran-data-model-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,3 +74,4 @@ venv.bak/ | |
|
|
||
| # Claude instructions | ||
| CLAUDE.md | ||
| .claude/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| id,name,journey_type,description,creator_user_id,enabled,is_archived,lifetime_limit,simultaneous_limit,start_tile_id,trigger_event_names,created_at,updated_at,_fivetran_deleted,_fivetran_synced,draft_name | ||
| 157274,Welcome Series,Published,Onboarding sequence sent to new subscribers over their first week,jimmy.neutron@goddard.com,true,false,1,1,44001,"[""signUp""]",2021-06-01 09:14:22.000,2021-06-11 13:30:58.412,FALSE,2021-06-11 13:32:03.771,Welcome Series draft | ||
| 28801,Automation,Triggered,Behavioral automation triggered by in-app activity,jimmy.neutron@goddard.com,true,false,5,2,44002,"[""customEvent"",""emailOpen""]",2021-05-18 11:02:47.000,2021-06-09 17:45:10.220,FALSE,2021-06-11 13:32:03.771,Automation draft | ||
| 83250,Workflow - Survey,Blast,Post-purchase survey invitation,carl.wheezer@goddard.com,true,false,,1,44003,"[""purchase""]",2021-04-27 15:39:05.000,2021-06-02 08:21:36.905,FALSE,2021-06-11 13:32:03.771, | ||
| 900001,Audience Split - Dormant Users,Triggered,Splits dormant users into re-engagement branches and updates their profile fields. Sends no messages.,carl.wheezer@goddard.com,false,true,,,44004,[],2021-03-15 10:00:00.000,2021-05-20 12:11:44.310,FALSE,2021-06-11 13:32:03.771, | ||
| 900002,Deleted Journey,Triggered,Journey deleted in the source and excluded from staging output,carl.wheezer@goddard.com,false,false,,,44005,"[""signUp""]",2021-02-08 08:45:12.000,2021-04-02 16:20:31.118,TRUE,2021-06-11 13:32:03.771, |
51 changes: 51 additions & 0 deletions
51
integration_tests/tests/consistency/consistency_journeys.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| {{ config( | ||
| tags="fivetran_validations", | ||
| enabled=var('fivetran_validation_tests_enabled', false) | ||
| ) }} | ||
|
|
||
| {% set exclude_cols = ['trigger_event_names'] + var('consistency_test_exclude_metrics', []) %} | ||
| {% set fields = dbt_utils.star(from=ref('iterable__journeys'), except=exclude_cols) %} | ||
|
|
||
| -- this test ensures the iterable__journeys end model matches the prior version | ||
| with prod as ( | ||
| select {{ fields }} | ||
| from {{ target.schema }}_iterable_prod.iterable__journeys | ||
| where date(updated_at) < date({{ dbt.current_timestamp() }}) | ||
| ), | ||
|
|
||
| dev as ( | ||
| select {{ fields }} | ||
| from {{ target.schema }}_iterable_dev.iterable__journeys | ||
| where date(updated_at) < date({{ dbt.current_timestamp() }}) | ||
| ), | ||
|
|
||
| prod_not_in_dev as ( | ||
| -- rows from prod not found in dev | ||
| select * from prod | ||
| except distinct | ||
| select * from dev | ||
| ), | ||
|
|
||
| dev_not_in_prod as ( | ||
| -- rows from dev not found in prod | ||
| select * from dev | ||
| except distinct | ||
| select * from prod | ||
| ), | ||
|
|
||
| final as ( | ||
| select | ||
| *, | ||
| 'from prod' as source | ||
| from prod_not_in_dev | ||
|
|
||
| union all -- union since we only care if rows are produced | ||
|
|
||
| select | ||
| *, | ||
| 'from dev' as source | ||
| from dev_not_in_prod | ||
| ) | ||
|
|
||
| select * | ||
| from final |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| {% macro get_journey_columns() %} | ||
|
|
||
| {% set columns = [ | ||
| {"name": "_fivetran_deleted", "datatype": "boolean"}, | ||
| {"name": "_fivetran_synced", "datatype": dbt.type_timestamp()}, | ||
| {"name": "created_at", "datatype": dbt.type_timestamp()}, | ||
| {"name": "creator_user_id", "datatype": dbt.type_string()}, | ||
| {"name": "description", "datatype": dbt.type_string()}, | ||
| {"name": "enabled", "datatype": "boolean"}, | ||
| {"name": "id", "datatype": dbt.type_int()}, | ||
| {"name": "is_archived", "datatype": "boolean"}, | ||
| {"name": "journey_type", "datatype": dbt.type_string()}, | ||
| {"name": "lifetime_limit", "datatype": dbt.type_int()}, | ||
| {"name": "name", "datatype": dbt.type_string()}, | ||
| {"name": "simultaneous_limit", "datatype": dbt.type_int()}, | ||
| {"name": "start_tile_id", "datatype": dbt.type_int()}, | ||
| {"name": "trigger_event_names", "datatype": dbt.type_string()}, | ||
| {"name": "updated_at", "datatype": dbt.type_timestamp()} | ||
| ] %} | ||
|
|
||
| {{ fivetran_utils.add_pass_through_columns(columns, var('iterable_journey_pass_through_columns')) }} | ||
|
|
||
| {{ return(columns) }} | ||
|
|
||
| {% endmacro %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
models/intermediate/int_iterable__journey_event_metrics.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| {{ config(enabled=var('iterable__using_journey', True)) }} | ||
|
|
||
| with user_campaign as ( | ||
| select * | ||
| from {{ ref('iterable__user_campaign') }} | ||
|
|
||
| ), campaign as ( | ||
|
|
||
| select | ||
| source_relation, | ||
| campaign_id, | ||
| journey_id | ||
|
|
||
| from {{ ref('int_iterable__recurring_campaigns') }} | ||
| where journey_id is not null | ||
|
|
||
| ), journey_event_metrics as ( | ||
| {%- set user_campaign_columns = adapter.get_columns_in_relation(ref('iterable__user_campaign')) %} | ||
| {%- set non_agg_columns = ['source_relation', 'unique_user_key', 'user_id', '_fivetran_user_id', | ||
| 'user_email', 'user_full_name', 'campaign_id', 'campaign_name', 'recurring_campaign_id', | ||
| 'recurring_campaign_name', 'first_event_at', 'last_event_at', 'template_id', 'template_name', | ||
| 'experiment_id', 'unique_user_campaign_id', 'first_open_or_click_event_at' | ||
| ] %} | ||
|
|
||
| select | ||
| campaign.source_relation, | ||
| campaign.journey_id, | ||
| count(distinct user_campaign.campaign_id) as count_total_campaigns, | ||
| count(distinct user_campaign.unique_user_key) as count_unique_users, | ||
| min(user_campaign.first_event_at) as first_event_at, | ||
| max(user_campaign.last_event_at) as last_event_at | ||
| {% for col in user_campaign_columns if col.name|lower not in non_agg_columns %} | ||
| , sum(user_campaign.{{ col.name }}) as {{ col.name }} | ||
| -- counts distinct users; campaign_event_metrics counts distinct emails | ||
| , count(distinct case when user_campaign.{{ col.name }} > 0 then user_campaign.unique_user_key else null end) as unique_{{ col.name }} | ||
| {% endfor %} | ||
|
|
||
| from user_campaign | ||
|
|
||
| inner join campaign | ||
| on user_campaign.campaign_id = campaign.campaign_id | ||
| and user_campaign.source_relation = campaign.source_relation | ||
|
|
||
| {{ dbt_utils.group_by(n=2) }} | ||
| ) | ||
|
|
||
| select * | ||
| from journey_event_metrics |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.