Skip to content

Commit

Permalink
validation tests + docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fivetran-avinash committed Aug 27, 2024
1 parent 1cc9b03 commit 712dab3
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 19 deletions.
12 changes: 5 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# dbt_shopify v0.13.1
## Bug Fixes
- Coalesces the `backfill_lifetime_sums` fields from incremental loads, as well as `cohort_month_number` in the rare cases there are no orders from an incremental period. This fixes the issue of NULL values in the lifetime columns in `shopify__customer_cohorts` table. ([PR #86](https://github.com/fivetran/dbt_shopify/pull/86)).

## 🪲 Bug Fixes 🪛
- Coalesces the previous lifetimes fields from incremental loads. This fixes the issue of NULL values in the lifetime columns in `shopify__customer_cohorts` table. ([PR #86](https://github.com/fivetran/dbt_shopify/pull/86)).

## 🚘 Under the Hood 🚘
- Coalesces `backfill_lifetime_sums` columns
- Coalesces `windows` columns in a rare case where there are no orders in an incremental period
## Under the Hood:
- Added consistency and integrity tests within `integration_tests` for the `shopify__customer_cohorts` model.

## Contributors
- [@advolut-team](https://github.com/advolut-team) ([PR #86](https://github.com/fivetran/dbt_shopify/pull/86))
Expand All @@ -18,7 +16,7 @@
- This model is currently disabled by default. You may enable it by setting the `shopify__standardized_billing_model_enabled` as `true` in your `dbt_project.yml`.

## Under the Hood:
- Added consistency test within integration_tests for the `stripe__line_item_enhanced` model.
- Added consistency test within integration_tests for the `shopify__line_item_enhanced` model.

# dbt_shopify v0.12.2

Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/manifest.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/run_results.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions integration_tests/ci/sample.profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ integration_tests:
pass: "{{ env_var('CI_REDSHIFT_DBT_PASS') }}"
dbname: "{{ env_var('CI_REDSHIFT_DBT_DBNAME') }}"
port: 5439
schema: shopify_integration_tests_10
schema: shopify_integration_tests_11
threads: 8
bigquery:
type: bigquery
method: service-account-json
project: 'dbt-package-testing'
schema: shopify_integration_tests_10
schema: shopify_integration_tests_11
threads: 8
keyfile_json: "{{ env_var('GCLOUD_SERVICE_KEY') | as_native }}"
snowflake:
Expand All @@ -33,7 +33,7 @@ integration_tests:
role: "{{ env_var('CI_SNOWFLAKE_DBT_ROLE') }}"
database: "{{ env_var('CI_SNOWFLAKE_DBT_DATABASE') }}"
warehouse: "{{ env_var('CI_SNOWFLAKE_DBT_WAREHOUSE') }}"
schema: shopify_integration_tests_10
schema: shopify_integration_tests_11
threads: 8
postgres:
type: postgres
Expand All @@ -42,13 +42,13 @@ integration_tests:
pass: "{{ env_var('CI_POSTGRES_DBT_PASS') }}"
dbname: "{{ env_var('CI_POSTGRES_DBT_DBNAME') }}"
port: 5432
schema: shopify_integration_tests_10
schema: shopify_integration_tests_11
threads: 8
databricks:
catalog: "{{ env_var('CI_DATABRICKS_DBT_CATALOG') }}"
host: "{{ env_var('CI_DATABRICKS_DBT_HOST') }}"
http_path: "{{ env_var('CI_DATABRICKS_DBT_HTTP_PATH') }}"
schema: shopify_integration_tests_10
schema: shopify_integration_tests_11
threads: 8
token: "{{ env_var('CI_DATABRICKS_DBT_TOKEN') }}"
type: databricks
Expand Down
6 changes: 3 additions & 3 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ clean-targets: # directories to be removed by `dbt clean`
- "dbt_modules"

vars:
# shopify_using_fulfillment_event: true # set to true when regenerating docs
# shopify_using_all_metafields: true # set to true when regenerating docs
shopify_schema: shopify_integration_tests_10
shopify_using_fulfillment_event: true # set to true when regenerating docs
shopify_using_all_metafields: true # set to true when regenerating docs
shopify_schema: shopify_integration_tests_11
shopify_source:
shopify_customer_identifier: "shopify_customer_data"
shopify_order_line_refund_identifier: "shopify_order_line_refund_data"
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/packages.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
packages:
- local: ../
- local: ../
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{{ config(
tags="fivetran_validations",
enabled=var('fivetran_validation_tests_enabled', false)
) }}

with prod as (

select
customer_cohort_id,
source_relation,
total_price_lifetime,
order_count_lifetime,
line_item_count_lifetime
from {{ target.schema }}_shopify_prod.shopify__customer_cohorts
),

dev as (

select
customer_cohort_id,
source_relation,
total_price_lifetime,
order_count_lifetime,
line_item_count_lifetime
from {{ target.schema }}_shopify_dev.shopify__customer_cohorts
),

final as (

select
prod.customer_cohort_id as prod_customer_cohort_id,
dev.customer_cohort_id as dev_customer_cohort_id,
prod.source_relation as prod_source_relation,
dev.source_relation as dev_source_relation,
prod.total_price_lifetime as prod_total_price_lifetime,
dev.total_price_lifetime as dev_total_price_lifetime,
prod.order_count_lifetime as prod_order_count_lifetime,
dev.order_count_lifetime as dev_order_count_lifetime,
prod.line_item_count_lifetime as prod_line_item_count_lifetime,
dev.line_item_count_lifetime as dev_line_item_count_lifetime
from prod
full outer join dev
on dev.customer_cohort_id = prod.customer_cohort_id
and dev.source_relation = prod.source_relation
)

select *
from final
where
prod_customer_cohort_id != dev_customer_cohort_id or
prod_source_relation != dev_source_relation or
abs(prod_total_price_lifetime - dev_total_price_lifetime) > .001 or
abs(prod_order_count_lifetime - dev_order_count_lifetime) > .001 or
abs(prod_line_item_count_lifetime - dev_line_item_count_lifetime) > .001
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{ config(
tags="fivetran_validations",
enabled=var('fivetran_validation_tests_enabled', false)
) }}

with calendar as (

select *
from {{ ref('shopify__calendar') }}
where cast({{ dbt.date_trunc('month','date_day') }} as date) = date_day

),

customers as (

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

),

orders as (

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

),

customer_cohort_source as (

select
customers.source_relation,
count(*) as source_rows
from calendar
inner join customers
on cast({{ dbt.date_trunc('month', 'first_order_timestamp') }} as date) <= calendar.date_day
group by 1
),

customer_cohort_end as (

select
source_relation,
count(*) as end_rows
from {{ ref('shopify__customer_cohorts') }}
group by 1
),

final as (
select
customer_cohort_source.source_relation,
source_rows,
end_rows
from customer_cohort_source
join customer_cohort_end
on customer_cohort_source.source_relation = customer_cohort_end.source_relation
where customer_cohort_source.source_rows != customer_cohort_end.end_rows
)

select *
from final

0 comments on commit 712dab3

Please sign in to comment.