forked from tconbeer/sqlfmt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix tconbeer#471: handle nested dictionary in jinja expression
- Loading branch information
1 parent
614f526
commit e4007ff
Showing
3 changed files
with
50 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
38 changes: 38 additions & 0 deletions
38
tests/data/unit_tests/test_nested_dictionary/test_nested_dictionary.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,38 @@ | ||
-- source: https://github.com/tconbeer/sqlfmt/issues/471 | ||
{{ | ||
config( | ||
materialized='incremental', | ||
incremental_strategy='insert_overwrite', | ||
external_location=generate_external_location("baz", "datalake/producer=foo/object=bar"), | ||
partitioned_by=['batch_date'], | ||
lf_tags_config={ | ||
'enabled': true, | ||
'tags': { | ||
'domain': 'foo', | ||
'sensitivity': 'public' | ||
} | ||
} | ||
) | ||
}} | ||
select | ||
batch_date | ||
from | ||
{{ ref('bar') }} | ||
{% if is_incremental() %} | ||
where batch_date = '{{ var("ds") }}' | ||
{% endif %} | ||
)))))__SQLFMT_OUTPUT__((((( | ||
-- source: https://github.com/tconbeer/sqlfmt/issues/471 | ||
{{ | ||
config( | ||
materialized="incremental", | ||
incremental_strategy="insert_overwrite", | ||
external_location=generate_external_location("baz", "datalake/producer=foo/object=bar"), | ||
partitioned_by=["batch_date"], | ||
lf_tags_config={"enabled": true, "tags": {"domain": "foo", "sensitivity": "public"}}, | ||
) | ||
}} | ||
select batch_date | ||
from {{ ref("bar") }} | ||
{% if is_incremental() %} where batch_date = '{{ var("ds") }}' {% 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,11 @@ | ||
from sqlfmt.api import format_string | ||
from sqlfmt.mode import Mode | ||
from tests.util import read_test_data | ||
|
||
|
||
def test_handle_nested_dictionary_in_jinja_expression() -> None: | ||
source_string, expected_string = read_test_data( | ||
"unit_tests/test_nested_dictionary/test_nested_dictionary.sql" | ||
) | ||
actual = format_string(source_string, mode=Mode(line_length=100)) | ||
assert expected_string == actual |