Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test dynamic snowflake warehouse assignment via macro #1112

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions tests/functional/adapter/dynamic_table_tests/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,27 @@
) }}
select * from {{ ref('my_seed') }}
"""

MY_DYNAMIC_TABLE_WITH_DYNAMIC_WAREHOUSE = """
{{ config(
materialized = 'dynamic_table',
snowflake_warehouse = get_warehouse('xsmall'),
target_lag = 'downstream',
on_configuration_change = 'apply',
) }}

select * from {{ ref('my_seed') }}

"""

GET_WAREHOUSE_MACRO = """
{% macro get_warehouse(size) %}
{% set warehouses = {
'xsmall': 'DBT_TESTING',
'small': 'DBT_TESTING',
'medium': 'DBT_TESTING',
'large': 'DBT_TESTING',
} %}
{{ return(warehouses[size]) }}
{% endmacro %}
"""
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
MY_SEED,
MY_TABLE,
MY_VIEW,
MY_DYNAMIC_TABLE_WITH_DYNAMIC_WAREHOUSE,
GET_WAREHOUSE_MACRO,
)
from tests.functional.adapter.dynamic_table_tests.utils import query_relation_type

Expand Down Expand Up @@ -184,3 +186,25 @@ def test_dynamic_table_only_updates_after_refresh(self, project, my_dynamic_tabl
# new records were inserted in the table but didn't show up in the view until it was refreshed
assert table_start < table_mid == table_end
assert view_start == view_mid < view_end


class TestSnowflakeDynamicTableWithDynamicWarehouse:
@pytest.fixture(scope="class")
def macros(self):
return {"get_warehouse.sql": GET_WAREHOUSE_MACRO}

@pytest.fixture(scope="class", autouse=True)
def seeds(self):
return {"my_seed.csv": MY_SEED}

@pytest.fixture(scope="class", autouse=True)
def models(self):
yield {
"my_table.sql": MY_TABLE,
"my_view.sql": MY_VIEW,
"my_dynamic_table_with_dynamic_warehouse.sql": MY_DYNAMIC_TABLE_WITH_DYNAMIC_WAREHOUSE,
}

def test_dynamic_table_create(self, project):
run_dbt(["seed"])
run_dbt(["run"])
Loading