|
9 | 9 | from sqlmesh.core.context import Context |
10 | 10 | from sqlmesh.core.context_diff import ContextDiff |
11 | 11 | from sqlmesh.core.environment import EnvironmentNamingInfo |
12 | | -from sqlmesh.core.model import IncrementalByTimeRangeKind, SeedKind, SeedModel, SqlModel |
| 12 | +from sqlmesh.core.model import ( |
| 13 | + FullKind, |
| 14 | + IncrementalByTimeRangeKind, |
| 15 | + SeedKind, |
| 16 | + SeedModel, |
| 17 | + SqlModel, |
| 18 | +) |
13 | 19 | from sqlmesh.core.model.seed import Seed |
14 | 20 | from sqlmesh.core.plan import Plan, PlanBuilder, SnapshotIntervals |
15 | 21 | from sqlmesh.core.snapshot import ( |
@@ -858,7 +864,13 @@ def test_new_environment_with_changes(make_snapshot, mocker: MockerFixture): |
858 | 864 |
|
859 | 865 |
|
860 | 866 | def test_forward_only_models(make_snapshot, mocker: MockerFixture): |
861 | | - snapshot = make_snapshot(SqlModel(name="a", query=parse_one("select 1, ds"))) |
| 867 | + snapshot = make_snapshot( |
| 868 | + SqlModel( |
| 869 | + name="a", |
| 870 | + query=parse_one("select 1, ds"), |
| 871 | + kind=IncrementalByTimeRangeKind(time_column="ds", forward_only=True), |
| 872 | + ) |
| 873 | + ) |
862 | 874 | snapshot.categorize_as(SnapshotChangeCategory.BREAKING) |
863 | 875 | updated_snapshot = make_snapshot( |
864 | 876 | SqlModel( |
@@ -898,6 +910,37 @@ def test_forward_only_models(make_snapshot, mocker: MockerFixture): |
898 | 910 | assert updated_snapshot.change_category == SnapshotChangeCategory.FORWARD_ONLY |
899 | 911 |
|
900 | 912 |
|
| 913 | +def test_forward_only_models_model_kind_changed(make_snapshot, mocker: MockerFixture): |
| 914 | + snapshot = make_snapshot(SqlModel(name="a", query=parse_one("select 1, ds"), kind=FullKind())) |
| 915 | + snapshot.categorize_as(SnapshotChangeCategory.BREAKING) |
| 916 | + updated_snapshot = make_snapshot( |
| 917 | + SqlModel( |
| 918 | + name="a", |
| 919 | + query=parse_one("select 3, ds"), |
| 920 | + kind=IncrementalByTimeRangeKind(time_column="ds", forward_only=True), |
| 921 | + ) |
| 922 | + ) |
| 923 | + updated_snapshot.previous_versions = snapshot.all_versions |
| 924 | + |
| 925 | + context_diff = ContextDiff( |
| 926 | + environment="test_environment", |
| 927 | + is_new_environment=True, |
| 928 | + is_unfinalized_environment=False, |
| 929 | + create_from="prod", |
| 930 | + added=set(), |
| 931 | + removed_snapshots={}, |
| 932 | + modified_snapshots={updated_snapshot.name: (updated_snapshot, snapshot)}, |
| 933 | + snapshots={updated_snapshot.snapshot_id: updated_snapshot}, |
| 934 | + new_snapshots={updated_snapshot.snapshot_id: updated_snapshot}, |
| 935 | + previous_plan_id=None, |
| 936 | + previously_promoted_snapshot_ids=set(), |
| 937 | + previous_finalized_snapshots=None, |
| 938 | + ) |
| 939 | + |
| 940 | + PlanBuilder(context_diff, is_dev=True).build() |
| 941 | + assert updated_snapshot.change_category == SnapshotChangeCategory.BREAKING |
| 942 | + |
| 943 | + |
901 | 944 | def test_indirectly_modified_forward_only_model(make_snapshot, mocker: MockerFixture): |
902 | 945 | snapshot_a = make_snapshot(SqlModel(name="a", query=parse_one("select 1 as a, ds"))) |
903 | 946 | snapshot_a.categorize_as(SnapshotChangeCategory.BREAKING) |
|
0 commit comments