-
Notifications
You must be signed in to change notification settings - Fork 497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update star.sql to allow for non-quote wrapped column names #706
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
77361a4
Update star.sql
CR-Lough 4665156
Update star.sql
CR-Lough 69de573
feat: add testing to star macro
76d0330
chore: update schema.yml
37a2b69
Update star.sql
CR-Lough bb639d7
chore: update star.sql and schema.yml
c177a59
chore: resolve diff
5e2451e
chore: update star.sql to trim blank space
6d00df1
Update README.md
CR-Lough c57fce7
Update README.md
CR-Lough File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
column_one | ||
a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
select | ||
{{ dbt.string_literal(adapter.quote("column_one")) | lower }} as expected, | ||
{{ dbt.string_literal(dbt_utils.star(from=ref('data_star_quote_identifiers'), quote_identifiers=True)) | trim | lower }} as actual | ||
|
||
union all | ||
|
||
select | ||
{{ dbt.string_literal("column_one") | lower }} as expected, | ||
{{ dbt.string_literal(dbt_utils.star(from=ref('data_star_quote_identifiers'), quote_identifiers=False)) | trim | lower }} as actual |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,30 @@ | ||
{% macro star(from, relation_alias=False, except=[], prefix='', suffix='') -%} | ||
{{ return(adapter.dispatch('star', 'dbt_utils')(from, relation_alias, except, prefix, suffix)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__star(from, relation_alias=False, except=[], prefix='', suffix='') -%} | ||
{%- do dbt_utils._is_relation(from, 'star') -%} | ||
{%- do dbt_utils._is_ephemeral(from, 'star') -%} | ||
|
||
{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #} | ||
{%- if not execute -%} | ||
{{ return('*') }} | ||
{%- endif -%} | ||
|
||
{% set cols = dbt_utils.get_filtered_columns_in_relation(from, except) %} | ||
|
||
{%- if cols|length <= 0 -%} | ||
{{- return('*') -}} | ||
{%- else -%} | ||
{%- for col in cols %} | ||
{%- if relation_alias %}{{ relation_alias }}.{% else %}{%- endif -%}{{ adapter.quote(col)|trim }} {%- if prefix!='' or suffix!='' %} as {{ adapter.quote(prefix ~ col ~ suffix)|trim }} {%- endif -%} | ||
{%- if not loop.last %},{{ '\n ' }}{% endif %} | ||
{%- endfor -%} | ||
{% endif %} | ||
{%- endmacro %} | ||
{% macro star(from, relation_alias=False, except=[], prefix='', suffix='', quote_identifiers=True) -%} | ||
{{ return(adapter.dispatch('star', 'dbt_utils')(from, relation_alias, except, prefix, suffix, quote_identifiers)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__star(from, relation_alias=False, except=[], prefix='', suffix='', quote_identifiers=True) -%} | ||
{%- do dbt_utils._is_relation(from, 'star') -%} | ||
{%- do dbt_utils._is_ephemeral(from, 'star') -%} | ||
|
||
{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #} | ||
{%- if not execute -%} | ||
{{ return('*') }} | ||
{%- endif -%} | ||
|
||
{% set cols = dbt_utils.get_filtered_columns_in_relation(from, except) %} | ||
|
||
{%- if cols|length <= 0 -%} | ||
{{- return('*') -}} | ||
{%- else -%} | ||
{%- for col in cols %} | ||
{%- if relation_alias %}{{ relation_alias }}.{% else %}{%- endif -%} | ||
{%- if quote_identifiers -%} | ||
{{ adapter.quote(col)|trim }} {%- if prefix!='' or suffix!='' %} as {{ adapter.quote(prefix ~ col ~ suffix)|trim }} {%- endif -%} | ||
{%- else -%} | ||
{{ col|trim }} {%- if prefix!='' or suffix!='' %} as {{ (prefix ~ col ~ suffix)|trim }} {%- endif -%} | ||
{% endif %} | ||
{%- if not loop.last %},{{ '\n ' }}{%- endif -%} | ||
{%- endfor -%} | ||
{% endif %} | ||
{%- endmacro %} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first time I read this, I thought it meant quoting the optional
relation_alias
. But re-reading it, I realize it means the alias it is assigned (if any).