英文:
dbt_utils union_relations column_override not working
问题
{{ dbt_utils.union_relations(
relations=[
ref('base_consumer_digital_ad_performance_apple_ads_spend'),
ref('base_consumer_digital_ad_performance_facebook_spend'),
ref('base_consumer_digital_ad_performance_tiktok_spend'),
ref('base_consumer_digital_ad_performance_google_spend')
],
column_override={"digital_campaign_id": "TEXT"}
) }}
I am trying to use the column_override
arg in the dbt_utils union_relations
macro, but it doesn't seem to work when my code compiles.
(
select
cast('DBT_CCARREL.staging.base_consumer_digital_ad_performance_apple_ads_spend' as TEXT) as _dbt_source_relation,
cast("AD_DATE" as DATE) as "AD_DATE",
cast("ACQUISITION_PARTNER" as character varying(9)) as "ACQUISITION_PARTNER",
cast("DIGITAL_CAMPAIGN_ID" as NUMBER(38,0)) as "DIGITAL_CAMPAIGN_ID",
cast("DIGITAL_ADSET_ID" as NUMBER(38,0)) as "DIGITAL_ADSET_ID",
cast("DIGITAL_AD_ID" as NUMBER(38,0)) as "DIGITAL_AD_ID",
cast("IMPRESSIONS" as NUMBER(38,0)) as "IMPRESSIONS",
cast("CLICKS" as NUMBER(38,0)) as "CLICKS",
cast("SPEND" as NUMBER(18,4)) as "SPEND",
cast("AD_PERFORMANCE_UUID" as character varying(32)) as "AD_PERFORMANCE_UUID"
from DBT_CCARREL.staging.base_consumer_digital_ad_performance_apple_ads_spend
)
union all
Would love some help to understand what I am missing.
<details>
<summary>英文:</summary>
{{ dbt_utils.union_relations(
relations=[
ref('base_consumer_digital_ad_performance_apple_ads_spend'),
ref('base_consumer_digital_ad_performance_facebook_spend'),
ref('base_consumer_digital_ad_performance_tiktok_spend'),
ref('base_consumer_digital_ad_performance_google_spend')
],
column_override={"digital_campaign_id":"TEXT"}
) }}
I am trying to use the `column_override` arg in the dbt_utils `union_relations` macro, but it doesn't seem to work when my code compiles.
(
select
cast('DBT_CCARREL.staging.base_consumer_digital_ad_performance_apple_ads_spend' as TEXT) as _dbt_source_relation,
cast("AD_DATE" as DATE) as "AD_DATE" ,
cast("ACQUISITION_PARTNER" as character varying(9)) as "ACQUISITION_PARTNER" ,
cast("DIGITAL_CAMPAIGN_ID" as NUMBER(38,0)) as "DIGITAL_CAMPAIGN_ID" ,
cast("DIGITAL_ADSET_ID" as NUMBER(38,0)) as "DIGITAL_ADSET_ID" ,
cast("DIGITAL_AD_ID" as NUMBER(38,0)) as "DIGITAL_AD_ID" ,
cast("IMPRESSIONS" as NUMBER(38,0)) as "IMPRESSIONS" ,
cast("CLICKS" as NUMBER(38,0)) as "CLICKS" ,
cast("SPEND" as NUMBER(18,4)) as "SPEND" ,
cast("AD_PERFORMANCE_UUID" as character varying(32)) as "AD_PERFORMANCE_UUID"
from DBT_CCARREL.staging.base_consumer_digital_ad_performance_apple_ads_spend
)
union all
Would love some help to understand what I am missing.
</details>
# 答案1
**得分**: 0
从[源代码][1]中,我认为`column_override`是区分大小写的(因为在Python和Jinja中,字典访问是区分大小写的)。所以这应该可以工作:
```python
{{ dbt_utils.union_relations(
relations=[
ref('base_consumer_digital_ad_performance_apple_ads_spend'),
ref('base_consumer_digital_ad_performance_facebook_spend'),
ref('base_consumer_digital_ad_performance_tiktok_spend'),
ref('base_consumer_digital_ad_performance_google_spend')
],
column_override={"DIGITAL_CAMPAIGN_ID": "TEXT"}
) }}
英文:
From the source, I think column_override
is case-sensitve (since in Python and Jinja, dictionary access is case-sensitive). So this should work:
{{ dbt_utils.union_relations(
relations=[
ref('base_consumer_digital_ad_performance_apple_ads_spend'),
ref('base_consumer_digital_ad_performance_facebook_spend'),
ref('base_consumer_digital_ad_performance_tiktok_spend'),
ref('base_consumer_digital_ad_performance_google_spend')
],
column_override={"DIGITAL_CAMPAIGN_ID":"TEXT"}
) }}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论