|
24 | 24 | DataObject, |
25 | 25 | DataObjectType, |
26 | 26 | InsertOverwriteStrategy, |
| 27 | + CommentCreationView, |
27 | 28 | ) |
28 | 29 | from sqlmesh.core.environment import EnvironmentNamingInfo |
29 | 30 | from sqlmesh.core.macros import RuntimeStage, macro, MacroEvaluator, MacroFunc |
@@ -1519,6 +1520,41 @@ def test_migrate_view( |
1519 | 1520 | ) |
1520 | 1521 |
|
1521 | 1522 |
|
| 1523 | +def test_migrate_view_recreation_not_needed( |
| 1524 | + mocker: MockerFixture, |
| 1525 | + make_snapshot, |
| 1526 | + make_mocked_engine_adapter, |
| 1527 | +): |
| 1528 | + model = SqlModel( |
| 1529 | + name="test_schema.test_model", |
| 1530 | + kind=ViewKind(), |
| 1531 | + description="my_description", |
| 1532 | + query=parse_one("SELECT c, a FROM tbl"), |
| 1533 | + ) |
| 1534 | + snapshot = make_snapshot(model, version="1") |
| 1535 | + snapshot.change_category = SnapshotChangeCategory.METADATA |
| 1536 | + snapshot.forward_only = False |
| 1537 | + |
| 1538 | + adapter = make_mocked_engine_adapter(EngineAdapter) |
| 1539 | + adapter.COMMENT_CREATION_VIEW = CommentCreationView.UNSUPPORTED |
| 1540 | + adapter.with_settings = lambda **kwargs: adapter |
| 1541 | + mocker.patch( |
| 1542 | + "sqlmesh.core.engine_adapter.base.EngineAdapter.get_data_objects", |
| 1543 | + return_value=[ |
| 1544 | + DataObject( |
| 1545 | + schema="sqlmesh__test_schema", |
| 1546 | + name=f"test_schema__test_model__{snapshot.version}", |
| 1547 | + type="view", |
| 1548 | + ) |
| 1549 | + ], |
| 1550 | + ) |
| 1551 | + |
| 1552 | + evaluator = SnapshotEvaluator(adapter) |
| 1553 | + evaluator.migrate([snapshot], {}, directly_or_indirectly_modified_snapshots_ids=set()) |
| 1554 | + |
| 1555 | + adapter.cursor.execute.assert_not_called() |
| 1556 | + |
| 1557 | + |
1522 | 1558 | def test_migrate_snapshot_data_object_type_mismatch( |
1523 | 1559 | mocker: MockerFixture, |
1524 | 1560 | make_snapshot, |
|
0 commit comments