Skip to content

Commit

Permalink
add iceberg dynamic tables to existing dynamic table tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare committed Sep 20, 2024
1 parent 4373bdd commit 951a2ab
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/functional/relation_tests/dynamic_table_tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,31 @@
) }}
select * from {{ ref('my_seed') }}
"""


DYNAMIC_ICEBERG_TABLE_ALTER = """
{{ config(
materialized='dynamic_table',
snowflake_warehouse='DBT_TESTING',
target_lag='5 minutes',
refresh_mode='INCREMENTAL',
table_format="iceberg",
external_volume="s3_iceberg_snow",
base_location_subpath="subpath",
) }}
select * from {{ ref('my_seed') }}
"""


DYNAMIC_ICEBERG_TABLE_REPLACE = """
{{ config(
materialized='dynamic_table',
snowflake_warehouse='DBT_TESTING',
target_lag='2 minutes',
refresh_mode='FULL',
table_format="iceberg",
external_volume="s3_iceberg_snow",
base_location_subpath="subpath",
) }}
select * from {{ ref('my_seed') }}
"""
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def models(self):
yield {
"dynamic_table_alter.sql": models.DYNAMIC_TABLE,
"dynamic_table_replace.sql": models.DYNAMIC_TABLE,
"dynamic_table_iceberg_alter.sql": models.DYNAMIC_ICEBERG_TABLE,
"dynamic_table_iceberg_replace.sql": models.DYNAMIC_ICEBERG_TABLE,
}

@pytest.fixture(scope="function", autouse=True)
Expand All @@ -33,11 +35,17 @@ def setup_method(self, project, setup_class):

update_model(project, "dynamic_table_alter", models.DYNAMIC_TABLE_ALTER)
update_model(project, "dynamic_table_replace", models.DYNAMIC_TABLE_REPLACE)
update_model(project, "dynamic_table_iceberg_alter", models.DYNAMIC_ICEBERG_TABLE_ALTER)
update_model(
project, "dynamic_table_iceberg_replace", models.DYNAMIC_ICEBERG_TABLE_REPLACE
)

yield

update_model(project, "dynamic_table_alter", models.DYNAMIC_TABLE)
update_model(project, "dynamic_table_replace", models.DYNAMIC_TABLE)
update_model(project, "dynamic_table_iceberg_alter", models.DYNAMIC_ICEBERG_TABLE)
update_model(project, "dynamic_table_iceberg_replace", models.DYNAMIC_ICEBERG_TABLE)

@staticmethod
def assert_changes_are_applied(project):
Expand All @@ -51,6 +59,16 @@ def assert_changes_are_applied(project):
assert replaced.target_lag == "2 minutes"
assert replaced.refresh_mode == "FULL" # this updated

altered_iceberg = describe_dynamic_table(project, "dynamic_table_iceberg_alter")
assert altered_iceberg.snowflake_warehouse == "DBT_TESTING"
assert altered_iceberg.target_lag == "5 minutes" # this updated
assert altered_iceberg.refresh_mode == "INCREMENTAL"

replaced_iceberg = describe_dynamic_table(project, "dynamic_table_iceberg_replace")
assert replaced_iceberg.snowflake_warehouse == "DBT_TESTING"
assert replaced_iceberg.target_lag == "2 minutes"
assert replaced_iceberg.refresh_mode == "FULL" # this updated

@staticmethod
def assert_changes_are_not_applied(project):
altered = describe_dynamic_table(project, "dynamic_table_alter")
Expand All @@ -63,6 +81,18 @@ def assert_changes_are_not_applied(project):
assert replaced.target_lag == "2 minutes"
assert replaced.refresh_mode == "INCREMENTAL" # this would have updated, but didn't

altered_iceberg = describe_dynamic_table(project, "dynamic_table_iceberg_alter")
assert altered_iceberg.snowflake_warehouse == "DBT_TESTING"
assert altered_iceberg.target_lag == "2 minutes" # this would have updated, but didn't
assert altered_iceberg.refresh_mode == "INCREMENTAL"

replaced_iceberg = describe_dynamic_table(project, "dynamic_table_iceberg_replace")
assert replaced_iceberg.snowflake_warehouse == "DBT_TESTING"
assert replaced_iceberg.target_lag == "2 minutes"
assert (
replaced_iceberg.refresh_mode == "INCREMENTAL"
) # this would have updated, but didn't

def test_full_refresh_is_always_successful(self, project):
# this always passes and always changes the configuration, regardless of on_configuration_change
# and regardless of whether the changes require a replace versus an alter
Expand Down

0 comments on commit 951a2ab

Please sign in to comment.