Merged PR 2994: Staging Hubspot deals

# Description

Creation on stg_hubspot__deals model

# 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.
This commit is contained in:
Joaquin Ossa 2024-09-27 15:30:53 +00:00
commit ae865b8848
4 changed files with 165 additions and 0 deletions

View file

@ -0,0 +1,10 @@
version: 2
sources:
- name: hubspot
schema: sync_hubspot
tables:
- name: contacts
identifier: contacts
- name: deals
identifier: deals

View file

@ -0,0 +1,117 @@
version: 2
models:
- name: stg_hubspot__contacts
description: "Table with contact information of user in Hubspot."
columns:
- name: id_contact
data_type: character varying
description: "Unique id for each contact information."
tests:
- unique
- not_null
- name: archived
data_type: boolean
description: ""
- name: companies
data_type: jsonb
description: ""
- name: properties
data_type: jsonb
description: "Json with all contact information for this record."
tests:
- not_null
- name: created_at_utc
data_type: timestamp with time zone
description: "Timestamp of when this record was created."
tests:
- not_null
- name: created_date_utc
data_type: timestamp without time zone
description: "Date of when this record was created."
tests:
- not_null
- name: updated_at_utc
data_type: timestamp with time zone
description: "Timestamp of when this record was last updated."
tests:
- not_null
- name: updated_date_utc
data_type: timestamp without time zone
description: "Date of when this record was last updated."
tests:
- not_null
- name: dwh_extracted_at_utc
data_type: timestamp with time zone
description: "Timestamp of when data was extracted to DWH."
tests:
- not_null
- name: stg_hubspot__deals
description: "Table with deal information stored in Hubspot."
columns:
- name: id_deal
data_type: character varying
description: "Unique id for each contact information."
tests:
- unique
- not_null
- name: archived
data_type: boolean
description: ""
- name: contacts
data_type: jsonb
description: "List of contact ids for the deal"
- name: companies
data_type: jsonb
description: ""
- name: line_items
data_type: jsonb
description: ""
- name: properties
data_type: jsonb
description: "Json with all information for this deal."
tests:
- not_null
- name: created_at_utc
data_type: timestamp with time zone
description: "Timestamp of when this record was created."
tests:
- not_null
- name: created_date_utc
data_type: timestamp without time zone
description: "Date of when this record was created."
tests:
- not_null
- name: updated_at_utc
data_type: timestamp with time zone
description: "Timestamp of when this record was last updated."
tests:
- not_null
- name: updated_date_utc
data_type: timestamp without time zone
description: "Date of when this record was last updated."
tests:
- not_null
- name: dwh_extracted_at_utc
data_type: timestamp with time zone
description: "Timestamp of when data was extracted to DWH."
tests:
- not_null

View file

@ -0,0 +1,18 @@
with
raw_contacts as (select * from {{ source("hubspot", "contacts") }}),
stg_core__contacts as (
select
{{ adapter.quote("id") }} as id_contact,
{{ adapter.quote("archived") }} as archived,
{{ adapter.quote("companies") }} as companies,
{{ adapter.quote("properties") }} as properties,
{{ adapter.quote("createdAt") }} as created_at_utc,
cast({{ adapter.quote("createdAt") }} as date) as created_date_utc,
{{ adapter.quote("updatedAt") }} as updated_at_utc,
cast({{ adapter.quote("updatedAt") }} as date) as updated_date_utc,
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
from raw_contacts
)
select *
from stg_core__contacts

View file

@ -0,0 +1,20 @@
with
raw_deals as (select * from {{ source("hubspot", "deals") }}),
stg_core__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") }} as properties,
{{ adapter.quote("createdAt") }} as created_at_utc,
cast({{ adapter.quote("createdAt") }} as date) as created_date_utc,
{{ adapter.quote("updatedAt") }} as updated_at_utc,
cast({{ adapter.quote("updatedAt") }} as date) as updated_date_utc,
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
from raw_deals
)
select *
from stg_core__deals