Skip to content

Commit

Permalink
Dynamic Table testing improvements (#1187)
Browse files Browse the repository at this point in the history
* move dynamic table tests down into the relation tests folder
* make utils more generic, move out of dynamic table tests
* add init files for namespacing in test discovery
* remove 2024_03 bundle items
  • Loading branch information
mikealfare authored Sep 20, 2024
1 parent 084674f commit 34c4442
Show file tree
Hide file tree
Showing 12 changed files with 341 additions and 575 deletions.
35 changes: 11 additions & 24 deletions dbt/adapters/snowflake/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,28 +258,20 @@ def list_relations_without_caching(
return []
raise

# this can be reduced to always including `is_dynamic` once bundle `2024_03` is mandatory
columns = ["database_name", "schema_name", "name", "kind"]
if "is_dynamic" in schema_objects.column_names:
columns.append("is_dynamic")
if "is_iceberg" in schema_objects.column_names:
# this can be collapsed once Snowflake adds is_iceberg to show objects
columns = ["database_name", "schema_name", "name", "kind", "is_dynamic"]
if self.behavior.enable_iceberg_materializations.no_warn:
columns.append("is_iceberg")

return [self._parse_list_relations_result(obj) for obj in schema_objects.select(columns)]

def _parse_list_relations_result(self, result: "agate.Row") -> SnowflakeRelation:
# this can be reduced to always including `is_dynamic` once bundle `2024_03` is mandatory
# this can be reduced to always including `is_iceberg` once Snowflake adds it to show objects
try:
if self.behavior.enable_iceberg_materializations.no_warn:
database, schema, identifier, relation_type, is_dynamic, is_iceberg = result
else:
database, schema, identifier, relation_type, is_dynamic = result
except ValueError:
database, schema, identifier, relation_type = result
is_dynamic = "N"
if self.behavior.enable_iceberg_materializations.no_warn:
is_iceberg = "N"
# this can be collapsed once Snowflake adds is_iceberg to show objects
if self.behavior.enable_iceberg_materializations.no_warn:
database, schema, identifier, relation_type, is_dynamic, is_iceberg = result
else:
database, schema, identifier, relation_type, is_dynamic = result
is_iceberg = "N"

try:
relation_type = self.Relation.get_relation_type(relation_type.lower())
Expand All @@ -289,13 +281,8 @@ def _parse_list_relations_result(self, result: "agate.Row") -> SnowflakeRelation
if relation_type == self.Relation.Table and is_dynamic == "Y":
relation_type = self.Relation.DynamicTable

# This line is the main gate on supporting Iceberg materializations. Pass forward a default
# table format, and no downstream table macros can build iceberg relations.
table_format: str = (
TableFormat.ICEBERG
if self.behavior.enable_iceberg_materializations.no_warn and is_iceberg in ("Y", "YES")
else TableFormat.DEFAULT
)
table_format = TableFormat.ICEBERG if is_iceberg in ("Y", "YES") else TableFormat.DEFAULT

quote_policy = {"database": True, "schema": True, "identifier": True}

return self.Relation.create(
Expand Down

This file was deleted.

Loading

0 comments on commit 34c4442

Please sign in to comment.