-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix some issues around global-scoped vars
Fix global-level var rewriting from v2 -> v1 Add top-level vars to more lookup fields When a user calls var() in a `generate_*_name` macro, on failure it now raises (like at runtime) When a node has no FQN, pretend the FQN is just the package name when returning vars Add tests
- Loading branch information
Jacob Beck
committed
May 20, 2020
1 parent
a8f8708
commit e2cd45b
Showing
18 changed files
with
350 additions
and
46 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
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
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
test/integration/013_context_var_tests/bad-generate-macros/generate_names.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,4 @@ | ||
{% macro generate_schema_name(custom_schema_name, node) -%} | ||
{% do var('somevar') %} | ||
{% do return(dbt.generate_schema_name(custom_schema_name, node)) %} | ||
{%- endmacro %} |
2 changes: 2 additions & 0 deletions
2
test/integration/013_context_var_tests/dependency-data/root_model_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,2 @@ | ||
first_dep_global,from_root | ||
dep_never_overridden,root_root_value |
3 changes: 3 additions & 0 deletions
3
test/integration/013_context_var_tests/dependency-models/inside/model.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,3 @@ | ||
select | ||
'{{ var("first_dep_override") }}' as first_dep_global, | ||
'{{ var("from_root_to_root") }}' as from_root |
2 changes: 2 additions & 0 deletions
2
test/integration/013_context_var_tests/first_dependency/data/first_dep_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,2 @@ | ||
first_dep_global,from_root | ||
first_dep_global_value_overridden,root_first_value |
27 changes: 27 additions & 0 deletions
27
test/integration/013_context_var_tests/first_dependency/dbt_project.yml
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,27 @@ | ||
|
||
name: 'first_dep' | ||
version: '1.0' | ||
config-version: 2 | ||
|
||
profile: 'default' | ||
|
||
source-paths: ["models"] | ||
analysis-paths: ["analysis"] | ||
test-paths: ["tests"] | ||
data-paths: ["data"] | ||
macro-paths: ["macros"] | ||
|
||
require-dbt-version: '>=0.1.0' | ||
|
||
target-path: "target" # directory which will store compiled SQL files | ||
clean-targets: # directories to be removed by `dbt clean` | ||
- "target" | ||
- "dbt_modules" | ||
|
||
vars: | ||
first_dep: | ||
first_dep_global: 'first_dep_global_value_overridden' | ||
|
||
|
||
seeds: | ||
quote_columns: False |
3 changes: 3 additions & 0 deletions
3
test/integration/013_context_var_tests/first_dependency/models/nested/first_dep_model.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,3 @@ | ||
select | ||
'{{ var("first_dep_global") }}' as first_dep_global, | ||
'{{ var("from_root_to_first") }}' as from_root |
2 changes: 2 additions & 0 deletions
2
test/integration/013_context_var_tests/second_dependency_v1/data/second_dep_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,2 @@ | ||
from_root,from_second | ||
root_second_value,second_to_second_override_value |
43 changes: 43 additions & 0 deletions
43
test/integration/013_context_var_tests/second_dependency_v1/dbt_project.yml
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,43 @@ | ||
|
||
name: 'second_dep' | ||
version: '1.0' | ||
|
||
profile: 'default' | ||
|
||
source-paths: ["models"] | ||
analysis-paths: ["analysis"] | ||
test-paths: ["tests"] | ||
data-paths: ["data"] | ||
macro-paths: ["macros"] | ||
|
||
require-dbt-version: '>=0.1.0' | ||
|
||
target-path: "target" # directory which will store compiled SQL files | ||
clean-targets: # directories to be removed by `dbt clean` | ||
- "target" | ||
- "dbt_modules" | ||
|
||
|
||
seeds: | ||
quote_columns: False | ||
|
||
|
||
models: | ||
second_dep: | ||
vars: | ||
from_second_to_second: 'never_see_me' | ||
inner: | ||
vars: | ||
from_second_to_second: 'second_to_second_override_value' | ||
first_dep: | ||
vars: | ||
from_second_to_first: 'never_see_me_either' | ||
nested: | ||
vars: | ||
from_second_to_first: 'second_to_first_override_value' | ||
test: | ||
vars: | ||
from_second_to_root: 'also_never_see_me' | ||
inside: | ||
vars: | ||
from_second_to_root: 'second_to_root_override_value' |
3 changes: 3 additions & 0 deletions
3
.../integration/013_context_var_tests/second_dependency_v1/models/inner/second_dep_model.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,3 @@ | ||
select | ||
'{{ var("from_root_to_second") }}' as from_root, | ||
'{{ var("from_second_to_second") }}' as from_second |
Oops, something went wrong.