Skip to content
Merged
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
1 change: 1 addition & 0 deletions sqlmesh/core/snapshot/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ def data_version(self) -> SnapshotDataVersion:
change_category=self.change_category,
physical_schema=self.physical_schema,
dev_table_suffix=self.dev_table_suffix,
table_naming_convention=self.table_naming_convention,
)

@property
Expand Down
20 changes: 20 additions & 0 deletions tests/core/test_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,26 @@ def test_table_name_naming_convention_hash_md5(make_snapshot: t.Callable[..., Sn
assert snapshot.table_name(is_deployable=False) == f"sqlmesh__foo.sqlmesh_md5__{hash_dev}__dev"


def test_table_naming_convention_passed_around_correctly(make_snapshot: t.Callable[..., Snapshot]):
snapshot = make_snapshot(
SqlModel(name='"foo"."bar"."baz"', query=parse_one("select 1")),
table_naming_convention=TableNamingConvention.HASH_MD5,
)
snapshot.categorize_as(SnapshotChangeCategory.BREAKING)

assert snapshot.table_naming_convention == TableNamingConvention.HASH_MD5
assert snapshot.data_version.table_naming_convention == TableNamingConvention.HASH_MD5
assert snapshot.table_info.table_naming_convention == TableNamingConvention.HASH_MD5
assert (
snapshot.table_info.data_version.table_naming_convention == TableNamingConvention.HASH_MD5
)
assert snapshot.table_info.table_info.table_naming_convention == TableNamingConvention.HASH_MD5
assert (
snapshot.table_info.table_info.data_version.table_naming_convention
== TableNamingConvention.HASH_MD5
)


def test_table_name_view(make_snapshot: t.Callable):
# Mimic a direct breaking change.
snapshot = make_snapshot(SqlModel(name="name", query=parse_one("select 1"), kind="VIEW"))
Expand Down