-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ADAP-971: Fix issue where dynamic tables were returning null for type (…
…#818) * changelog * create test demonstrating the issue * map nulls to dynamic table
- Loading branch information
1 parent
3f297c8
commit 1f123b7
Showing
4 changed files
with
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Fixes | ||
body: Dynamic tables now show the proper type in catalog queries | ||
time: 2023-10-30T21:21:51.220225-04:00 | ||
custom: | ||
Author: mikealfare | ||
Issue: "817" |
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,32 @@ | ||
MY_SEED = """ | ||
id,value | ||
1,100 | ||
2,200 | ||
3,300 | ||
""".strip() | ||
|
||
|
||
MY_TABLE = """ | ||
{{ config( | ||
materialized='table', | ||
) }} | ||
select * from {{ ref('my_seed') }} | ||
""" | ||
|
||
|
||
MY_VIEW = """ | ||
{{ config( | ||
materialized='view', | ||
) }} | ||
select * from {{ ref('my_seed') }} | ||
""" | ||
|
||
|
||
MY_DYNAMIC_TABLE = """ | ||
{{ config( | ||
materialized='dynamic_table', | ||
snowflake_warehouse='DBT_TESTING', | ||
target_lag='30 minutes', | ||
) }} | ||
select * from {{ ref('my_seed') }} | ||
""" |
44 changes: 44 additions & 0 deletions
44
tests/functional/adapter/catalog_tests/test_relation_types.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,44 @@ | ||
from dbt.contracts.results import CatalogArtifact | ||
from dbt.tests.util import run_dbt | ||
import pytest | ||
|
||
from tests.functional.adapter.catalog_tests import files | ||
|
||
|
||
class TestCatalogRelationTypes: | ||
@pytest.fixture(scope="class", autouse=True) | ||
def seeds(self): | ||
return {"my_seed.csv": files.MY_SEED} | ||
|
||
@pytest.fixture(scope="class", autouse=True) | ||
def models(self): | ||
yield { | ||
"my_table.sql": files.MY_TABLE, | ||
"my_view.sql": files.MY_VIEW, | ||
"my_dynamic_table.sql": files.MY_DYNAMIC_TABLE, | ||
} | ||
|
||
@pytest.fixture(scope="class", autouse=True) | ||
def docs(self, project): | ||
run_dbt(["seed"]) | ||
run_dbt(["run"]) | ||
yield run_dbt(["docs", "generate"]) | ||
|
||
@pytest.mark.parametrize( | ||
"node_name,relation_type", | ||
[ | ||
("seed.test.my_seed", "BASE TABLE"), | ||
("model.test.my_table", "BASE TABLE"), | ||
("model.test.my_view", "VIEW"), | ||
("model.test.my_dynamic_table", "DYNAMIC TABLE"), | ||
], | ||
) | ||
def test_relation_types_populate_correctly( | ||
self, docs: CatalogArtifact, node_name: str, relation_type: str | ||
): | ||
""" | ||
This test addresses: https://github.com/dbt-labs/dbt-snowflake/issues/817 | ||
""" | ||
assert node_name in docs.nodes | ||
node = docs.nodes[node_name] | ||
assert node.metadata.type == relation_type |