-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 #2036 from fishtown-analytics/feature/toyaml-fromyaml
add toyaml/fromyaml (#1911)
- Loading branch information
Showing
5 changed files
with
70 additions
and
1 deletion.
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
19 changes: 19 additions & 0 deletions
19
test/integration/013_context_var_tests/test_context_members.py
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,19 @@ | ||
from test.integration.base import DBTIntegrationTest, use_profile | ||
|
||
|
||
class TestContextVars(DBTIntegrationTest): | ||
@property | ||
def schema(self): | ||
return "context_members_013" | ||
|
||
@property | ||
def models(self): | ||
return "context-member-models" | ||
|
||
@property | ||
def project_config(self): | ||
return {'test-paths': ['tests']} | ||
|
||
@use_profile('postgres') | ||
def test_json_data_tests_postgres(self): | ||
self.assertEqual(len(self.run_dbt(['test'])), 2) |
14 changes: 14 additions & 0 deletions
14
test/integration/013_context_var_tests/tests/from_yaml.sql
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,14 @@ | ||
{% set simplest = (fromyaml('a: 1') == {'a': 1}) %} | ||
{% set nested_data %} | ||
a: | ||
b: | ||
- c: 1 | ||
d: 2 | ||
- c: 3 | ||
d: 4 | ||
{% endset %} | ||
{% set nested = (fromyaml(nested_data) == {'a': {'b': [{'c': 1, 'd': 2}, {'c': 3, 'd': 4}]}}) %} | ||
|
||
(select 'simplest' as name {% if simplest %}limit 0{% endif %}) | ||
union all | ||
(select 'nested' as name {% if nested %}limit 0{% endif %}) |
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,17 @@ | ||
|
||
{% set simplest = (toyaml({'a': 1}) == 'a: 1\n') %} | ||
{% set default_sort = (toyaml({'b': 2, 'a': 1}) == 'b: 2\na: 1\n') %} | ||
{% set unsorted = (toyaml({'b': 2, 'a': 1}, sort_keys=False) == 'b: 2\na: 1\n') %} | ||
{% set sorted = (toyaml({'b': 2, 'a': 1}, sort_keys=True) == 'a: 1\nb: 2\n') %} | ||
{% set default_results = (toyaml({'a': adapter}, 'failed') == 'failed') %} | ||
|
||
(select 'simplest' as name {% if simplest %}limit 0{% endif %}) | ||
union all | ||
(select 'default_sort' as name {% if default_sort %}limit 0{% endif %}) | ||
union all | ||
(select 'unsorted' as name {% if unsorted %}limit 0{% endif %}) | ||
union all | ||
(select 'sorted' as name {% if sorted %}limit 0{% endif %}) | ||
union all | ||
(select 'default_results' as name {% if default_results %}limit 0{% endif %}) | ||
|