stages model

This commit is contained in:
Pablo Martin 2024-10-14 11:37:42 +02:00
parent 002eadc362
commit b9958129bc

View file

@ -0,0 +1,33 @@
with
raw_deal_pipelines as (select * from {{ source("hubspot", "deal_pipelines") }}),
stg_hubspot__deal_pipelines as (
select
{{ adapter.quote("pipelineId") }} as id_deal_pipeline,
stage."stageId" as id_stage,
stage.label as stage_name,
stage.active as is_active,
{{
unix_ms_timestamp_to_utc(
column_name="createdAt", table_alias="stage"
)
}} as created_at_utc,
{{
unix_ms_timestamp_to_utc(
column_name="updatedAt", table_alias="stage"
)
}} as updated_at_utc,
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
from
raw_deal_pipelines,
lateral jsonb_to_recordset({{ adapter.quote("stages") }}::jsonb) as stage(
label text,
active boolean,
"stageId" text,
metadata jsonb,
"createdAt" bigint,
"updatedAt" bigint,
"displayOrder" int
)
)
select *
from stg_hubspot__deal_pipelines