stages model
This commit is contained in:
parent
002eadc362
commit
b9958129bc
1 changed files with 33 additions and 0 deletions
33
models/staging/hubspot/stg_hubspot__deal_pipeline_stages.sql
Normal file
33
models/staging/hubspot/stg_hubspot__deal_pipeline_stages.sql
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue