-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add prefix and suffix arguments to star macro (#436)
* add prefix and suffix to star macro * add tests * snowflake casing?
- Loading branch information
1 parent
6ed3130
commit cffe8d5
Showing
5 changed files
with
27 additions
and
5 deletions.
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
4 changes: 4 additions & 0 deletions
4
integration_tests/data/sql/data_star_prefix_suffix_expected.csv
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,4 @@ | ||
prefix_field_1_suffix,prefix_field_2_suffix,prefix_field_3_suffix | ||
a,b,c | ||
d,e,f | ||
g,h,i |
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,13 @@ | ||
{% set prefix_with = 'prefix_' if target.type != 'snowflake' else 'PREFIX_' %} | ||
{% set suffix_with = '_suffix' if target.type != 'snowflake' else '_SUFFIX' %} | ||
|
||
with data as ( | ||
|
||
select | ||
{{ dbt_utils.star(from=ref('data_star'), prefix=prefix_with, suffix=suffix_with) }} | ||
|
||
from {{ ref('data_star') }} | ||
|
||
) | ||
|
||
select * from data |
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
cffe8d5
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.
@fivetran-jamie I think the automatic aliasing in the final select statement should be an optional feature of the macro - not sure about others but we don't only use the macro for sql generation but also for compiling col lists in jinja for manipulation.
We have patched this with
cffe8d5
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.
@jelstongreen this is being resolved in #468 - I've just checked in to see whether the person who made the PR is available to wrap it up or not.