Skip to content

Commit

Permalink
Merge pull request dbt-labs#9 from fishtown-analytics/star
Browse files Browse the repository at this point in the history
add star macro
  • Loading branch information
drewbanin authored Aug 15, 2017
2 parents 8a80519 + 0d40783 commit 1da4081
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions macros/start.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% macro star(from, except=[]) -%}

{%- set table_parts = from.split('.') %}
{%- set include_cols = [] %}
{%- set cols = adapter.get_columns_in_table(*table_parts) %}
{%- for col in cols -%}

{%- if col.column not in except -%}
{% set _ = include_cols.append(col.column) %}

{%- endif %}
{%- endfor %}

{%- for col in include_cols %}

"{{ col }}" {% if not loop.last %},
{% endif %}

{%- endfor -%}
{%- endmacro %}

0 comments on commit 1da4081

Please sign in to comment.