Description
Is there an existing feature request for this?
- I have searched the existing issues
Describe the Feature
Background
stg_microsoft_ads__ad_history_tmp
contains several columns that contain information related the ad, as is delivered from the initial report.
title_part_1
title_part_2
title_part_3
domain
type
Currently, get_ad_history_columns()
only selects title_part_1
and type
from that list
In many cases with this ad platform, title_part_1
is not a good differentiator and the better ad_name
has been configured to fit in a different column. Additionally, when type = 'Responsive Search Ad'
title_part_1
is always null
.
Proposed feature
Allow users to configure how the ad_name
is determined from any of the fields in the list.
How would you implement this feature?
CAVEAT: This is code I haven't tested, and all snippets are for discussion purposes
- Update
get_ad_history_columns()
to include additional columns
{% set columns = [
{"name": "id", "datatype": dbt.type_int()},
{"name": "title_part_1", "datatype": dbt.type_string()},
{"name": "final_url", "datatype": dbt.type_string()},
{"name": "ad_group_id", "datatype": dbt.type_int()},
{"name": "modified_time", "datatype": dbt.type_timestamp()},
{"name": "status", "datatype": dbt.type_string()},
{"name": "type", "datatype": dbt.type_string()},
{"name": "title_part_2", "datatype": dbt.type_string()},
{"name": "title_part_3", "datatype": dbt.type_string()},
{"name": "title", "datatype": dbt.type_string()},
{"name": "domain", "datatype": dbt.type_string()}
] %}
- create a variable
microsoft_ads_source__ad_name_selector
with a default value oftitle_part_1
- Reference the ad name selector in
stg_microsoft_ads__ad_history
instead of explicitly referencingtitle_part_1
...
final as (
select
source_relation,
id as ad_id,
{{ var.microsoft_ads_source__ad_name_selector }} as ad_name,
final_url,
ad_group_id,
...
Describe alternatives you've considered
Alternative...
-
Same as 1 above
-
Create a new macro
generate_ad_name()
with a sensible default - title_part_1 so it's a non-breaking change
{% macro generate_ad_name() %}
{{ return(adapter.dispatch('my_macro', 'microsoft_ads_source')()) }}
{% endmacro %}
{% macro default__generate_ad_name() %}
title_part_1
{% endmacro %}
- Call this macro in
stg_microsoft_ads__ad_history
instead of explicitly referencingtitle_part_1
...
final as (
select
source_relation,
id as ad_id,
{{ microsoft_ads_source.generate_ad_name}} as ad_name,
final_url,
ad_group_id,
...
With this setup (or something similar), I think a user should then be able to override the macro.
Are you interested in contributing this feature?
- Yes.
- Yes, but I will need assistance.
- No.
Anything else?
No response