From 9abf7ab9c9962c85202b357248fcb1b5f5d62255 Mon Sep 17 00:00:00 2001 From: Michael McLean Date: Wed, 30 Mar 2022 18:12:04 -0500 Subject: [PATCH 1/5] Implement try_cast macro on 'numeric_value' field It's possible for the `numeric_value` field from Klaviyo to contain non-numeric data types, which leads this model to fail because the `sum_revenue_` field expects a numeric type. See [Issue17 in dbt_klaviyo](https://github.com/fivetran/dbt_klaviyo/issues/17) for more detail, This {{ fivetran_utils.try_cast }} macro was recently implemented to solve this issue in the dbt_klaviyo package 0.4.1 release --- models/intermediate/int__daily_klaviyo_user_metrics.sql | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/models/intermediate/int__daily_klaviyo_user_metrics.sql b/models/intermediate/int__daily_klaviyo_user_metrics.sql index a2d59be..44781a6 100644 --- a/models/intermediate/int__daily_klaviyo_user_metrics.sql +++ b/models/intermediate/int__daily_klaviyo_user_metrics.sql @@ -21,7 +21,9 @@ with events as ( -- sum up the numeric value associated with events (most likely will mean revenue) {% for rm in var('klaviyo__sum_revenue_metrics') %} - , sum(case when lower(type) = '{{ rm | lower }}' then numeric_value else 0 end) + , sum(case when lower(type) = '{{ rm | lower }}' then + coalesce({{ fivetran_utils.try_cast("numeric_value", "numeric") }}, 0) + else 0 end) as {{ 'sum_revenue_' ~ rm | replace(' ', '_') | replace('(', '') | replace(')', '') | lower }} -- removing special characters that I have seen in different integration events {% endfor %} @@ -37,4 +39,4 @@ with events as ( -- the grain will be person-flow-campaign-variation-day select * -from pivot_out_events \ No newline at end of file +from pivot_out_events From 5de47f37399562b08875adad4db27daf065d201f Mon Sep 17 00:00:00 2001 From: Michael McLean Date: Wed, 30 Mar 2022 18:47:12 -0500 Subject: [PATCH 2/5] updated version number --- dbt_project.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbt_project.yml b/dbt_project.yml index db3bc3e..0def78d 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -1,5 +1,5 @@ name: 'shopify_holistic_reporting' -version: '0.1.0' +version: '0.1.1' config-version: 2 require-dbt-version: [">=1.0.0", "<2.0.0"] @@ -43,4 +43,4 @@ vars: - 'Placed Order' - 'Ordered Product' - 'checkout started' - - 'cancelled order' \ No newline at end of file + - 'cancelled order' From 61cf445d049a320f08c2a4f566b2bfb5b1e8a2b6 Mon Sep 17 00:00:00 2001 From: Michael McLean Date: Wed, 30 Mar 2022 18:47:40 -0500 Subject: [PATCH 3/5] updated version number --- integration_tests/dbt_project.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_tests/dbt_project.yml b/integration_tests/dbt_project.yml index e66d8c5..8617bc1 100644 --- a/integration_tests/dbt_project.yml +++ b/integration_tests/dbt_project.yml @@ -1,5 +1,5 @@ name: 'shopify_holistic_reporting_integration_tests' -version: '0.1.0' +version: '0.1.1' profile: 'integration_tests' config-version: 2 @@ -149,4 +149,4 @@ seeds: event: +column_types: flow_id: "{{ 'string' if target.type in ('bigquery', 'spark') else 'varchar' }}" - campaign_id: "{{ 'string' if target.type in ('bigquery', 'spark') else 'varchar' }}" \ No newline at end of file + campaign_id: "{{ 'string' if target.type in ('bigquery', 'spark') else 'varchar' }}" From 3eacef7220220461be35a68c50c8d2d9af4754be Mon Sep 17 00:00:00 2001 From: Michael McLean Date: Wed, 30 Mar 2022 18:55:06 -0500 Subject: [PATCH 4/5] updated log --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8373db..69a7c44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# dbt_shopify_holistic_reporting v0.1.1 +Bug Fixes +Incorporate the try_cast macro from fivetran_utils to ensure that the numeric_value field in int__daily_klaviyo_user_metrics is the same data type as '0'. + + # dbt_shopify_holistic_reporting v0.1.0 The original release! This package currently models Shopify and Klaviyo data to achieve the following: @@ -5,4 +10,4 @@ The original release! This package currently models Shopify and Klaviyo data to - Consolidate customers, their information, and activity across platforms. - Create a rich portrait of customer personas based on how customers are engaging with and responding to specific marketing efforts. -This package works off of dependencies on Fivetran's individual [Shopify](https://github.com/fivetran/dbt_shopify) and [Klaviyo](https://github.com/fivetran/dbt_klaviyo) dbt packages. \ No newline at end of file +This package works off of dependencies on Fivetran's individual [Shopify](https://github.com/fivetran/dbt_shopify) and [Klaviyo](https://github.com/fivetran/dbt_klaviyo) dbt packages. From 321eee8626e0438bd23a1e0d082a04642295a2b6 Mon Sep 17 00:00:00 2001 From: fivetran-joemarkiewicz Date: Wed, 4 May 2022 16:40:32 -0500 Subject: [PATCH 5/5] added contibutor section to CHANGELOG --- CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69a7c44..72b63a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # dbt_shopify_holistic_reporting v0.1.1 -Bug Fixes -Incorporate the try_cast macro from fivetran_utils to ensure that the numeric_value field in int__daily_klaviyo_user_metrics is the same data type as '0'. +## Bug Fixes +Incorporate the try_cast macro from fivetran_utils to ensure that the numeric_value field in int__daily_klaviyo_user_metrics is the same data type as '0'. ([#6](https://github.com/fivetran/dbt_shopify_holistic_reporting/pull/6)) + +## Contributors +- [@MisterClean](https://github.com/MisterClean) ([#6](https://github.com/fivetran/dbt_shopify_holistic_reporting/pull/6)) # dbt_shopify_holistic_reporting v0.1.0