From d695e3061d32684abd4b382477b93e16a9deef4c Mon Sep 17 00:00:00 2001 From: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com> Date: Thu, 18 Aug 2022 16:49:07 -0700 Subject: [PATCH 1/5] working --- CHANGELOG.md | 5 +++++ README.md | 3 ++- models/stg_hubspot__ticket_deal.sql | 2 +- models/tmp/stg_hubspot__ticket_deal_tmp.sql | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c244c61..46905a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# dbt_hubspot_source v0.5.8 + +## Features +- Adds `hubspot_ticket_deal_enabled` variable (default value=`False`) to disable modelling and testing of the `ticket_deal` source table. If there are no associations between tickets and deals in your Hubspot environment, this table will not exist. + # dbt_hubspot_source v0.5.7 ## Fixes - Spelling correction of variable names within the README. ([#73](https://github.com/fivetran/dbt_hubspot_source/pull/73)) diff --git a/README.md b/README.md index 873f9c3..c9a23ce 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ vars: ### Disabling models -When setting up your Hubspot connection in Fivetran, it is possible that not every table this package expects will be synced. This can occur because you either don't use that functionality in Hubspot or have actively decided to not sync some tables. In order to disable the relevant functionality in the package, you will need to add the relevant variables. By default, all variables are assumed to be `true` (with exception of `hubspot_service_enabled` and `hubspot_contact_merge_audit_enabled`). You only need to add variables for the tables you would like to disable or enable respectively: +When setting up your Hubspot connection in Fivetran, it is possible that not every table this package expects will be synced. This can occur because you either don't use that functionality in Hubspot or have actively decided to not sync some tables. In order to disable the relevant functionality in the package, you will need to add the relevant variables. By default, all variables are assumed to be `true` (with exception of `hubspot_service_enabled`, `hubspot_ticket_deal_enabled`, and `hubspot_contact_merge_audit_enabled`). You only need to add variables for the tables you would like to disable or enable respectively: ```yml # dbt_project.yml @@ -97,6 +97,7 @@ vars: # Service hubspot_service_enabled: true # Enables all service models + hubspot_ticket_deal_enabled: true ``` diff --git a/models/stg_hubspot__ticket_deal.sql b/models/stg_hubspot__ticket_deal.sql index 1702486..78d11d2 100644 --- a/models/stg_hubspot__ticket_deal.sql +++ b/models/stg_hubspot__ticket_deal.sql @@ -1,4 +1,4 @@ -{{ config(enabled=var('hubspot_service_enabled', False)) }} +{{ config(enabled=fivetran_utils.enabled_vars(['hubspot_service_enabled','hubspot_ticket_deal_enabled'])) }} with base as ( diff --git a/models/tmp/stg_hubspot__ticket_deal_tmp.sql b/models/tmp/stg_hubspot__ticket_deal_tmp.sql index 180883e..392364f 100644 --- a/models/tmp/stg_hubspot__ticket_deal_tmp.sql +++ b/models/tmp/stg_hubspot__ticket_deal_tmp.sql @@ -1,4 +1,4 @@ -{{ config(enabled=var('hubspot_service_enabled', True)) }} +{{ config(enabled=fivetran_utils.enabled_vars(['hubspot_service_enabled','hubspot_ticket_deal_enabled'])) }} select * from {{ var('ticket_deal') }} From 6da104af8a1871ac9ef5c5bb2300adb8aa3c4489 Mon Sep 17 00:00:00 2001 From: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com> Date: Thu, 18 Aug 2022 16:51:47 -0700 Subject: [PATCH 2/5] add config despite no freshness test on this table --- models/src_hubspot.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/models/src_hubspot.yml b/models/src_hubspot.yml index f2458f5..30b024f 100644 --- a/models/src_hubspot.yml +++ b/models/src_hubspot.yml @@ -1262,6 +1262,8 @@ sources: - name: ticket_deal description: Each record represents a 'link' between a ticket and a deal. + config: + enabled: "{{ var('hubspot_service_enabled', false) and var('hubspot_ticket_deal_enabled', false) }}" columns: - name: _fivetran_synced description: '{{ doc("_fivetran_synced") }}' From 113fd5f02e556690178b0b2450bb66d98352f529 Mon Sep 17 00:00:00 2001 From: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com> Date: Mon, 22 Aug 2022 10:11:23 -0700 Subject: [PATCH 3/5] default value --- dbt_project.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/dbt_project.yml b/dbt_project.yml index 1c5d5dc..75e9765 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -62,6 +62,7 @@ vars: #Service Hub Enable Variables hubspot_service_enabled: false + hubspot_ticket_deal_enabled: false #Contact Merge Audit Enable Variable hubspot_contact_merge_audit_enabled: false From b503d975ac49bc83dd354b03c3ed1a3a03deee14 Mon Sep 17 00:00:00 2001 From: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com> Date: Tue, 23 Aug 2022 10:46:35 -0700 Subject: [PATCH 4/5] deal passthrough --- models/stg_hubspot__deal.sql | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/models/stg_hubspot__deal.sql b/models/stg_hubspot__deal.sql index 4901895..61ce994 100644 --- a/models/stg_hubspot__deal.sql +++ b/models/stg_hubspot__deal.sql @@ -19,13 +19,17 @@ with base as ( ), fields as ( select + property_dealname as deal_name, + property_closedate as closed_at, + property_createdate as created_at, {% if var('hubspot__pass_through_all_columns', false) %} - -- just pass everything through + -- just pass everything else through {{ fivetran_utils.remove_prefix_from_columns( columns=adapter.get_columns_in_relation(ref('stg_hubspot__deal_tmp')), - prefix='property_') + prefix='property_', + exclude=['property_dealname','property_closedate','property_createdate']) }} from base @@ -38,11 +42,8 @@ with base as ( cast(deal_pipeline_stage_id as {{ dbt_utils.type_string() }}) as deal_pipeline_stage_id, owner_id, portal_id, - property_dealname as deal_name, property_description as description, - property_amount as amount, - property_closedate as closed_at, - property_createdate as created_at + property_amount as amount --The below macro adds the fields defined within your hubspot__deal_pass_through_columns variable into the staging model {{ fivetran_utils.fill_pass_through_columns('hubspot__deal_pass_through_columns') }} From b45b73da008681feb08d618abe9bb1a58ac6c6ad Mon Sep 17 00:00:00 2001 From: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com> Date: Tue, 23 Aug 2022 13:29:42 -0700 Subject: [PATCH 5/5] address bug in deals --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46905a6..3de44f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ # dbt_hubspot_source v0.5.8 ## Features -- Adds `hubspot_ticket_deal_enabled` variable (default value=`False`) to disable modelling and testing of the `ticket_deal` source table. If there are no associations between tickets and deals in your Hubspot environment, this table will not exist. +- Adds `hubspot_ticket_deal_enabled` variable (default value=`False`) to disable modelling and testing of the `ticket_deal` source table. If there are no associations between tickets and deals in your Hubspot environment, this table will not exist ([#79](https://github.com/fivetran/dbt_hubspot_source/pull/79)). + +## Fixes +- Consistently renames `property_dealname`, `property_closedate`, and `property_createdate` to `deal_name`, `closed_at`, and `created_at`, respectively, in the `deals` staging model. Previously, if `hubspot__pass_through_all_columns = true`, only the prefix `property_` was removed from the names of these fields, while they were completely renamed to `deal_name`, `closed_at`, and `created_at` if `hubspot__pass_through_all_columns = false` ([#79](https://github.com/fivetran/dbt_hubspot_source/pull/79)). # dbt_hubspot_source v0.5.7 ## Fixes