From a994c3ef4f2b0655048037c392857e0a03e5e0f5 Mon Sep 17 00:00:00 2001 From: Jamie Rodriguez Date: Mon, 22 Mar 2021 11:41:32 -0700 Subject: [PATCH] deal company --- models/sales/hubspot__deals.sql | 17 +++++++++++++++++ models/sales/sales.yml | 3 +++ 2 files changed, 20 insertions(+) diff --git a/models/sales/hubspot__deals.sql b/models/sales/hubspot__deals.sql index 2a90860..b9feb58 100644 --- a/models/sales/hubspot__deals.sql +++ b/models/sales/hubspot__deals.sql @@ -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 @@ -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) @@ -36,6 +48,11 @@ with deals as ( left join owners using (owner_id) + {% if var('hubspot_company_enabled', True) %} + left join companies + using (company_id) + {% endif %} + {% if fivetran_utils.enabled_vars(['hubspot_engagement_enabled','hubspot_engagement_deal_enabled']) %} ), engagements as ( diff --git a/models/sales/sales.yml b/models/sales/sales.yml index e2107ca..1f59c89 100644 --- a/models/sales/sales.yml +++ b/models/sales/sales.yml @@ -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