|
2 | 2 |
|
3 | 3 | import pytest
|
4 | 4 |
|
5 |
| -from dagster_sqlmesh.controller.base import PlanOptions, RunOptions |
| 5 | +from dagster_sqlmesh.controller.base import PlanOptions |
6 | 6 | from tests.conftest import SQLMeshTestContext
|
7 | 7 |
|
8 | 8 | logger = logging.getLogger(__name__)
|
|
12 | 12 | "no_auto_upstream,skip_backfill,expected_changes",
|
13 | 13 | [
|
14 | 14 | (
|
15 |
| - True, |
| 15 | + False, |
16 | 16 | False,
|
17 | 17 | {
|
18 | 18 | "staging_1": ">=", # Should increase (skip_backfill disabled)
|
|
26 | 26 | "only_skip_backfill",
|
27 | 27 | ],
|
28 | 28 | )
|
| 29 | +@pytest.mark.skip(reason="Work in progress test") |
29 | 30 | def test_given_model_chain_when_running_with_different_flags_then_behaves_as_expected(
|
30 | 31 | model_change_test_context: SQLMeshTestContext,
|
31 | 32 | no_auto_upstream: bool,
|
@@ -54,85 +55,80 @@ def test_given_model_chain_when_running_with_different_flags_then_behaves_as_exp
|
54 | 55 | ">=" means final count should be greater than or equal to initial
|
55 | 56 | """
|
56 | 57 | # Initial run to set up all models
|
57 |
| - model_change_test_context.plan_and_run( |
58 |
| - environment="dev", |
59 |
| - start="2023-02-01", |
60 |
| - end="2023-02-03", |
61 |
| - plan_options=PlanOptions( |
62 |
| - execution_time="2023-02-03", |
63 |
| - ), |
64 |
| - run_options=RunOptions( |
65 |
| - execution_time="2023-02-03", |
66 |
| - ), |
67 |
| - ) |
| 58 | + # model_change_test_context.plan_and_run( |
| 59 | + # environment="dev", |
| 60 | + # start="2023-02-01", |
| 61 | + # end="2023-02-03", |
| 62 | + # plan_options=PlanOptions( |
| 63 | + # execution_time="2023-02-03", |
| 64 | + # ), |
| 65 | + # run_options=RunOptions( |
| 66 | + # execution_time="2023-02-03", |
| 67 | + # ), |
| 68 | + # ) |
68 | 69 |
|
69 |
| - # Get initial counts for the model chain |
70 |
| - initial_counts = { |
71 |
| - "staging_1": model_change_test_context.query( |
72 |
| - "SELECT COUNT(*) FROM sqlmesh_example__dev.staging_model_1" |
73 |
| - )[0][0], |
74 |
| - "staging_2": model_change_test_context.query( |
75 |
| - "SELECT COUNT(*) FROM sqlmesh_example__dev.staging_model_2" |
76 |
| - )[0][0], |
77 |
| - "intermediate": model_change_test_context.query( |
78 |
| - "SELECT COUNT(*) FROM sqlmesh_example__dev.intermediate_model_1" |
79 |
| - )[0][0], |
80 |
| - "full": model_change_test_context.query( |
81 |
| - "SELECT COUNT(*) FROM sqlmesh_example__dev.full_model" |
82 |
| - )[0][0], |
83 |
| - } |
| 70 | + # # Get initial counts for the model chain |
| 71 | + # initial_counts = { |
| 72 | + # "staging_1": model_change_test_context.query( |
| 73 | + # "SELECT COUNT(*) FROM sqlmesh_example__dev.staging_model_1" |
| 74 | + # )[0][0], |
| 75 | + # "staging_2": model_change_test_context.query( |
| 76 | + # "SELECT COUNT(*) FROM sqlmesh_example__dev.staging_model_2" |
| 77 | + # )[0][0], |
| 78 | + # "intermediate": model_change_test_context.query( |
| 79 | + # "SELECT COUNT(*) FROM sqlmesh_example__dev.intermediate_model_1" |
| 80 | + # )[0][0], |
| 81 | + # "full": model_change_test_context.query( |
| 82 | + # "SELECT COUNT(*) FROM sqlmesh_example__dev.full_model" |
| 83 | + # )[0][0], |
| 84 | + # } |
| 85 | + |
| 86 | + # print(f"initial_counts: {initial_counts}") |
| 87 | + # print( |
| 88 | + # f"intermediate_model_1 first run: { |
| 89 | + # model_change_test_context.query( |
| 90 | + # 'SELECT * FROM sqlmesh_example__dev.intermediate_model_1', |
| 91 | + # return_df=True, |
| 92 | + # ) |
| 93 | + # }" |
| 94 | + # ) |
84 | 95 |
|
85 |
| - print(f"initial_counts: {initial_counts}") |
86 |
| - print( |
87 |
| - f"intermediate_model_1 first run: { |
88 |
| - model_change_test_context.query( |
89 |
| - 'SELECT * FROM sqlmesh_example__dev.intermediate_model_1', |
90 |
| - return_df=True, |
91 |
| - ) |
92 |
| - }" |
93 |
| - ) |
| 96 | + # # Modify staging_model_1 to include more data |
| 97 | + # model_change_test_context.modify_model_file( |
| 98 | + # "intermediate_model_1.sql", |
| 99 | + # """ |
| 100 | + # MODEL ( |
| 101 | + # name sqlmesh_example.intermediate_model_1, |
| 102 | + # kind INCREMENTAL_BY_TIME_RANGE ( |
| 103 | + # time_column event_date |
| 104 | + # ), |
| 105 | + # start '2020-01-01', |
| 106 | + # cron '@daily', |
| 107 | + # grain (id, event_date) |
| 108 | + # ); |
94 | 109 |
|
95 |
| - # Modify staging_model_1 to include more data |
96 |
| - model_change_test_context.modify_model_file( |
97 |
| - "intermediate_model_1.sql", |
98 |
| - """ |
99 |
| - MODEL ( |
100 |
| - name sqlmesh_example.intermediate_model_1, |
101 |
| - kind INCREMENTAL_BY_TIME_RANGE ( |
102 |
| - time_column event_date |
103 |
| - ), |
104 |
| - start '2020-01-01', |
105 |
| - cron '@daily', |
106 |
| - grain (id, event_date) |
107 |
| - ); |
108 |
| -
|
109 |
| - SELECT |
110 |
| - main.id, |
111 |
| - main.item_id, |
112 |
| - main.event_date, |
113 |
| - CONCAT(sub.item_name, ' - modified') as item_name |
114 |
| - FROM sqlmesh_example.staging_model_1 AS main |
115 |
| - INNER JOIN sqlmesh_example.staging_model_2 as sub |
116 |
| - ON main.id = sub.id |
117 |
| - WHERE |
118 |
| - event_date BETWEEN @start_date AND @end_date |
119 |
| -
|
120 |
| - """, |
121 |
| - ) |
| 110 | + # SELECT |
| 111 | + # main.id, |
| 112 | + # main.item_id, |
| 113 | + # main.event_date, |
| 114 | + # CONCAT(sub.item_name, ' - modified18') as item_name |
| 115 | + # FROM sqlmesh_example.staging_model_1 AS main |
| 116 | + # INNER JOIN sqlmesh_example.staging_model_2 as sub |
| 117 | + # ON main.id = sub.id |
| 118 | + # WHERE |
| 119 | + # event_date BETWEEN @start_date AND @end_date |
| 120 | + |
| 121 | + # """, |
| 122 | + # ) |
| 123 | + |
| 124 | + # raise Exception("Stop here") |
122 | 125 |
|
123 | 126 | # Run with specified flags
|
124 | 127 | model_change_test_context.plan_and_run(
|
125 | 128 | environment="dev",
|
126 |
| - start="2023-02-01", |
127 |
| - end="2023-02-03", |
128 | 129 | plan_options=PlanOptions(
|
129 | 130 | skip_backfill=skip_backfill,
|
130 | 131 | enable_preview=True,
|
131 |
| - execution_time="2023-02-03", |
132 |
| - ), |
133 |
| - run_options=RunOptions( |
134 |
| - no_auto_upstream=no_auto_upstream, |
135 |
| - execution_time="2023-02-03", |
136 | 132 | ),
|
137 | 133 | select_models=["sqlmesh_example.intermediate_model_1"],
|
138 | 134 | )
|
|
0 commit comments