Merged PR 3957: ordered names to select oldest one created

# Description

Ordered the deals so the selected name to show is the oldest one by creation, except Xero that doesn't contain `creation_date` so instead I used `updated_date`.
I also partly added the entry in exposure, I only have the link to the power BI missing which I'll add once it is uploaded.

# 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.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.

# Other

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

ordered names to select oldest one created

Related work items: #25827
This commit is contained in:
Joaquin Ossa 2025-01-07 12:55:00 +00:00
commit f5e417c7db
2 changed files with 23 additions and 3 deletions

View file

@ -16,7 +16,7 @@ with
u.company_name as core_company_name, u.company_name as core_company_name,
c.core_company_name_count, c.core_company_name_count,
row_number() over ( row_number() over (
partition by u.id_deal order by u.company_name partition by u.id_deal order by u.created_at_utc
) as row_num ) as row_num
from int_core__unified_user u from int_core__unified_user u
left join core_deal_counts c on u.id_deal = c.id_deal left join core_deal_counts c on u.id_deal = c.id_deal
@ -40,7 +40,9 @@ with
h.id_deal, h.id_deal,
h.deal_name as hubspot_deal_name, h.deal_name as hubspot_deal_name,
c.hubspot_deal_name_count, c.hubspot_deal_name_count,
row_number() over (partition by h.id_deal order by h.deal_name) as row_num row_number() over (
partition by h.id_deal order by h.created_at_utc
) as row_num
from int_hubspot__deal h from int_hubspot__deal h
left join hubspot_deal_counts c on h.id_deal = c.id_deal left join hubspot_deal_counts c on h.id_deal = c.id_deal
where h.id_deal is not null where h.id_deal is not null
@ -64,7 +66,7 @@ with
x.contact_name as xero_contact_name, x.contact_name as xero_contact_name,
c.xero_contact_name_count, c.xero_contact_name_count,
row_number() over ( row_number() over (
partition by x.id_deal order by x.contact_name partition by x.id_deal order by x.updated_at_utc
) as row_num ) as row_num
from int_xero__contacts x from int_xero__contacts x
left join xero_contact_counts c on x.id_deal = c.id_deal left join xero_contact_counts c on x.id_deal = c.id_deal

View file

@ -352,3 +352,21 @@ exposures:
owner: owner:
name: Pablo Martin name: Pablo Martin
email: pablo.martin@superhog.com email: pablo.martin@superhog.com
- name: deals_consolidation_report
label: Deals Consolidation
type: dashboard
maturity: medium
url: to be filled
description: |
A PBI report that shows all deals id from Superhog backend (Core), HubSpot
and Xero into a table.
It contains the deal's name (if it exists) and the number of different names
it has in each source.
depends_on:
- ref('deals_consolidation')
owner:
name: Joaquin Ossa
email: joaquin.ossa@superhog.com