# Description Very minimal, first version of Hubspot deals. I intentionally didn't include here sales related information or additional attributes since I don't need them for Churn related topics. This can be done in future PRs. This Deal version includes the name of the Hubspot pipeline and the Stage. It also excludes deals assigned to Guardhog pipeline (~3k) based on my discussion with Alex. # Checklist - [X] The edited models and dependants run properly with production data. - [X] The edited models are sufficiently documented. - [X] The edited models contain PK tests, and I've ran and passed them. - [X] I have checked for DRY opportunities with other models and docs. - [X] I've picked the right materialization for the affected models. **Left as a view since there's not that many records, can be changed in the future if needed** # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #22689
31 lines
1 KiB
SQL
31 lines
1 KiB
SQL
{% set id_deal_pipelines_excluded = "('15380854')" %}
|
|
|
|
with
|
|
stg_hubspot__deals as (select * from {{ ref("stg_hubspot__deals") }}),
|
|
stg_hubspot__deal_pipeline_stages as (
|
|
select * from {{ ref("stg_hubspot__deal_pipeline_stages") }}
|
|
),
|
|
stg_hubspot__deal_pipelines as (
|
|
select * from {{ ref("stg_hubspot__deal_pipelines") }}
|
|
)
|
|
select
|
|
d.id_deal,
|
|
d.deal_name,
|
|
d.contract_signed_date_utc,
|
|
d.onboarding_date_utc,
|
|
d.live_date_utc,
|
|
d.cancellation_date_utc,
|
|
d.account_manager,
|
|
dp.deal_pipeline_name as deal_pipeline,
|
|
dps.stage_name as deal_hubspot_stage,
|
|
d.cancellation_category,
|
|
d.cancellation_details,
|
|
d.created_at_utc,
|
|
d.created_date_utc,
|
|
d.updated_at_utc,
|
|
d.updated_date_utc
|
|
from stg_hubspot__deals d
|
|
left join stg_hubspot__deal_pipeline_stages dps on d.id_deal_stage = dps.id_stage
|
|
left join stg_hubspot__deal_pipelines dp on dps.id_deal_pipeline = dp.id_deal_pipeline
|
|
-- Exclude Guardhog pipelines
|
|
where dps.id_deal_pipeline not in {{ id_deal_pipelines_excluded }}
|