data-dwh-dbt-project/models/intermediate/hubspot/int_hubspot__deal.sql
Oriol Roqué Paniagua fae7572777 Merged PR 4782: Dashboard, Pricing and Services from Hubspot
# Description

Brings 3 new properties from HubSpot - Deals:
* Dashboard Type: Old Dash, New Dash or null
* Pricing Structure: this contains several possibilities, such as new pricing v1, v2, old pricing (legacy), api pricing, etc.
* Partnership Services: what services the client has according to Hubspot. Not the best in terms of quality but better than nothing specially in Old Dash. I also handled a small processing since services were differently separated.

This is propagated to intermediate in `int_hubspot__deal`. This is needed to automate the pricing differences for clients in old dash to be moved to new dash.

# Checklist

- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented. **Mostly on intermediate, did not bother to update staging besides the new fields.**
- [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.

# Other

- [ ] Check if a full-refresh is required after this PR is merged.

Related work items: #28627
2025-03-24 11:20:03 +00:00

37 lines
1.2 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.amount_of_properties,
d.last_contacted_date_utc,
d.amount_times_contacted,
d.dashboard_type,
d.pricing_structure,
d.partnership_services,
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 }}