-
Notifications
You must be signed in to change notification settings - Fork 41
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
Releases/v0.12.latest #82
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
df5e496
Update shopify__daily_shop.sql
shreveasaurus 89f0b09
Bump package version
shreveasaurus f271d18
Update CHANGELOG.md
shreveasaurus 1baf570
Bump project version
shreveasaurus 946f7b4
Update link to PR in changelog
shreveasaurus 7a4acbd
Merge pull request #81 from shreveasaurus/shreveasaurus-patch-1
fivetran-jamie ea6bbb1
testing
fivetran-jamie 577d6dc
validation tests
fivetran-jamie 7bcf0de
docs
fivetran-jamie c6a1690
joe feedback
fivetran-jamie 67157bb
change package ref
fivetran-jamie 92a83ad
avinash feedback
fivetran-jamie 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
id,_fivetran_synced,address_1,city,country,created_at,estimated_delivery_at,fulfillment_id,happened_at,latitude,longitude,message,order_id,province,shop_id,status,updated_at,zip,_fivetran_deleted | ||
451435,2022-11-18 04:39:07.945000,,,,2022-08-29 20:52:39.000000,,40495,2022-08-29 20:52:39.000000,,,,4502987,,89440612,delivered,2022-08-29 20:52:39.000000,,false | ||
48779,2022-11-18 05:48:01.773000,,LONDON,GB,2022-09-13 08:07:57.000000,,4064737,2022-08-15 12:41:00.000000,101.349998474121094,-14.0333000011742115,Delay,4588203,,320612,out_for_delivery,2022-09-13 08:07:57.000000,CR0,false | ||
1481515,2022-11-18 05:41:00.745000,,ECHO PARK,AU,2022-09-14 14:16:52.000000,2022-09-14 08:00:00.000000,4019339,2022-09-14 01:26:00.000000,-3.797698974609375,190.783958203125,Delay,451915,,89320612,out_for_delivery,2022-09-14 14:16:52.000000,2759,false | ||
1481515,2022-11-18 05:41:00.745000,,ECHO PARK,AU,2022-09-14 14:16:52.000000,2022-09-14 08:00:00.000000,4019339,2022-09-14 01:26:00.000000,-3.797698974609375,190.783958203125,Delay,451915,,89320612,delayed,2022-09-14 14:16:52.000000,2759,false | ||
558955,2022-11-18 10:51:24.286000,,LAZYTOWN,US,2022-08-13 12:40:26.000000,,402947,2022-03-01 10:36:39.000000,22.337699890136719,-71.731002807617188,Delay,429188587,MA,89420612,in_transit,2022-08-13 12:40:26.000000,01505,false | ||
6904235,2022-11-18 08:58:00.458000,,LA,US,2022-08-24 06:29:21.000000,2022-08-24 23:59:59.000000,4060491,2022-08-24 05:30:57.000000,12.287498474121094,-21.3573989868164,Delay,4242667,MA,89420612,in_transit,2022-08-24 06:29:21.000000,01760,false |
91 changes: 91 additions & 0 deletions
91
integration_tests/tests/consistency/consistency_daily_shop.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,91 @@ | ||
{{ config( | ||
tags="fivetran_validations", | ||
enabled=var('fivetran_validation_tests_enabled', false) | ||
) }} | ||
|
||
with prod as ( | ||
select | ||
date_day, | ||
shop_id, | ||
source_relation, | ||
sum(count_orders) as count_orders, | ||
count(count_customers) as count_customers, | ||
sum(order_adjusted_total) as order_adjusted_total, | ||
sum(count_abandoned_checkouts) as count_abandoned_checkouts | ||
|
||
{% if var('shopify_using_fulfillment_event', false) %} | ||
, sum(count_fulfillment_attempted_delivery) as count_fulfillment_attempted_delivery | ||
, sum(count_fulfillment_confirmed) as count_fulfillment_confirmed | ||
, count(count_fulfillment_in_transit) as count_fulfillment_in_transit | ||
{% endif %} | ||
|
||
from {{ target.schema }}_shopify_prod.shopify__daily_shop | ||
group by 1,2,3 | ||
), | ||
|
||
dev as ( | ||
select | ||
date_day, | ||
shop_id, | ||
source_relation, | ||
sum(count_orders) as count_orders, | ||
count(count_customers) as count_customers, | ||
sum(order_adjusted_total) as order_adjusted_total, | ||
sum(count_abandoned_checkouts) as count_abandoned_checkouts | ||
|
||
{% if var('shopify_using_fulfillment_event', false) %} | ||
, sum(count_fulfillment_attempted_delivery) as count_fulfillment_attempted_delivery | ||
, sum(count_fulfillment_confirmed) as count_fulfillment_confirmed | ||
, count(count_fulfillment_in_transit) as count_fulfillment_in_transit | ||
{% endif %} | ||
|
||
from {{ target.schema }}_shopify_dev.shopify__daily_shop | ||
group by 1,2,3 | ||
), | ||
|
||
final as ( | ||
select | ||
prod.date_day as prod_date_day, | ||
dev.date_day as dev_date_day, | ||
prod.shop_id as prod_shop_id, | ||
dev.shop_id as dev_shop_id, | ||
prod.source_relation as prod_source_relation, | ||
dev.source_relation as dev_source_relation, | ||
prod.count_orders as prod_count_orders, | ||
dev.count_orders as dev_count_orders, | ||
prod.count_customers as prod_count_customers, | ||
dev.count_customers as dev_count_customers, | ||
prod.order_adjusted_total as prod_order_adjusted_total, | ||
dev.order_adjusted_total as dev_order_adjusted_total, | ||
prod.count_abandoned_checkouts as prod_count_abandoned_checkouts, | ||
dev.count_abandoned_checkouts as dev_count_abandoned_checkouts | ||
|
||
{% if var('shopify_using_fulfillment_event', false) %} | ||
, prod.count_fulfillment_attempted_delivery as prod_count_fulfillment_attempted_delivery | ||
, dev.count_fulfillment_attempted_delivery as dev_count_fulfillment_attempted_delivery | ||
, prod.count_fulfillment_confirmed as prod_count_fulfillment_confirmed | ||
, dev.count_fulfillment_confirmed as dev_count_fulfillment_confirmed | ||
{% endif %} | ||
|
||
from prod | ||
full outer join dev | ||
on dev.date_day = prod.date_day | ||
and dev.shop_id = prod.shop_id | ||
and dev.source_relation = prod.source_relation | ||
) | ||
|
||
select * | ||
from final | ||
where | ||
prod_date_day != dev_date_day or | ||
prod_shop_id != dev_shop_id or | ||
prod_source_relation != dev_source_relation or | ||
abs(prod_count_orders - dev_count_orders) > .001 or | ||
abs(prod_count_customers - dev_count_customers) > .001 or | ||
abs(prod_order_adjusted_total - dev_order_adjusted_total) > .001 or | ||
abs(prod_count_abandoned_checkouts - dev_count_abandoned_checkouts) > .001 | ||
|
||
{% if var('shopify_using_fulfillment_event', false) %} | ||
or abs(prod_count_fulfillment_attempted_delivery - dev_count_fulfillment_attempted_delivery) > .001 | ||
or abs(prod_count_fulfillment_confirmed - dev_count_fulfillment_confirmed) > .001 | ||
{% endif %} |
63 changes: 63 additions & 0 deletions
63
integration_tests/tests/integrity/horizontal_integrity_daily_shop_orders.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,63 @@ | ||
{{ config( | ||
tags="fivetran_validations", | ||
enabled=var('fivetran_validation_tests_enabled', false) | ||
) }} | ||
|
||
with orders as ( | ||
|
||
select * | ||
from {{ ref('shopify__orders') }} | ||
), | ||
|
||
order_metrics as ( | ||
|
||
select | ||
source_relation, | ||
cast({{ dbt.date_trunc('day','created_timestamp') }} as date) as date_day, | ||
count(distinct order_id) as count_orders, | ||
sum(order_adjusted_total) as order_adjusted_total | ||
|
||
from orders | ||
where created_timestamp > '2020-01-01' and created_timestamp < '2024-06-10' | ||
group by 1,2 | ||
), | ||
|
||
daily_shop as ( | ||
|
||
select * | ||
from {{ ref('shopify__daily_shop') }} | ||
), | ||
|
||
daily_shop_metrics as ( | ||
|
||
select | ||
source_relation, | ||
date_day, | ||
sum(count_orders) as count_orders, | ||
sum(order_adjusted_total) as order_adjusted_total | ||
|
||
from daily_shop | ||
where date_day >= '2020-01-01' and date_day < '2024-06-10' | ||
group by 1,2 | ||
), | ||
|
||
final as ( | ||
|
||
select | ||
daily_shop_metrics.source_relation, | ||
coalesce(daily_shop_metrics.count_orders, 0) as daily_shop_count_orders, | ||
coalesce(order_metrics.count_orders, 0) as order_count_orders, | ||
coalesce(daily_shop_metrics.order_adjusted_total, 0) as daily_shop_order_adjusted_total, | ||
coalesce(order_metrics.order_adjusted_total, 0) as order_order_adjusted_total | ||
|
||
from daily_shop_metrics | ||
full outer join order_metrics | ||
on daily_shop_metrics.source_relation = order_metrics.source_relation | ||
and daily_shop_metrics.date_day = order_metrics.date_day | ||
) | ||
|
||
select * | ||
from final | ||
where | ||
abs(daily_shop_count_orders - order_count_orders) > 0 or | ||
abs(daily_shop_order_adjusted_total - order_order_adjusted_total) > .1 |
81 changes: 81 additions & 0 deletions
81
integration_tests/tests/integrity/vertical_integrity_daily_shop_fulfillment.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,81 @@ | ||
{{ config( | ||
tags="fivetran_validations", | ||
enabled=var('fivetran_validation_tests_enabled', false) | ||
) }} | ||
-- test will only run if shopify_using_fulfillment_event is set to True | ||
|
||
with source as ( | ||
|
||
select * | ||
from {{ ref('stg_shopify__fulfillment_event') }} | ||
), | ||
|
||
source_metrics as ( | ||
|
||
select | ||
source_relation, | ||
cast({{ dbt.date_trunc('day','happened_at') }} as date) as date_day, | ||
shop_id, | ||
count(distinct case when status = 'delayed' then fulfillment_id end) as count_fulfillment_delayed, | ||
count(distinct case when status = 'in_transit' then fulfillment_id end) as count_fulfillment_in_transit, | ||
count(distinct case when status = 'confirmed' then fulfillment_id end) as count_fulfillment_confirmed, | ||
count(distinct case when status = 'delivered' then fulfillment_id end) as count_fulfillment_delivered | ||
|
||
from source | ||
where happened_at > '2020-01-01' and happened_at < '2024-06-10' | ||
group by 1,2,3 | ||
), | ||
|
||
model as ( | ||
|
||
select * | ||
from {{ ref('shopify__daily_shop') }} | ||
), | ||
|
||
model_metrics as ( | ||
|
||
select | ||
source_relation, | ||
date_day, | ||
shop_id, | ||
sum(count_fulfillment_delayed) as count_fulfillment_delayed, | ||
sum(count_fulfillment_in_transit) as count_fulfillment_in_transit, | ||
sum(count_fulfillment_confirmed) as count_fulfillment_confirmed, | ||
sum(count_fulfillment_delivered) as count_fulfillment_delivered | ||
|
||
from model | ||
where date_day >= '2020-01-01' and date_day < '2024-06-10' | ||
group by 1,2,3 | ||
), | ||
|
||
final as ( | ||
|
||
select | ||
model_metrics.source_relation, | ||
model_metrics.shop_id as model_shop_id, | ||
source_metrics.shop_id as source_shop_id, | ||
model_metrics.date_day as model_date_day, | ||
source_metrics.date_day as source_date_day, | ||
coalesce(model_metrics.count_fulfillment_delayed, 0) as model_count_fulfillment_delayed, | ||
coalesce(source_metrics.count_fulfillment_delayed, 0) as source_count_fulfillment_delayed, | ||
coalesce(model_metrics.count_fulfillment_in_transit, 0) as model_count_fulfillment_in_transit, | ||
coalesce(source_metrics.count_fulfillment_in_transit, 0) as source_count_fulfillment_in_transit, | ||
coalesce(model_metrics.count_fulfillment_confirmed, 0) as model_count_fulfillment_confirmed, | ||
coalesce(source_metrics.count_fulfillment_confirmed, 0) as source_count_fulfillment_confirmed, | ||
coalesce(model_metrics.count_fulfillment_delivered, 0) as model_count_fulfillment_delivered, | ||
coalesce(source_metrics.count_fulfillment_delivered, 0) as source_count_fulfillment_delivered | ||
|
||
from model_metrics | ||
full outer join source_metrics | ||
on model_metrics.source_relation = source_metrics.source_relation | ||
and model_metrics.shop_id = source_metrics.shop_id | ||
and model_metrics.date_day = source_metrics.date_day | ||
) | ||
|
||
select * | ||
from final | ||
where | ||
model_count_fulfillment_delayed != source_count_fulfillment_delayed or | ||
model_count_fulfillment_in_transit != source_count_fulfillment_in_transit or | ||
model_count_fulfillment_confirmed != source_count_fulfillment_confirmed or | ||
model_count_fulfillment_delivered != source_count_fulfillment_delivered |
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
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,3 +1,3 @@ | ||
packages: | ||
- package: fivetran/shopify_source | ||
version: [">=0.12.0", "<0.13.0"] | ||
version: [">=0.12.0", "<0.13.0"] |
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.
I'd add your consistency/integrity tests as Under the Hood and that can be the #82 changes.
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.
added!