Skip to content

Commit

Permalink
Merge pull request #33 from fivetran/jr_working
Browse files Browse the repository at this point in the history
deal-company
  • Loading branch information
fivetran-jamie authored Mar 22, 2021
2 parents 60f4395 + 31b4483 commit 49ea100
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
6 changes: 2 additions & 4 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ version: '0.3.0'
config-version: 2
require-dbt-version: [">=0.18.0", "<0.20.0"]

models:
hubspot:
+materialized: table
+schema: hubspot
vars:
hubspot:
contact: "{{ ref('stg_hubspot__contact') }}"
Expand All @@ -18,6 +14,7 @@ vars:
company_property_history: "{{ ref('stg_hubspot__company_property_history') }}"

deal: "{{ ref('stg_hubspot__deal') }}"
deal_company: "{{ ref('stg_hubspot__deal_company') }}"
deal_pipeline: "{{ ref('stg_hubspot__deal_pipeline') }}"
deal_pipeline_stage: "{{ ref('stg_hubspot__deal_pipeline_stage') }}"
deal_property_history: "{{ ref('stg_hubspot__deal_property_history') }}"
Expand Down Expand Up @@ -64,6 +61,7 @@ vars:
models:
hubspot:
+materialized: table
+schema: hubspot
marketing:
intermediate:
+materialized: ephemeral
3 changes: 2 additions & 1 deletion models/marketing/hubspot__contact_lists.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{ config(enabled=fivetran_utils.enabled_vars(['hubspot_marketing_enabled','hubspot_contact_list_enabled'])) }}

{{ config(enabled=fivetran_utils.enabled_vars(['hubspot_marketing_enabled', 'hubspot_contact_list_enabled'])) }}

with contact_lists as (

Expand Down
17 changes: 17 additions & 0 deletions models/sales/hubspot__deals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ with deals as (
select *
from {{ var('owner') }}

{% if var('hubspot_company_enabled', True) %}
), companies as (

select *
from {{ var('deal_company') }}
{% endif %}

), deal_fields_joined as (

select
Expand All @@ -28,6 +35,11 @@ with deals as (
pipeline_stages.pipeline_stage_label,
owners.email_address as owner_email_address,
owners.full_name as owner_full_name

{% if var('hubspot_company_enabled', True) %}
, companies.company_id
{% endif %}

from deals
left join pipelines
using (deal_pipeline_id)
Expand All @@ -36,6 +48,11 @@ with deals as (
left join owners
using (owner_id)

{% if var('hubspot_company_enabled', True) %}
left join companies
on deals.deal_id = companies.deal_id
{% endif %}

{% if fivetran_utils.enabled_vars(['hubspot_engagement_enabled','hubspot_engagement_deal_enabled']) %}

), engagements as (
Expand Down
3 changes: 3 additions & 0 deletions models/sales/sales.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ models:

- name: owner_full_name
description: The full name of the deal's owner.

- name: company_id
description: ID of the deal's associated company.


- name: hubspot__companies
Expand Down

0 comments on commit 49ea100

Please sign in to comment.