|
8 | 8 | import typing as t |
9 | 9 | import shutil |
10 | 10 | from datetime import datetime, timedelta |
| 11 | +import logging |
11 | 12 |
|
12 | 13 | import numpy as np # noqa: TID253 |
13 | 14 | import pandas as pd # noqa: TID253 |
14 | 15 | import pytest |
15 | 16 | import pytz |
| 17 | +from unittest import mock |
16 | 18 | from sqlglot import exp, parse_one |
17 | 19 | from sqlglot.optimizer.normalize_identifiers import normalize_identifiers |
18 | 20 | from sqlglot.optimizer.qualify_columns import quote_identifiers |
@@ -3733,7 +3735,7 @@ def _set_config(_gateway: str, config: Config) -> None: |
3733 | 3735 | ] |
3734 | 3736 |
|
3735 | 3737 |
|
3736 | | -def test_materialized_view_evaluation(ctx: TestContext): |
| 3738 | +def test_materialized_view_evaluation(ctx: TestContext, mocker: MockerFixture): |
3737 | 3739 | adapter = ctx.engine_adapter |
3738 | 3740 | dialect = ctx.dialect |
3739 | 3741 | if not adapter.SUPPORTS_MATERIALIZED_VIEWS: |
@@ -3784,7 +3786,16 @@ def test_materialized_view_evaluation(ctx: TestContext): |
3784 | 3786 | load_sql_based_model(d.parse(f"""MODEL (name {model_name}, kind FULL); SELECT 2 AS col""")) |
3785 | 3787 | ) |
3786 | 3788 |
|
3787 | | - sqlmesh.plan(auto_apply=True, no_prompts=True) |
| 3789 | + logger = logging.getLogger("sqlmesh.core.snapshot.evaluator") |
| 3790 | + |
| 3791 | + with mock.patch.object(logger, "info") as mock_logger: |
| 3792 | + sqlmesh.plan(auto_apply=True, no_prompts=True) |
| 3793 | + |
| 3794 | + # RisingWave does not need to recreate the mview, all other engines do |
| 3795 | + recreate_view = ( |
| 3796 | + "Skipping creation of the view" if dialect == "risingwave" else "Replacing view" |
| 3797 | + ) |
| 3798 | + assert any(recreate_view in call[0][0] for call in mock_logger.call_args_list) |
3788 | 3799 |
|
3789 | 3800 | df = adapter.fetchdf(f"SELECT * FROM {mview_name.sql(dialect=dialect)}") |
3790 | 3801 | assert df["col"][0] == 2 |
0 commit comments