From 9549dfead7e64af3207021127f803ca1f615b1a5 Mon Sep 17 00:00:00 2001 From: dietofworms <28944297+dietofworms@users.noreply.github.com> Date: Wed, 4 May 2022 11:45:43 +1000 Subject: [PATCH 1/9] created deal_contact models --- dbt_project.yml | 1 + models/stg_hubspot__deal_contact.sql | 31 +++++++++++++++++++ models/tmp/stg_hubspot__deal_contact__tmp.sql | 4 +++ 3 files changed, 36 insertions(+) create mode 100644 models/stg_hubspot__deal_contact.sql create mode 100644 models/tmp/stg_hubspot__deal_contact__tmp.sql diff --git a/dbt_project.yml b/dbt_project.yml index 1731e5e..637220e 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -22,6 +22,7 @@ vars: deal: "{{ source('hubspot','deal') }}" deal_stage: "{{ source('hubspot','deal_stage') }}" deal_company: "{{ source('hubspot','deal_company') }}" + deal_contact: "{{ source('hubspot','deal_contact') }}" deal_pipeline: "{{ source('hubspot','deal_pipeline') }}" deal_pipeline_stage: "{{ source('hubspot','deal_pipeline_stage') }}" deal_property_history: "{{ source('hubspot','deal_property_history') }}" diff --git a/models/stg_hubspot__deal_contact.sql b/models/stg_hubspot__deal_contact.sql new file mode 100644 index 0000000..a01964c --- /dev/null +++ b/models/stg_hubspot__deal_contact.sql @@ -0,0 +1,31 @@ +{{ config(enabled=fivetran_utils.enabled_vars(['hubspot_sales_enabled','hubspot_deal_enabled','hubspot_deal_contact_enabled'])) }} + +with base as ( + + select * + from {{ ref('stg_hubspot__deal_contact_tmp') }} + +), macro as ( + + select + {{ + fivetran_utils.fill_staging_columns( + source_columns=adapter.get_columns_in_relation(ref('stg_hubspot__deal_contact_tmp')), + staging_columns=get_deal_company_columns() + ) + }} + from base + +), fields as ( + + select + contact_id, + deal_id, + _fivetran_synced + + from macro + +) + +select * +from fields diff --git a/models/tmp/stg_hubspot__deal_contact__tmp.sql b/models/tmp/stg_hubspot__deal_contact__tmp.sql new file mode 100644 index 0000000..577bd9a --- /dev/null +++ b/models/tmp/stg_hubspot__deal_contact__tmp.sql @@ -0,0 +1,4 @@ +{{ config(enabled=fivetran_utils.enabled_vars(['hubspot_sales_enabled','hubspot_deal_enabled','hubspot_deal_contact_enabled'])) }} + +select * +from {{ var('deal_contact') }} From 586c79edd09224ef5aea1f38c104f3a1d41d3da6 Mon Sep 17 00:00:00 2001 From: dietofworms <28944297+dietofworms@users.noreply.github.com> Date: Wed, 4 May 2022 11:49:16 +1000 Subject: [PATCH 2/9] renamed file --- ...t__deal_contact__tmp.sql => stg_hubspot__deal_contact_tmp.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename models/tmp/{stg_hubspot__deal_contact__tmp.sql => stg_hubspot__deal_contact_tmp.sql} (100%) diff --git a/models/tmp/stg_hubspot__deal_contact__tmp.sql b/models/tmp/stg_hubspot__deal_contact_tmp.sql similarity index 100% rename from models/tmp/stg_hubspot__deal_contact__tmp.sql rename to models/tmp/stg_hubspot__deal_contact_tmp.sql From dfabbc9cc6e2d5af9d4ee81769e83639ec90e4bd Mon Sep 17 00:00:00 2001 From: dietofworms <28944297+dietofworms@users.noreply.github.com> Date: Wed, 4 May 2022 11:58:50 +1000 Subject: [PATCH 3/9] create macro for deal_contact_columns --- macros/get_deal_contact_columns.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 macros/get_deal_contact_columns.sql diff --git a/macros/get_deal_contact_columns.sql b/macros/get_deal_contact_columns.sql new file mode 100644 index 0000000..fa625bc --- /dev/null +++ b/macros/get_deal_contact_columns.sql @@ -0,0 +1,11 @@ +{% macro get_deal_contact_columns() %} + +{% set columns = [ + {"name": "_fivetran_synced", "datatype": dbt_utils.type_timestamp()}, + {"name": "deal_id", "datatype": dbt_utils.type_int()}, + {"name": "contact_id", "datatype": dbt_utils.type_int()} +] %} + +{{ return(columns) }} + +{% endmacro %} From 6ff512d6c347057b74a411a5bdd542ade2fa6407 Mon Sep 17 00:00:00 2001 From: dietofworms <28944297+dietofworms@users.noreply.github.com> Date: Wed, 4 May 2022 11:59:51 +1000 Subject: [PATCH 4/9] fixed macro ref in model --- models/stg_hubspot__deal_contact.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/stg_hubspot__deal_contact.sql b/models/stg_hubspot__deal_contact.sql index a01964c..d7167ce 100644 --- a/models/stg_hubspot__deal_contact.sql +++ b/models/stg_hubspot__deal_contact.sql @@ -11,7 +11,7 @@ with base as ( {{ fivetran_utils.fill_staging_columns( source_columns=adapter.get_columns_in_relation(ref('stg_hubspot__deal_contact_tmp')), - staging_columns=get_deal_company_columns() + staging_columns=get_deal_contact_columns() ) }} from base From 99d3d83f86f8a8711b471d2155ea899443b45d4e Mon Sep 17 00:00:00 2001 From: dietofworms <28944297+dietofworms@users.noreply.github.com> Date: Wed, 4 May 2022 12:11:52 +1000 Subject: [PATCH 5/9] added entry to change log --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a8f7eb..3664a72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +# dbt_hubspot_source v0.5.5 +## Fixes +- Adds missing `stg_hubspot__deal_contact` model. + +## Contributors +- [@dietofworms](https://github.com/dietofworms) + +# dbt_hubspot_source v0.5.3 + +## Under the Hood +- Cast the `deal_pipeline_stage_id` and `deal_pipeline_id` fields within the stg_hubspot__deal_pipeline, stg_hubspot__deal_pipeline_stage, stg_hubspot__deal using the `dbt_utils.type_string()` macro. This ensures joins in downstream models are accurate across warehouses. ([#57](https://github.com/fivetran/dbt_hubspot_source/pull/57)) + + # dbt_hubspot_source v0.5.4 ## Fixes - Updated the README to reference the proper `hubspot_email_event_spam_report_enabled` variable name. ([#59](https://github.com/fivetran/dbt_hubspot_source/pull/59)) From ffbbe4d4c1beed8f87281124512affaa512cf34a Mon Sep 17 00:00:00 2001 From: dietofworms <28944297+dietofworms@users.noreply.github.com> Date: Wed, 4 May 2022 12:12:47 +1000 Subject: [PATCH 6/9] updated dbt project with version change no. --- dbt_project.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt_project.yml b/dbt_project.yml index 637220e..ddad186 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -1,5 +1,5 @@ name: 'hubspot_source' -version: '0.5.4' +version: '0.5.5' config-version: 2 require-dbt-version: [">=1.0.0", "<2.0.0"] From 39884c77997bbbbce8519a88d7f20eaf9c3baf1d Mon Sep 17 00:00:00 2001 From: Stavros Karmaniolos <28944297+dietofworms@users.noreply.github.com> Date: Wed, 4 May 2022 12:50:12 +1000 Subject: [PATCH 7/9] Update CHANGELOG.md --- CHANGELOG.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3664a72..5e957dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,6 @@ ## Contributors - [@dietofworms](https://github.com/dietofworms) -# dbt_hubspot_source v0.5.3 - -## Under the Hood -- Cast the `deal_pipeline_stage_id` and `deal_pipeline_id` fields within the stg_hubspot__deal_pipeline, stg_hubspot__deal_pipeline_stage, stg_hubspot__deal using the `dbt_utils.type_string()` macro. This ensures joins in downstream models are accurate across warehouses. ([#57](https://github.com/fivetran/dbt_hubspot_source/pull/57)) - - # dbt_hubspot_source v0.5.4 ## Fixes - Updated the README to reference the proper `hubspot_email_event_spam_report_enabled` variable name. ([#59](https://github.com/fivetran/dbt_hubspot_source/pull/59)) From fa0d65fc630f7821356d58dd4531040ab0594958 Mon Sep 17 00:00:00 2001 From: fivetran-joemarkiewicz Date: Thu, 5 May 2022 12:53:27 -0500 Subject: [PATCH 8/9] integration tests addition --- CHANGELOG.md | 4 ++-- integration_tests/dbt_project.yml | 7 ++++++- integration_tests/seeds/deal_contact_data.csv | 12 ++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 integration_tests/seeds/deal_contact_data.csv diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e957dd..91ce60b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,9 @@ # dbt_hubspot_source v0.5.5 ## Fixes -- Adds missing `stg_hubspot__deal_contact` model. +- Adds missing `stg_hubspot__deal_contact` model. ([#64](https://github.com/fivetran/dbt_hubspot_source/pull/64)) ## Contributors -- [@dietofworms](https://github.com/dietofworms) +- [@dietofworms](https://github.com/dietofworms) ([#64](https://github.com/fivetran/dbt_hubspot_source/pull/64)) # dbt_hubspot_source v0.5.4 ## Fixes diff --git a/integration_tests/dbt_project.yml b/integration_tests/dbt_project.yml index 229c96a..9bab64e 100644 --- a/integration_tests/dbt_project.yml +++ b/integration_tests/dbt_project.yml @@ -1,6 +1,6 @@ name: 'hubspot_source_integration_tests' -version: '0.5.4' +version: '0.5.5' profile: 'integration_tests' config-version: 2 @@ -21,6 +21,7 @@ vars: deal: "{{ ref('deal_data')}}" deal_stage: "{{ ref('deal_stage_data')}}" deal_company: "{{ ref('deal_company_data')}}" + deal_contact: "{{ ref('deal_contact_data')}}" deal_pipeline: "{{ ref('deal_pipeline_data')}}" deal_pipeline_stage: "{{ ref('deal_pipeline_stage_data')}}" deal_property_history: "{{ ref('deal_property_history_data')}}" @@ -69,6 +70,10 @@ seeds: +column_types: deal_id: "{{ 'int64' if target.name == 'bigquery' else 'bigint' }}" owner_id: "{{ 'int64' if target.name == 'bigquery' else 'bigint' }}" + deal_contact_data: + +column_types: + contact_id: "{{ 'int64' if target.name == 'bigquery' else 'bigint' }}" + deal_id: "{{ 'int64' if target.name == 'bigquery' else 'bigint' }}" deal_stage_data: +column_types: deal_id: "{{ 'int64' if target.name == 'bigquery' else 'bigint' }}" diff --git a/integration_tests/seeds/deal_contact_data.csv b/integration_tests/seeds/deal_contact_data.csv new file mode 100644 index 0000000..d17fdd0 --- /dev/null +++ b/integration_tests/seeds/deal_contact_data.csv @@ -0,0 +1,12 @@ +contact_id,deal_id,_fivetran_synced +1499466,86133127,2022-04-14 4:30:42 +1499466,86134193,2022-04-14 4:45:43 +1499368,86014324,2022-04-14 5:30:45 +1499468,86136486,2022-04-14 6:30:45 +1499469,86139887,2022-04-14 7:45:44 +1499469,86142279,2022-04-14 8:30:44 +1499596,86324169,2022-04-16 5:00:42 +1499595,86318106,2022-04-16 4:45:44 +1499597,86328114,2022-04-16 6:45:43 +1499597,86325643,2022-04-16 6:45:43 +1499598,86326974,2022-04-16 8:00:44 \ No newline at end of file From 2da8b32672915bf431d2b6f71cef4bbd640de9ec Mon Sep 17 00:00:00 2001 From: fivetran-joemarkiewicz Date: Thu, 5 May 2022 13:57:43 -0500 Subject: [PATCH 9/9] variable added to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e428e96..28cc28f 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ vars: hubspot_company_enabled: false hubspot_deal_enabled: false hubspot_deal_company_enabled: false + hubspot_deal_contact_enabled: false hubspot_engagement_enabled: false # Disables all engagement models and functionality hubspot_engagement_contact_enabled: false hubspot_engagement_company_enabled: false