-
Notifications
You must be signed in to change notification settings - Fork 40
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
[Feature] Standardized Marketing Models #146
Open
fivetran-avinash
wants to merge
9
commits into
main
Choose a base branch
from
feature/standardized-marketing-models
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
79b4238
standardized marketing models feature
fivetran-avinash 6660b03
standardized marketing models feature, schema and docs updates
fivetran-avinash 5e02245
syntax
fivetran-avinash 0c8dfbf
run models tweak
fivetran-avinash 30ea8b3
run models tweak
fivetran-avinash 6202477
run models tweak
fivetran-avinash daba056
docs
fivetran-avinash 010945a
dbt_project.yml
fivetran-avinash b83c77b
new changes to bring in unsubscribes, new docs, updated schema
fivetran-avinash 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
There are no files selected for viewing
This file contains 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 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 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.
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 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 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 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
packages: | ||
- local: ../ | ||
- local: ../ |
46 changes: 46 additions & 0 deletions
46
integration_tests/tests/consistency/row_comparisons/consistency_campaigns.sql
This file contains 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,46 @@ | ||
{{ config( | ||
tags="fivetran_validations", | ||
enabled=var('fivetran_validation_tests_enabled', false) | ||
) }} | ||
|
||
-- this test ensures the daily_activity end model matches the prior version | ||
with prod as ( | ||
select * | ||
from {{ target.schema }}_hubspot_prod.hubspot__email_campaigns | ||
), | ||
|
||
dev as ( | ||
select * | ||
from {{ target.schema }}_hubspot_dev.hubspot__email_campaigns | ||
), | ||
|
||
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 |
46 changes: 46 additions & 0 deletions
46
integration_tests/tests/consistency/row_comparisons/consistency_contacts.sql
This file contains 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,46 @@ | ||
{{ config( | ||
tags="fivetran_validations", | ||
enabled=var('fivetran_validation_tests_enabled', false) | ||
) }} | ||
|
||
-- this test ensures the daily_activity end model matches the prior version | ||
with prod as ( | ||
select * | ||
from {{ target.schema }}_hubspot_prod.hubspot__contacts | ||
), | ||
|
||
dev as ( | ||
select * | ||
from {{ target.schema }}_hubspot_dev.hubspot__contacts | ||
), | ||
|
||
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 |
46 changes: 46 additions & 0 deletions
46
integration_tests/tests/consistency/row_comparisons/consistency_email_sends.sql
This file contains 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,46 @@ | ||
{{ config( | ||
tags="fivetran_validations", | ||
enabled=var('fivetran_validation_tests_enabled', false) | ||
) }} | ||
|
||
-- this test ensures the daily_activity end model matches the prior version | ||
with prod as ( | ||
select * | ||
from {{ target.schema }}_hubspot_prod.hubspot__email_sends | ||
), | ||
|
||
dev as ( | ||
select * | ||
from {{ target.schema }}_hubspot_dev.hubspot__email_sends | ||
), | ||
|
||
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 |
21 changes: 21 additions & 0 deletions
21
integration_tests/tests/consistency/row_counts/consistency_campaign_count.sql
This file contains 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,21 @@ | ||
{{ config( | ||
tags="fivetran_validations", | ||
enabled=var('fivetran_validation_tests_enabled', false) | ||
) }} | ||
|
||
-- this test is to make sure the rows counts are the same between versions | ||
with prod as ( | ||
select count(*) as prod_rows | ||
from {{ target.schema }}_hubspot_prod.hubspot__email_campaigns | ||
), | ||
|
||
dev as ( | ||
select count(*) as dev_rows | ||
from {{ target.schema }}_hubspot_dev.hubspot__email_campaigns | ||
) | ||
|
||
-- test will return values and fail if the row counts don't match | ||
select * | ||
from prod | ||
join dev | ||
on prod.prod_rows != dev.dev_rows |
21 changes: 21 additions & 0 deletions
21
integration_tests/tests/consistency/row_counts/consistency_contact_count.sql
This file contains 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,21 @@ | ||
{{ config( | ||
tags="fivetran_validations", | ||
enabled=var('fivetran_validation_tests_enabled', false) | ||
) }} | ||
|
||
-- this test is to make sure the rows counts are the same between versions | ||
with prod as ( | ||
select count(*) as prod_rows | ||
from {{ target.schema }}_hubspot_prod.hubspot__contacts | ||
), | ||
|
||
dev as ( | ||
select count(*) as dev_rows | ||
from {{ target.schema }}_hubspot_dev.hubspot__contacts | ||
) | ||
|
||
-- test will return values and fail if the row counts don't match | ||
select * | ||
from prod | ||
join dev | ||
on prod.prod_rows != dev.dev_rows |
21 changes: 21 additions & 0 deletions
21
integration_tests/tests/consistency/row_counts/consistency_email_send_count.sql
This file contains 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,21 @@ | ||
{{ config( | ||
tags="fivetran_validations", | ||
enabled=var('fivetran_validation_tests_enabled', false) | ||
) }} | ||
|
||
-- this test is to make sure the rows counts are the same between versions | ||
with prod as ( | ||
select count(*) as prod_rows | ||
from {{ target.schema }}_hubspot_prod.hubspot__email_sends | ||
), | ||
|
||
dev as ( | ||
select count(*) as dev_rows | ||
from {{ target.schema }}_hubspot_dev.hubspot__email_sends | ||
) | ||
|
||
-- test will return values and fail if the row counts don't match | ||
select * | ||
from prod | ||
join dev | ||
on prod.prod_rows != dev.dev_rows |
34 changes: 34 additions & 0 deletions
34
models/standardized_models/hubspot__marketing_campaigns_standardized.sql
This file contains 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,34 @@ | ||
{{ config(enabled=(var('hubspot__standardized_marketing_model_enabled', False) | ||
and fivetran_utils.enabled_vars(['hubspot_marketing_enabled','hubspot_email_event_enabled','hubspot_email_event_sent_enabled']))) | ||
}} | ||
|
||
with campaigns as ( | ||
|
||
select * | ||
from {{ ref('hubspot__email_campaigns') }} | ||
), | ||
|
||
standardized as ( | ||
|
||
select | ||
email_campaign_id as campaign_id, | ||
email_campaign_name as campaign_name, | ||
email_campaign_type as campaign_type, | ||
email_campaign_sub_type as campaign_sub_type, | ||
email_campaign_subject as campaign_subject, | ||
coalesce(app_id, content_id) as secondary_id, | ||
cast(null as {{ dbt.type_timestamp() }}) as created_at, | ||
cast(null as {{ dbt.type_timestamp() }}) as updated_at, | ||
total_bounces, | ||
total_clicks, | ||
total_deferrals, | ||
total_deliveries, | ||
total_opens, | ||
cast(null as {{ dbt.type_int() }}) as total_unsubscribes, | ||
total_unique_clicks, | ||
total_unique_opens | ||
from campaigns | ||
) | ||
|
||
select * | ||
from standardized |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not available? It looks like we should have the information to generate unsubscribes from the reference table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They were available, but took some rejiggering of the models to make this work. You can see the updated CHANGELOG for details (will add more in the Height ticket).