Skip to content

Commit

Permalink
macro updates
Browse files Browse the repository at this point in the history
  • Loading branch information
fivetran-catfritz committed Jul 1, 2024
1 parent 4a252f2 commit f47bd73
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions macros/coalesce_w_renamed_col.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{% macro coalesce_w_renamed_col(original_column_name, datatype=dbt.type_string()) %}
{% macro coalesce_w_renamed_col(original_column_name, datatype=dbt.type_string(), alias=original_column_name, renamed_column_name=original_column_name.replace('_', '')) %}
{# This macro accomodates Fivetran connectors that keep the original salesforce field naming conventions without underscores #}

{%- set renamed_col = original_column_name.replace('_', '') -%}

coalesce(cast({{ renamed_col }} as {{ datatype }}),
coalesce(cast({{ renamed_column_name }} as {{ datatype }}),
cast({{ original_column_name }} as {{ datatype }}))
as {{ original_column_name }}
as {{ alias }}

{%- endmacro %}

0 comments on commit f47bd73

Please sign in to comment.