Prefix Columns Maco

A self-explanatory macro for prefixing all columns.

{%- macro prefix_columns(ref, prefix) -%}
    -- prefixes all columns in ref
    {%- set cols = adapter.get_columns_in_relation(ref) -%}

    -- select all columns from ref1
    {% for col in cols %}
        {% if not loop.last %}
            table1.{{}} as {{prefix}}{{}},
        {% else %}
            table1.{{}} as {{prefix}}{{}}
        {% endif %}
    {% endfor %}
    {{ ref }} as table1
{%- endmacro -%}

Hey @kevincmclaughlin. That’s always a good use case.
I guess the utils star macro could be used as well. Its a bit more powerful.
For further macros I’d also recommend to compile your code in action to see how blank lines and comments turn out. A bit of “-%}” and the distinction between sql comments (–,/**/) and jinja comments ({##}) could improve the compiled sql.