-
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.
Merge branch 'main' into paw/metadata-freshness
- Loading branch information
Showing
5 changed files
with
114 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Fixes | ||
body: Make python models use transient config | ||
time: 2023-09-18T10:57:21.113134+12:00 | ||
custom: | ||
Author: jeremyyeo | ||
Issue: "776" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# <temporary>_<transient>_table | ||
TRANSIENT_TRUE_TABLE = """ | ||
import pandas | ||
def model(dbt, session): | ||
dbt.config(transient=True) | ||
return pandas.DataFrame([[1,2]] * 10, columns=['test', 'test2']) | ||
""" | ||
|
||
|
||
TRANSIENT_FALSE_TABLE = """ | ||
import pandas | ||
def model(dbt, session): | ||
dbt.config(transient=False) | ||
return pandas.DataFrame([[1,2]] * 10, columns=['test', 'test2']) | ||
""" | ||
|
||
|
||
TRANSIENT_NONE_TABLE = """ | ||
import pandas | ||
def model(dbt, session): | ||
dbt.config(transient=None) | ||
return pandas.DataFrame([[1,2]] * 10, columns=['test', 'test2']) | ||
""" | ||
|
||
|
||
TRANSIENT_UNSET_TABLE = """ | ||
import pandas | ||
def model(dbt, session): | ||
return pandas.DataFrame([[1,2]] * 10, columns=['test', 'test2']) | ||
""" | ||
|
||
|
||
MACRO__DESCRIBE_TABLES = """ | ||
{% macro snowflake__test__describe_tables() %} | ||
{%- set _sql -%} | ||
show tables; | ||
select "name", "kind" | ||
from table(result_scan(last_query_id())) | ||
{%- endset %} | ||
{% set _table = run_query(_sql) %} | ||
{% do return(_table) %} | ||
{% endmacro %} | ||
""" |
35 changes: 35 additions & 0 deletions
35
tests/functional/adapter/python_model_tests/test_table_type.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,35 @@ | ||
import pytest | ||
|
||
from dbt.tests.util import run_dbt | ||
|
||
from tests.functional.adapter.python_model_tests import _files | ||
|
||
|
||
class TestTableType: | ||
@pytest.fixture(scope="class") | ||
def macros(self): | ||
return {"snowflake__test__describe_tables.sql": _files.MACRO__DESCRIBE_TABLES} | ||
|
||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
# <temporary>_<transient>_table | ||
"TRANSIENT_TRUE_TABLE.py": _files.TRANSIENT_TRUE_TABLE, | ||
"TRANSIENT_FALSE_TABLE.py": _files.TRANSIENT_FALSE_TABLE, | ||
"TRANSIENT_NONE_TABLE.py": _files.TRANSIENT_NONE_TABLE, | ||
"TRANSIENT_UNSET_TABLE.py": _files.TRANSIENT_UNSET_TABLE, | ||
} | ||
|
||
def test_expected_table_types_are_created(self, project): | ||
run_dbt(["run"]) | ||
expected_table_types = { | ||
# (name, kind) - TABLE == permanent | ||
("TRANSIENT_TRUE_TABLE", "TRANSIENT"), | ||
("TRANSIENT_FALSE_TABLE", "TABLE"), | ||
("TRANSIENT_NONE_TABLE", "TABLE"), | ||
("TRANSIENT_UNSET_TABLE", "TRANSIENT"), | ||
} | ||
with project.adapter.connection_named("__test"): | ||
agate_table = project.adapter.execute_macro("snowflake__test__describe_tables") | ||
actual_table_types = {(row.get("name"), row.get("kind")) for row in agate_table.rows} | ||
assert actual_table_types == expected_table_types |