Skip to content

Commit

Permalink
Merge pull request #79 from dwallace0723/add-star-optional-qualifier
Browse files Browse the repository at this point in the history
Star macro optional alias argument
  • Loading branch information
drewbanin authored Sep 14, 2018
2 parents c82b0bf + 3638102 commit bcbe57c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Usage:
```

#### star ([source](macros/sql/star.sql))
This macro generates a list of all fields that exist in the `from` relation, excluding any fields listed in the `except` argument. The construction is identical to `select * from {{ref('my_model')}}`, replacing star (`*`) with the star macro.
This macro generates a list of all fields that exist in the `from` relation, excluding any fields listed in the `except` argument. The construction is identical to `select * from {{ref('my_model')}}`, replacing star (`*`) with the star macro. This macro also has an optional `relation_alias` argument that will prefix all generated fields with an alias.

Usage:
```
Expand Down
4 changes: 2 additions & 2 deletions macros/sql/star.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% macro star(from, except=[]) -%}
{% macro star(from, relation_alias=False, except=[]) -%}

{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}
{%- if not execute -%}
Expand All @@ -23,7 +23,7 @@

{%- for col in include_cols %}

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

{%- endfor -%}
Expand Down

0 comments on commit bcbe57c

Please sign in to comment.