sqlmesh 0.226.1.dev3__py3-none-any.whl → 0.226.1.dev4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sqlmesh might be problematic. Click here for more details.
- sqlmesh/_version.py +2 -2
- sqlmesh/core/context.py +8 -0
- sqlmesh/core/scheduler.py +10 -1
- sqlmesh/core/signal.py +35 -14
- {sqlmesh-0.226.1.dev3.dist-info → sqlmesh-0.226.1.dev4.dist-info}/METADATA +1 -1
- {sqlmesh-0.226.1.dev3.dist-info → sqlmesh-0.226.1.dev4.dist-info}/RECORD +10 -10
- {sqlmesh-0.226.1.dev3.dist-info → sqlmesh-0.226.1.dev4.dist-info}/WHEEL +0 -0
- {sqlmesh-0.226.1.dev3.dist-info → sqlmesh-0.226.1.dev4.dist-info}/entry_points.txt +0 -0
- {sqlmesh-0.226.1.dev3.dist-info → sqlmesh-0.226.1.dev4.dist-info}/licenses/LICENSE +0 -0
- {sqlmesh-0.226.1.dev3.dist-info → sqlmesh-0.226.1.dev4.dist-info}/top_level.txt +0 -0
sqlmesh/_version.py
CHANGED
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '0.226.1.
|
|
32
|
-
__version_tuple__ = version_tuple = (0, 226, 1, '
|
|
31
|
+
__version__ = version = '0.226.1.dev4'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 226, 1, 'dev4')
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
sqlmesh/core/context.py
CHANGED
|
@@ -154,6 +154,8 @@ if t.TYPE_CHECKING:
|
|
|
154
154
|
)
|
|
155
155
|
from sqlmesh.core.snapshot import Node
|
|
156
156
|
|
|
157
|
+
from sqlmesh.core.snapshot.definition import Intervals
|
|
158
|
+
|
|
157
159
|
ModelOrSnapshot = t.Union[str, Model, Snapshot]
|
|
158
160
|
NodeOrSnapshot = t.Union[str, Model, StandaloneAudit, Snapshot]
|
|
159
161
|
|
|
@@ -276,6 +278,7 @@ class ExecutionContext(BaseContext):
|
|
|
276
278
|
default_dialect: t.Optional[str] = None,
|
|
277
279
|
default_catalog: t.Optional[str] = None,
|
|
278
280
|
is_restatement: t.Optional[bool] = None,
|
|
281
|
+
parent_intervals: t.Optional[Intervals] = None,
|
|
279
282
|
variables: t.Optional[t.Dict[str, t.Any]] = None,
|
|
280
283
|
blueprint_variables: t.Optional[t.Dict[str, t.Any]] = None,
|
|
281
284
|
):
|
|
@@ -287,6 +290,7 @@ class ExecutionContext(BaseContext):
|
|
|
287
290
|
self._variables = variables or {}
|
|
288
291
|
self._blueprint_variables = blueprint_variables or {}
|
|
289
292
|
self._is_restatement = is_restatement
|
|
293
|
+
self._parent_intervals = parent_intervals
|
|
290
294
|
|
|
291
295
|
@property
|
|
292
296
|
def default_dialect(self) -> t.Optional[str]:
|
|
@@ -315,6 +319,10 @@ class ExecutionContext(BaseContext):
|
|
|
315
319
|
def is_restatement(self) -> t.Optional[bool]:
|
|
316
320
|
return self._is_restatement
|
|
317
321
|
|
|
322
|
+
@property
|
|
323
|
+
def parent_intervals(self) -> t.Optional[Intervals]:
|
|
324
|
+
return self._parent_intervals
|
|
325
|
+
|
|
318
326
|
def var(self, var_name: str, default: t.Optional[t.Any] = None) -> t.Optional[t.Any]:
|
|
319
327
|
"""Returns a variable value."""
|
|
320
328
|
return self._variables.get(var_name.lower(), default)
|
sqlmesh/core/scheduler.py
CHANGED
|
@@ -352,7 +352,7 @@ class Scheduler:
|
|
|
352
352
|
)
|
|
353
353
|
for snapshot, intervals in merged_intervals.items()
|
|
354
354
|
}
|
|
355
|
-
snapshot_batches = {}
|
|
355
|
+
snapshot_batches: t.Dict[Snapshot, Intervals] = {}
|
|
356
356
|
all_unready_intervals: t.Dict[str, set[Interval]] = {}
|
|
357
357
|
for snapshot_id in dag:
|
|
358
358
|
if snapshot_id not in snapshot_intervals:
|
|
@@ -364,6 +364,14 @@ class Scheduler:
|
|
|
364
364
|
|
|
365
365
|
adapter = self.snapshot_evaluator.get_adapter(snapshot.model_gateway)
|
|
366
366
|
|
|
367
|
+
parent_intervals: Intervals = []
|
|
368
|
+
for parent_id in snapshot.parents:
|
|
369
|
+
parent_snapshot, _ = snapshot_intervals.get(parent_id, (None, []))
|
|
370
|
+
if not parent_snapshot or parent_snapshot.is_external:
|
|
371
|
+
continue
|
|
372
|
+
|
|
373
|
+
parent_intervals.extend(snapshot_batches[parent_snapshot])
|
|
374
|
+
|
|
367
375
|
context = ExecutionContext(
|
|
368
376
|
adapter,
|
|
369
377
|
self.snapshots_by_name,
|
|
@@ -371,6 +379,7 @@ class Scheduler:
|
|
|
371
379
|
default_dialect=adapter.dialect,
|
|
372
380
|
default_catalog=self.default_catalog,
|
|
373
381
|
is_restatement=is_restatement,
|
|
382
|
+
parent_intervals=parent_intervals,
|
|
374
383
|
)
|
|
375
384
|
|
|
376
385
|
intervals = self._check_ready_intervals(
|
sqlmesh/core/signal.py
CHANGED
|
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import typing as t
|
|
4
4
|
from sqlmesh.utils import UniqueKeyDict, registry_decorator
|
|
5
|
+
from sqlmesh.utils.errors import MissingSourceError
|
|
5
6
|
|
|
6
7
|
if t.TYPE_CHECKING:
|
|
7
8
|
from sqlmesh.core.context import ExecutionContext
|
|
@@ -42,7 +43,16 @@ SignalRegistry = UniqueKeyDict[str, signal]
|
|
|
42
43
|
|
|
43
44
|
|
|
44
45
|
@signal()
|
|
45
|
-
def freshness(
|
|
46
|
+
def freshness(
|
|
47
|
+
batch: DatetimeRanges,
|
|
48
|
+
snapshot: Snapshot,
|
|
49
|
+
context: ExecutionContext,
|
|
50
|
+
) -> bool:
|
|
51
|
+
"""
|
|
52
|
+
Implements model freshness as a signal, i.e it considers this model to be fresh if:
|
|
53
|
+
- Any upstream SQLMesh model has available intervals to compute i.e is fresh
|
|
54
|
+
- Any upstream external model has been altered since the last time the model was evaluated
|
|
55
|
+
"""
|
|
46
56
|
adapter = context.engine_adapter
|
|
47
57
|
if context.is_restatement or not adapter.SUPPORTS_METADATA_TABLE_LAST_MODIFIED_TS:
|
|
48
58
|
return True
|
|
@@ -54,24 +64,35 @@ def freshness(batch: DatetimeRanges, snapshot: Snapshot, context: ExecutionConte
|
|
|
54
64
|
if deployability_index.is_deployable(snapshot)
|
|
55
65
|
else snapshot.dev_last_altered_ts
|
|
56
66
|
)
|
|
67
|
+
|
|
57
68
|
if not last_altered_ts:
|
|
58
69
|
return True
|
|
59
70
|
|
|
60
71
|
parent_snapshots = {context.snapshots[p.name] for p in snapshot.parents}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
72
|
+
|
|
73
|
+
upstream_parent_snapshots = {p for p in parent_snapshots if not p.is_external}
|
|
74
|
+
external_parents = snapshot.node.depends_on - {p.name for p in upstream_parent_snapshots}
|
|
75
|
+
|
|
76
|
+
if context.parent_intervals:
|
|
77
|
+
# At least one upstream sqlmesh model has intervals to compute (i.e is fresh),
|
|
78
|
+
# so the current model is considered fresh too
|
|
65
79
|
return True
|
|
66
80
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
81
|
+
if external_parents:
|
|
82
|
+
external_last_altered_timestamps = adapter.get_table_last_modified_ts(
|
|
83
|
+
list(external_parents)
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
if len(external_last_altered_timestamps) != len(external_parents):
|
|
87
|
+
raise MissingSourceError(
|
|
88
|
+
f"Expected {len(external_parents)} sources to be present, but got {len(external_last_altered_timestamps)}."
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
# Finding new data means that the upstream depedencies have been altered
|
|
92
|
+
# since the last time the model was evaluated
|
|
93
|
+
return any(
|
|
94
|
+
external_last_altered_ts > last_altered_ts
|
|
95
|
+
for external_last_altered_ts in external_last_altered_timestamps
|
|
73
96
|
)
|
|
74
|
-
)
|
|
75
97
|
|
|
76
|
-
|
|
77
|
-
return upstream_dep_has_new_data
|
|
98
|
+
return False
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
sqlmesh/__init__.py,sha256=v_spqQEhcnGaahp1yPvMqUIa6mhH3cs3Bc1CznxvCEA,7965
|
|
2
|
-
sqlmesh/_version.py,sha256=
|
|
2
|
+
sqlmesh/_version.py,sha256=EVQxxQ9b1qQaa52bxrILETUdCqJ89MuMmlUUKVT4AD8,721
|
|
3
3
|
sqlmesh/magics.py,sha256=xLh3u4eqpVrKRVN5KF3X84RPRqjygAB9AJP1TXwH8hg,42086
|
|
4
4
|
sqlmesh/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
sqlmesh/cicd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -13,7 +13,7 @@ sqlmesh/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
13
13
|
sqlmesh/core/_typing.py,sha256=PzXxMYnORq18JhblAOUttms3zPJZzZpIbfFA_jgKYPA,498
|
|
14
14
|
sqlmesh/core/console.py,sha256=MYpVlciUY6rUuoqXyKfXTxD6a4-Bw4-ooATUTj_VHGg,172830
|
|
15
15
|
sqlmesh/core/constants.py,sha256=BuQk43vluUm7LfP9nKp5o9qRhqIenWF_LiLXO_t_53c,2699
|
|
16
|
-
sqlmesh/core/context.py,sha256=
|
|
16
|
+
sqlmesh/core/context.py,sha256=C6UxhhHB5dtuoNb-P9a5mQW4_KX3fYVUMyYowSRKDpg,131217
|
|
17
17
|
sqlmesh/core/context_diff.py,sha256=mxkJu0IthFMOlaQ_kcq5C09mlgkq2RQb-pG2rd-x_nA,21648
|
|
18
18
|
sqlmesh/core/dialect.py,sha256=CnKcPj6BnREfu9Zn1OyS7hZ3ktnaX03ygOg91nADlTU,53029
|
|
19
19
|
sqlmesh/core/environment.py,sha256=Kgs_gUEUI072mh0JJFWNRynrCxp1TzRHZhX_NWJRfXc,13142
|
|
@@ -25,11 +25,11 @@ sqlmesh/core/node.py,sha256=2ejDwH1whl_ic1CRzX16Be-FQrosAf8pdyWb7oPzU6M,19895
|
|
|
25
25
|
sqlmesh/core/notification_target.py,sha256=PPGoDrgbRKxr27vJEu03XqNTQLYTw0ZF_b0yAapxGeI,16158
|
|
26
26
|
sqlmesh/core/reference.py,sha256=k7OSkLqTjPR8WJjNeFj0xAJ297nZUMgb_iTVwKRRKjc,4875
|
|
27
27
|
sqlmesh/core/renderer.py,sha256=JZuoydTwK0voU5sH70jhULjo5_x41uTEFKydtT-JRCg,28855
|
|
28
|
-
sqlmesh/core/scheduler.py,sha256=
|
|
28
|
+
sqlmesh/core/scheduler.py,sha256=hbi5n1zfac2EJGF728y5us7rgKwUrVGvZ6BorjaAjNc,49737
|
|
29
29
|
sqlmesh/core/schema_diff.py,sha256=qM4uxOBtrAqx8_5JU0ERicMT-byLD4xUUv4FrQw92js,33934
|
|
30
30
|
sqlmesh/core/schema_loader.py,sha256=_Pq2RSw91uthqv1vNi_eHmLlzhtGz_APMJ0wAJZYuvk,3677
|
|
31
31
|
sqlmesh/core/selector.py,sha256=gb8NpDXO-yxzxAB4Rl5yRkirWZyouV9V9d9AC1Lfzjg,18030
|
|
32
|
-
sqlmesh/core/signal.py,sha256=
|
|
32
|
+
sqlmesh/core/signal.py,sha256=RPyQNSCLyr2sybRK3wj6iWwukpwF-R0w9divnPwjJlM,3692
|
|
33
33
|
sqlmesh/core/table_diff.py,sha256=oKLVaBs5HhpWFQUHimcNB4jDPvFJCCM360N3yQqle5g,28872
|
|
34
34
|
sqlmesh/core/user.py,sha256=EJ6R4R1iK67n80vBoCCsidF56IR7xEYqiCEO-nrVMso,1660
|
|
35
35
|
sqlmesh/core/analytics/__init__.py,sha256=ou3ZXAJfQOXEifj-PzaXwMDSvJzsVaqaMkUopiI00kM,3247
|
|
@@ -238,7 +238,7 @@ sqlmesh/utils/pydantic.py,sha256=-yppkVlw6iSBaSiKjbe7OChxL-u3urOS4-KCjJEgsRU,120
|
|
|
238
238
|
sqlmesh/utils/rich.py,sha256=cwQ5nJ6sgz64xHtoh6_ec7ReV5YpsOGhMtUJnwoRfEI,3549
|
|
239
239
|
sqlmesh/utils/windows.py,sha256=0F9RdpuuCoG5NiEDXvWlAGCiJ-59OjSAmgFF5wW05aY,1133
|
|
240
240
|
sqlmesh/utils/yaml.py,sha256=KFBd7hsKNRTtRudGR7d410qUYffQv0EWRcDM8hVNNZg,3025
|
|
241
|
-
sqlmesh-0.226.1.
|
|
241
|
+
sqlmesh-0.226.1.dev4.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
|
|
242
242
|
sqlmesh_dbt/__init__.py,sha256=awYS5y5mz-1NUmx6i5h5NSTJ7tidRl9NC0FAnFWSF6U,350
|
|
243
243
|
sqlmesh_dbt/cli.py,sha256=p9foHjAW9ni7BTOJ2loynk47M0Sf43QIJZRggOzF5tc,6351
|
|
244
244
|
sqlmesh_dbt/console.py,sha256=RwWLYnEZHzn9Xp-e2gbZvkdKbWbBLN146geI84mJitg,1132
|
|
@@ -363,8 +363,8 @@ web/server/api/endpoints/models.py,sha256=kwj0s7uve3iZSMfmjkoPVMFMeY1sD0peTeyrWf
|
|
|
363
363
|
web/server/api/endpoints/modules.py,sha256=8hqqgonGay_mJmpCw0IdbjsPhWlQH2VLdKAqha-myac,468
|
|
364
364
|
web/server/api/endpoints/plan.py,sha256=bbbY50W_2MsZSTxOHWMKz0tbIm75nsRSlPy8GI2fg9Q,9306
|
|
365
365
|
web/server/api/endpoints/table_diff.py,sha256=8XTwgOh6QBbNy_hTM1JuHgRjbnie-pGPrphiW-FNLjQ,6058
|
|
366
|
-
sqlmesh-0.226.1.
|
|
367
|
-
sqlmesh-0.226.1.
|
|
368
|
-
sqlmesh-0.226.1.
|
|
369
|
-
sqlmesh-0.226.1.
|
|
370
|
-
sqlmesh-0.226.1.
|
|
366
|
+
sqlmesh-0.226.1.dev4.dist-info/METADATA,sha256=L_CMGFbq2DK9NkuSdId92tQDS9awhaA5JxjUDn8nYL8,26685
|
|
367
|
+
sqlmesh-0.226.1.dev4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
368
|
+
sqlmesh-0.226.1.dev4.dist-info/entry_points.txt,sha256=sHAf6tQczIM8xZoduN4qaUjV7QEPVUUW_LCT8EDUMv4,155
|
|
369
|
+
sqlmesh-0.226.1.dev4.dist-info/top_level.txt,sha256=RQ-33FPe2IgL0rgossAfJkCRtqslz9b7wFARqiWLC5Q,24
|
|
370
|
+
sqlmesh-0.226.1.dev4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|