-
Notifications
You must be signed in to change notification settings - Fork 7
/
stg_marketo__lead.sql
32 lines (25 loc) · 1.3 KB
/
stg_marketo__lead.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
with base as (
select *
from {{ ref('stg_marketo__lead_tmp') }}
), macro as (
select
{{
fivetran_utils.fill_staging_columns(
source_columns=adapter.get_columns_in_relation(ref('stg_marketo__lead_tmp')),
staging_columns=get_lead_columns()
)
}}
-- This will check if there are non-default columns to bring in
{% set default_cols = ['id', 'created_at', 'updated_at', 'email', 'first_name', 'last_name', '_fivetran_synced',
'phone', 'main_phone', 'mobile_phone', 'company', 'inferred_company', 'address_lead', 'address', 'city', 'state',
'state_code', 'country', 'country_code', 'postal_code', 'billing_street', 'billing_city', 'billing_state',
'billing_state_code', 'billing_country', 'billing_country_code', 'billing_postal_code', 'inferred_city', 'inferred_state_region',
'inferred_country', 'inferred_postal_code', 'inferred_phone_area_code', 'anonymous_ip', 'unsubscribed', 'email_invalid', 'do_not_call'] %}
{% set new_cols = dbt_utils.star(from=ref('stg_marketo__lead_tmp'), except=default_cols) %}
{% if new_cols != '/* no columns returned from star() macro */' %}
,{{ new_cols }}
{% endif %}
from base
)
select *
from macro