Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion sqlmesh/core/snapshot/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ def _evaluate_snapshot(
model.kind.is_materialized
and model.columns_to_types_
and columns_to_types_all_known(model.columns_to_types_)
)
) or (model.depends_on_self and model.annotated)
if self._can_clone(snapshot, deployability_index):
self._clone_snapshot_in_dev(
snapshot=snapshot,
Expand Down
26 changes: 26 additions & 0 deletions tests/core/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,32 @@ def test_new_forward_only_model(init_and_plan_context: t.Callable):
assert context.engine_adapter.table_exists(snapshot.table_name(is_deployable=False))


@time_machine.travel("2023-01-08 00:00:00 UTC")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good example of a test that doesn't actually need the sushi project at all.

Wouldnt this work much faster with an empty duckdb context?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It looks like this pattern has been used in other tests too. We might consider refactoring this separately.

def test_annotated_self_referential_model(init_and_plan_context: t.Callable):
context, _ = init_and_plan_context("examples/sushi")

# Projections are fully annotated in the query but columns were not specified explicitly
expressions = d.parse(
f"""
MODEL (
name memory.sushi.test_self_ref,
kind FULL,
start '2023-01-01',
);

SELECT 1::INT AS one FROM memory.sushi.test_self_ref;
"""
)
model = load_sql_based_model(expressions)
assert model.depends_on_self
context.upsert_model(model)

context.plan("prod", skip_tests=True, no_prompts=True, auto_apply=True)

df = context.fetchdf("SELECT one FROM memory.sushi.test_self_ref")
assert len(df) == 0


@time_machine.travel("2023-01-08 15:00:00 UTC")
def test_plan_set_choice_is_reflected_in_missing_intervals(init_and_plan_context: t.Callable):
context, _ = init_and_plan_context("examples/sushi")
Expand Down