|
11 | 11 | from pytest_mock.plugin import MockerFixture |
12 | 12 | from sqlglot import exp, to_column |
13 | 13 |
|
| 14 | +from sqlmesh.core import constants as c |
14 | 15 | from sqlmesh.core.audit import StandaloneAudit |
15 | 16 | from sqlmesh.core.config import ( |
16 | 17 | AutoCategorizationMode, |
|
35 | 36 | ) |
36 | 37 | from sqlmesh.core.model.kind import TimeColumn, ModelKindName |
37 | 38 | from sqlmesh.core.node import IntervalUnit |
| 39 | +from sqlmesh.core.signal import signal |
38 | 40 | from sqlmesh.core.snapshot import ( |
39 | 41 | DeployabilityIndex, |
40 | 42 | QualifiedViewName, |
@@ -2802,3 +2804,29 @@ def test_apply_auto_restatements_disable_restatement_downstream(make_snapshot): |
2802 | 2804 | assert snapshot_b.intervals == [ |
2803 | 2805 | (to_timestamp("2020-01-01"), to_timestamp("2020-01-06")), |
2804 | 2806 | ] |
| 2807 | + |
| 2808 | + |
| 2809 | +def test_render_signal(make_snapshot): |
| 2810 | + @signal() |
| 2811 | + def check_types(batch, env: str, default: int = 0): |
| 2812 | + if env != "in_memory" or not default == 0: |
| 2813 | + raise |
| 2814 | + return True |
| 2815 | + |
| 2816 | + sql_model = load_sql_based_model( |
| 2817 | + parse( |
| 2818 | + """ |
| 2819 | + MODEL ( |
| 2820 | + name test_schema.test_model, |
| 2821 | + signals check_types(env := @gateway) |
| 2822 | + ); |
| 2823 | + SELECT a FROM tbl; |
| 2824 | + """ |
| 2825 | + ), |
| 2826 | + variables={ |
| 2827 | + c.GATEWAY: "in_memory", |
| 2828 | + }, |
| 2829 | + signal_definitions=signal.get_registry(), |
| 2830 | + ) |
| 2831 | + snapshot_a = make_snapshot(sql_model) |
| 2832 | + assert snapshot_a.check_ready_intervals([(0, 1)]) == [(0, 1)] |
0 commit comments