Merged PR 3177: Deals with properties
# Description Expands the Deals staging model by adding tons of properties. # 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. # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #22225
This commit is contained in:
commit
da8c2e9fab
2 changed files with 254 additions and 2 deletions
|
|
@ -259,3 +259,199 @@ models:
|
|||
- name: dwh_extracted_at_utc
|
||||
data_type: timestamp
|
||||
description: Timestamp of when the record was read from source.
|
||||
|
||||
- name: stg_hubspot__deals
|
||||
description: |
|
||||
Our deals in Hubspot. A deal is a commercial relationship with a client
|
||||
company. It's possible for a single company to have multiple deals, but
|
||||
it's frequent for them to only have one.
|
||||
|
||||
Deals are one of the spines of Superhog's data. You will find references
|
||||
to Deal Ids in both our in-house systems and Xero.
|
||||
columns:
|
||||
- name: id_deal
|
||||
data_type: character varying
|
||||
description: Unique ID for this deal.
|
||||
tests:
|
||||
- unique
|
||||
- not_null
|
||||
|
||||
- name: archived
|
||||
data_type: boolean
|
||||
description: Whether the deal is archived.
|
||||
|
||||
- name: contacts
|
||||
data_type: jsonb
|
||||
description: An array of contact IDs.
|
||||
|
||||
- name: companies
|
||||
data_type: jsonb
|
||||
description: An array of company IDs.
|
||||
|
||||
- name: line_items
|
||||
data_type: jsonb
|
||||
description: ""
|
||||
|
||||
- name: id_hubspot_account_owner
|
||||
data_type: text
|
||||
description: |
|
||||
The ID of the owner of the Deal. This is typically the Superhog
|
||||
employee who closed the deal, so most probably one of our sales
|
||||
colleagues.
|
||||
|
||||
You can join this with the Owners table.
|
||||
|
||||
- name: account_manager
|
||||
data_type: text
|
||||
description: |
|
||||
The name of the account manager that is currently taking care of this
|
||||
deal.
|
||||
|
||||
- name: contract_signed_date_utc
|
||||
data_type: text
|
||||
description: Date in which the contract was signed
|
||||
|
||||
- name: live_date_utc
|
||||
data_type: text
|
||||
description: Date in which the account went live
|
||||
|
||||
- name: cancellation_date_utc
|
||||
data_type: text
|
||||
description: Date in which an account that was being used was cancelled
|
||||
|
||||
- name: deal_name
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: sales_stage
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: id_deal_stage
|
||||
data_type: text
|
||||
description: |
|
||||
ID of the stage the deal is in. Can be denormalized with our
|
||||
deal_pipeline_stages table.
|
||||
|
||||
- name: deal_source
|
||||
data_type: text
|
||||
description: |
|
||||
General indicator of the source of this deal.
|
||||
|
||||
- name: lead_source
|
||||
data_type: text
|
||||
description: |
|
||||
Whether the deal was inbound sourced (they came to us) or outbound
|
||||
sourced (we reached out proactively to the customer).
|
||||
|
||||
- name: amount_of_properties
|
||||
data_type: integer
|
||||
description: amount of properties the owner told us they manage
|
||||
|
||||
- name: is_demo_scheduled
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: demo_scheduled_date_utc
|
||||
data_type: text
|
||||
description: date at which the demo is scheduled for
|
||||
|
||||
- name: is_demo_completed
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: demo_details
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: onboarding_date_utc
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: onboarding_stage
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: onboarding_owner
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: onboarding_owner__cloned_
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: is_onboarding_call_completed
|
||||
data_type: text
|
||||
description: boolean for completed onboarding
|
||||
|
||||
- name: is_onboarding_scheduled
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: cancellation_category
|
||||
data_type: text
|
||||
description: categorization as to why they cancelled the account
|
||||
|
||||
- name: cancellation_details
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: last_nps_survey_date_utc
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: last_nps_survey_rating
|
||||
data_type: integer
|
||||
description: ""
|
||||
|
||||
- name: last_nps_survey_comment
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: customer_nps_sentiment
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: last_contacted_at_utc
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: last_contacted_date_utc
|
||||
data_type: date
|
||||
description: ""
|
||||
|
||||
- name: amount_times_contacted
|
||||
data_type: integer
|
||||
description: ""
|
||||
|
||||
- name: free_trial_start_date_utc
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: free_trial_end_date_utc
|
||||
data_type: text
|
||||
description: ""
|
||||
|
||||
- name: properties
|
||||
data_type: jsonb
|
||||
description: ""
|
||||
|
||||
- name: created_at_utc
|
||||
data_type: timestamp with time zone
|
||||
description: ""
|
||||
|
||||
- name: created_date_utc
|
||||
data_type: date
|
||||
description: ""
|
||||
|
||||
- name: updated_at_utc
|
||||
data_type: timestamp with time zone
|
||||
description: ""
|
||||
|
||||
- name: updated_date_utc
|
||||
data_type: date
|
||||
description: ""
|
||||
|
||||
- name: dwh_extracted_at_utc
|
||||
data_type: timestamp with time zone
|
||||
description: ""
|
||||
|
|
|
|||
|
|
@ -1,12 +1,68 @@
|
|||
with
|
||||
raw_deals as (select * from {{ source("hubspot", "deals") }}),
|
||||
stg_core__deals as (
|
||||
stg_hubspot__deals as (
|
||||
select
|
||||
{{ adapter.quote("id") }} as id_deal,
|
||||
{{ adapter.quote("archived") }} as archived,
|
||||
{{ adapter.quote("contacts") }} as contacts,
|
||||
{{ adapter.quote("companies") }} as companies,
|
||||
{{ adapter.quote("line_items") }} as line_items,
|
||||
{{ adapter.quote("properties") }}
|
||||
->> 'hubspot_owner_id' as id_hubspot_account_owner,
|
||||
{{ adapter.quote("properties") }}->> 'dedicated_am' as account_manager,
|
||||
{{ adapter.quote("properties") }}
|
||||
->> 'contract_signed_date' as contract_signed_date_utc,
|
||||
{{ adapter.quote("properties") }}->> 'live_date' as live_date_utc,
|
||||
{{ adapter.quote("properties") }}
|
||||
->> 'cancellation_date' as cancellation_date_utc,
|
||||
{{ adapter.quote("properties") }}->> 'dealname' as deal_name,
|
||||
{{ adapter.quote("properties") }}->> 'sales_stage' as sales_stage,
|
||||
{{ adapter.quote("properties") }}->> 'dealstage' as id_deal_stage,
|
||||
{{ adapter.quote("properties") }}->> 'deal_source' as deal_source,
|
||||
{{ adapter.quote("properties") }} ->> 'lead_source' as lead_source,
|
||||
round(
|
||||
({{ adapter.quote("properties") }} ->> 'amount_of_properties')::numeric,
|
||||
0
|
||||
)::integer -- Yes, somehow we managed to input decimals here sometimes, lol
|
||||
as amount_of_properties,
|
||||
{{ adapter.quote("properties") }}->> 'demo_scheduled' as is_demo_scheduled,
|
||||
{{ adapter.quote("properties") }}
|
||||
->> 'sales_demo_scheduled' as demo_scheduled_date_utc,
|
||||
{{ adapter.quote("properties") }}->> 'demo_completed' as is_demo_completed,
|
||||
{{ adapter.quote("properties") }}
|
||||
->> 'meeting_status__hubspot_' as demo_details,
|
||||
{{ adapter.quote("properties") }}->> 'date_meeting' as onboarding_date_utc,
|
||||
{{ adapter.quote("properties") }}->> 'onboarding_stage' as onboarding_stage,
|
||||
{{ adapter.quote("properties") }}->> 'onboarding_owner' as onboarding_owner,
|
||||
{{ adapter.quote("properties") }}
|
||||
->> 'onboarding_owner__cloned_' as onboarding_owner__cloned_,
|
||||
{{ adapter.quote("properties") }}
|
||||
->> 'onboarding_call_completed' as is_onboarding_call_completed,
|
||||
{{ adapter.quote("properties") }}
|
||||
->> 'meeting_scheduled' as is_onboarding_scheduled,
|
||||
{{ adapter.quote("properties") }}
|
||||
->> 'cancellation_category' as cancellation_category,
|
||||
{{ adapter.quote("properties") }}
|
||||
->> 'cancellation_details' as cancellation_details,
|
||||
{{ adapter.quote("properties") }}
|
||||
->> 'last_nps_survey_date' as last_nps_survey_date_utc,
|
||||
({{ adapter.quote("properties") }} ->> 'last_nps_survey_rating')::integer
|
||||
as last_nps_survey_rating,
|
||||
{{ adapter.quote("properties") }}
|
||||
->> 'last_nps_survey_comment' as last_nps_survey_comment,
|
||||
{{ adapter.quote("properties") }}
|
||||
->> 'customer_nps_sentiment' as customer_nps_sentiment,
|
||||
{{ adapter.quote("properties") }}
|
||||
->> 'notes_last_contacted' as last_contacted_at_utc,
|
||||
cast(
|
||||
{{ adapter.quote("properties") }} ->> 'notes_last_contacted' as date
|
||||
) as last_contacted_date_utc,
|
||||
({{ adapter.quote("properties") }} ->> 'num_contacted_notes')::integer
|
||||
as amount_times_contacted,
|
||||
{{ adapter.quote("properties") }}
|
||||
->> 'free_trial_start_date' as free_trial_start_date_utc,
|
||||
{{ adapter.quote("properties") }}
|
||||
->> 'free_trial_end_date' as free_trial_end_date_utc,
|
||||
{{ adapter.quote("properties") }} as properties,
|
||||
{{ adapter.quote("createdAt") }} as created_at_utc,
|
||||
cast({{ adapter.quote("createdAt") }} as date) as created_date_utc,
|
||||
|
|
@ -17,4 +73,4 @@ with
|
|||
from raw_deals
|
||||
)
|
||||
select *
|
||||
from stg_core__deals
|
||||
from stg_hubspot__deals
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue