Skip to content

Commit

Permalink
Merge pull request #64 from dietofworms/feature/create-deal-contact-m…
Browse files Browse the repository at this point in the history
…odels

Feature: Create deal contact models
  • Loading branch information
fivetran-joemarkiewicz authored May 5, 2022
2 parents 393bd11 + 2da8b32 commit 01422ca
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# dbt_hubspot_source v0.5.5
## Fixes
- Adds missing `stg_hubspot__deal_contact` model. ([#64](https://github.com/fivetran/dbt_hubspot_source/pull/64))

## Contributors
- [@dietofworms](https://github.com/dietofworms) ([#64](https://github.com/fivetran/dbt_hubspot_source/pull/64))

# 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))
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -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"]

Expand All @@ -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') }}"
Expand Down
7 changes: 6 additions & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

name: 'hubspot_source_integration_tests'
version: '0.5.4'
version: '0.5.5'
profile: 'integration_tests'
config-version: 2

Expand All @@ -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')}}"
Expand Down Expand Up @@ -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' }}"
Expand Down
12 changes: 12 additions & 0 deletions integration_tests/seeds/deal_contact_data.csv
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions macros/get_deal_contact_columns.sql
Original file line number Diff line number Diff line change
@@ -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 %}
31 changes: 31 additions & 0 deletions models/stg_hubspot__deal_contact.sql
Original file line number Diff line number Diff line change
@@ -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_contact_columns()
)
}}
from base

), fields as (

select
contact_id,
deal_id,
_fivetran_synced

from macro

)

select *
from fields
4 changes: 4 additions & 0 deletions models/tmp/stg_hubspot__deal_contact_tmp.sql
Original file line number Diff line number Diff line change
@@ -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') }}

0 comments on commit 01422ca

Please sign in to comment.