-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from fishtown-analytics/fix/cast-in-union-tables
fix errant uses of safe_cast
- Loading branch information
Showing
7 changed files
with
47 additions
and
25 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
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,6 +1,6 @@ | ||
id,name,favorite_color | ||
1,"drew", | ||
2,"bob", | ||
3,"alice", | ||
1,,"green" | ||
2,,"pink" | ||
id,name,favorite_color,favorite_number | ||
1,"drew",,pi | ||
2,"bob",,e | ||
3,"alice",,4 | ||
1,,"green",7 | ||
2,,"pink",13 |
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,4 +1,4 @@ | ||
id,name | ||
1,drew | ||
2,bob | ||
3,alice | ||
id,name,favorite_number | ||
1,drew,pi | ||
2,bob,e | ||
3,alice,4 |
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,3 +1,3 @@ | ||
id,favorite_color | ||
1,green | ||
2,pink | ||
id,favorite_color,favorite_number | ||
1,green,7 | ||
2,pink,13 |
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,6 +1,29 @@ | ||
{{ dbt_utils.unpivot( | ||
table=ref('data_unpivot'), | ||
cast_to=dbt_utils.type_string(), | ||
exclude=['customer_id','created_at'] | ||
|
||
) }} | ||
-- snowflake messes with these tests pretty badly since the | ||
-- output of the macro considers the casing of the source | ||
-- table columns. Using some hacks here to get this to work, | ||
-- but we should consider lowercasing the unpivot macro output | ||
-- at some point in the future for consistency | ||
|
||
{% if target.name == 'snowflake' %} | ||
{% set exclude = ['CUSTOMER_ID', 'CREATED_AT'] %} | ||
{% else %} | ||
{% set exclude = ['customer_id', 'created_at'] %} | ||
{% endif %} | ||
|
||
select | ||
customer_id, | ||
created_at, | ||
case | ||
when '{{ target.name }}' = 'snowflake' then lower(field_name) | ||
else field_name | ||
end as field_name, | ||
value | ||
|
||
from ( | ||
{{ dbt_utils.unpivot( | ||
table=ref('data_unpivot'), | ||
cast_to=dbt_utils.type_string(), | ||
exclude=exclude | ||
) }} | ||
) as sbq |
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