-
-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow the use of libraries in macro definitions (#3803)
* Allow the use of libraries in macro definitions * Move library usage in macro test to separate test case
- Loading branch information
Showing
7 changed files
with
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{ query_proxy('xyz') }} |
24 changes: 24 additions & 0 deletions
24
test/fixtures/templater/jinja_r_library_in_macro/jinja.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,24 @@ | ||
file: | ||
statement: | ||
select_statement: | ||
select_clause: | ||
keyword: SELECT | ||
select_clause_element: | ||
numeric_literal: '56' | ||
from_clause: | ||
keyword: FROM | ||
from_expression: | ||
from_expression_element: | ||
table_expression: | ||
table_reference: | ||
- naked_identifier: sch1 | ||
- dot: . | ||
- naked_identifier: foo_xyz | ||
where_clause: | ||
keyword: WHERE | ||
expression: | ||
column_reference: | ||
naked_identifier: x | ||
comparison_operator: | ||
raw_comparison_operator: '=' | ||
numeric_literal: '23' |
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,6 @@ | ||
"""Module used to test bar within the jinja template.""" | ||
|
||
|
||
def equals(col, val): | ||
"""Return a string that has col = val.""" | ||
return f"{col} = {val}" |
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,7 @@ | ||
"""Module used to test foo within the jinja template.""" | ||
schema = "sch1" | ||
|
||
|
||
def table(name): | ||
"""Return the parameter with foo_ in front of it.""" | ||
return f"foo_{name}" |
1 change: 1 addition & 0 deletions
1
test/fixtures/templater/jinja_r_library_in_macro/libs/not_python.txt
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 @@ | ||
I am just a text file |
4 changes: 4 additions & 0 deletions
4
test/fixtures/templater/jinja_r_library_in_macro/macros/query_proxy.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 query_proxy(tbl) %}SELECT 56 | ||
FROM {{ foo.schema }}.{{ foo.bar("xyz") }} | ||
WHERE {{ bar.equals("x", 23) }} | ||
{% endmacro %} |