-
Notifications
You must be signed in to change notification settings - Fork 114
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 #362 from alexsubota/apply-query-settings-for-empt…
…y-model Apply query settings for empty table model
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 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
65 changes: 65 additions & 0 deletions
65
tests/integration/adapter/query_settings/test_query_settings.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,65 @@ | ||
import pytest | ||
from dbt.tests.util import run_dbt | ||
|
||
nullable_column_model = """ | ||
{{ | ||
config( | ||
materialized='table', | ||
query_settings={ | ||
'join_use_nulls': 1 | ||
} | ||
) | ||
}} | ||
select t2.id as test_id | ||
from (select 1 as id) t1 | ||
left join (select 2 as id) t2 | ||
on t1.id=t2.id | ||
""" | ||
|
||
|
||
class TestNullableColumnJoin: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"nullable_column_model.sql": nullable_column_model, | ||
} | ||
|
||
def test_nullable_column_join(self, project): | ||
run_dbt(["run", "--select", "nullable_column_model"]) | ||
result = project.run_sql( | ||
"select isNullable(test_id) as is_nullable_column from nullable_column_model", | ||
fetch="one", | ||
) | ||
assert result[0] == 1 | ||
|
||
|
||
not_nullable_column_model = """ | ||
{{ | ||
config( | ||
materialized='table', | ||
query_settings={ | ||
'join_use_nulls': 0 | ||
} | ||
) | ||
}} | ||
select t2.id as test_id | ||
from (select 1 as id) t1 | ||
left join (select 2 as id) t2 | ||
on t1.id=t2.id | ||
""" | ||
|
||
|
||
class TestNotNullableColumnJoin: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"not_nullable_column_model.sql": not_nullable_column_model, | ||
} | ||
|
||
def test_nullable_column_join(self, project): | ||
run_dbt(["run", "--select", "not_nullable_column_model"]) | ||
result = project.run_sql( | ||
"select isNullable(test_id) as is_nullable_column from not_nullable_column_model", | ||
fetch="one", | ||
) | ||
assert result[0] == 0 |