sqlmesh 0.200.1.dev21__py3-none-any.whl → 0.200.1.dev23__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.
- sqlmesh/_version.py +2 -2
- sqlmesh/core/console.py +49 -10
- sqlmesh/core/context.py +57 -4
- sqlmesh/core/test/context.py +2 -2
- {sqlmesh-0.200.1.dev21.dist-info → sqlmesh-0.200.1.dev23.dist-info}/METADATA +1 -1
- {sqlmesh-0.200.1.dev21.dist-info → sqlmesh-0.200.1.dev23.dist-info}/RECORD +10 -10
- {sqlmesh-0.200.1.dev21.dist-info → sqlmesh-0.200.1.dev23.dist-info}/WHEEL +0 -0
- {sqlmesh-0.200.1.dev21.dist-info → sqlmesh-0.200.1.dev23.dist-info}/entry_points.txt +0 -0
- {sqlmesh-0.200.1.dev21.dist-info → sqlmesh-0.200.1.dev23.dist-info}/licenses/LICENSE +0 -0
- {sqlmesh-0.200.1.dev21.dist-info → sqlmesh-0.200.1.dev23.dist-info}/top_level.txt +0 -0
sqlmesh/_version.py
CHANGED
|
@@ -17,5 +17,5 @@ __version__: str
|
|
|
17
17
|
__version_tuple__: VERSION_TUPLE
|
|
18
18
|
version_tuple: VERSION_TUPLE
|
|
19
19
|
|
|
20
|
-
__version__ = version = '0.200.1.
|
|
21
|
-
__version_tuple__ = version_tuple = (0, 200, 1, '
|
|
20
|
+
__version__ = version = '0.200.1.dev23'
|
|
21
|
+
__version_tuple__ = version_tuple = (0, 200, 1, 'dev23')
|
sqlmesh/core/console.py
CHANGED
|
@@ -186,9 +186,19 @@ class DestroyConsole(abc.ABC):
|
|
|
186
186
|
"""Console for describing a destroy operation"""
|
|
187
187
|
|
|
188
188
|
@abc.abstractmethod
|
|
189
|
-
def start_destroy(
|
|
189
|
+
def start_destroy(
|
|
190
|
+
self,
|
|
191
|
+
schemas_to_delete: t.Optional[t.Set[str]] = None,
|
|
192
|
+
views_to_delete: t.Optional[t.Set[str]] = None,
|
|
193
|
+
tables_to_delete: t.Optional[t.Set[str]] = None,
|
|
194
|
+
) -> bool:
|
|
190
195
|
"""Start a destroy operation.
|
|
191
196
|
|
|
197
|
+
Args:
|
|
198
|
+
schemas_to_delete: Set of schemas that will be deleted
|
|
199
|
+
views_to_delete: Set of views that will be deleted
|
|
200
|
+
tables_to_delete: Set of tables that will be deleted
|
|
201
|
+
|
|
192
202
|
Returns:
|
|
193
203
|
Whether or not the destroy operation should proceed
|
|
194
204
|
"""
|
|
@@ -830,7 +840,12 @@ class NoopConsole(Console):
|
|
|
830
840
|
) -> None:
|
|
831
841
|
pass
|
|
832
842
|
|
|
833
|
-
def start_destroy(
|
|
843
|
+
def start_destroy(
|
|
844
|
+
self,
|
|
845
|
+
schemas_to_delete: t.Optional[t.Set[str]] = None,
|
|
846
|
+
views_to_delete: t.Optional[t.Set[str]] = None,
|
|
847
|
+
tables_to_delete: t.Optional[t.Set[str]] = None,
|
|
848
|
+
) -> bool:
|
|
834
849
|
return True
|
|
835
850
|
|
|
836
851
|
def stop_destroy(self, success: bool = True) -> None:
|
|
@@ -1282,16 +1297,40 @@ class TerminalConsole(Console):
|
|
|
1282
1297
|
else:
|
|
1283
1298
|
self.log_error("Cleanup failed!")
|
|
1284
1299
|
|
|
1285
|
-
def start_destroy(
|
|
1300
|
+
def start_destroy(
|
|
1301
|
+
self,
|
|
1302
|
+
schemas_to_delete: t.Optional[t.Set[str]] = None,
|
|
1303
|
+
views_to_delete: t.Optional[t.Set[str]] = None,
|
|
1304
|
+
tables_to_delete: t.Optional[t.Set[str]] = None,
|
|
1305
|
+
) -> bool:
|
|
1286
1306
|
self.log_warning(
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
"The operation is irreversible and may disrupt any currently running or scheduled plans.\n"
|
|
1290
|
-
"Use this command only when you intend to fully reset the project."
|
|
1291
|
-
)
|
|
1307
|
+
"This will permanently delete all engine-managed objects, state tables and SQLMesh cache.\n"
|
|
1308
|
+
"The operation may disrupt any currently running or scheduled plans.\n"
|
|
1292
1309
|
)
|
|
1293
|
-
|
|
1294
|
-
|
|
1310
|
+
|
|
1311
|
+
if schemas_to_delete or views_to_delete or tables_to_delete:
|
|
1312
|
+
if schemas_to_delete:
|
|
1313
|
+
self.log_error("Schemas to be deleted:")
|
|
1314
|
+
for schema in sorted(schemas_to_delete):
|
|
1315
|
+
self.log_error(f" • {schema}")
|
|
1316
|
+
|
|
1317
|
+
if views_to_delete:
|
|
1318
|
+
self.log_error("\nEnvironment views to be deleted:")
|
|
1319
|
+
for view in sorted(views_to_delete):
|
|
1320
|
+
self.log_error(f" • {view}")
|
|
1321
|
+
|
|
1322
|
+
if tables_to_delete:
|
|
1323
|
+
self.log_error("\nSnapshot tables to be deleted:")
|
|
1324
|
+
for table in sorted(tables_to_delete):
|
|
1325
|
+
self.log_error(f" • {table}")
|
|
1326
|
+
|
|
1327
|
+
self.log_error(
|
|
1328
|
+
"\nThis action will DELETE ALL the above resources managed by SQLMesh AND\n"
|
|
1329
|
+
"potentially external resources created by other tools in these schemas.\n"
|
|
1330
|
+
)
|
|
1331
|
+
|
|
1332
|
+
if not self._confirm("Are you ABSOLUTELY SURE you want to proceed with deletion?"):
|
|
1333
|
+
self.log_error("Destroy operation cancelled.")
|
|
1295
1334
|
return False
|
|
1296
1335
|
return True
|
|
1297
1336
|
|
sqlmesh/core/context.py
CHANGED
|
@@ -214,6 +214,15 @@ class BaseContext(abc.ABC):
|
|
|
214
214
|
"""
|
|
215
215
|
model_name = normalize_model_name(model_name, self.default_catalog, self.default_dialect)
|
|
216
216
|
|
|
217
|
+
if model_name not in self._model_tables:
|
|
218
|
+
model_name_list = "\n".join(list(self._model_tables))
|
|
219
|
+
logger.debug(
|
|
220
|
+
f"'{model_name}' not found in model to table mapping. Available model names: \n{model_name_list}"
|
|
221
|
+
)
|
|
222
|
+
raise SQLMeshError(
|
|
223
|
+
f"Unable to find a table mapping for model '{model_name}'. Has it been spelled correctly?"
|
|
224
|
+
)
|
|
225
|
+
|
|
217
226
|
# We generate SQL for the default dialect because the table name may be used in a
|
|
218
227
|
# fetchdf call and so the quotes need to be correct (eg. backticks for bigquery)
|
|
219
228
|
return parse_one(self._model_tables[model_name]).sql(
|
|
@@ -849,10 +858,52 @@ class GenericContext(BaseContext, t.Generic[C]):
|
|
|
849
858
|
def destroy(self) -> bool:
|
|
850
859
|
success = False
|
|
851
860
|
|
|
852
|
-
|
|
861
|
+
# Collect resources to be deleted
|
|
862
|
+
environments = self.state_reader.get_environments()
|
|
863
|
+
schemas_to_delete = set()
|
|
864
|
+
tables_to_delete = set()
|
|
865
|
+
views_to_delete = set()
|
|
866
|
+
all_snapshot_infos = set()
|
|
867
|
+
|
|
868
|
+
# For each environment find schemas and tables
|
|
869
|
+
for environment in environments:
|
|
870
|
+
all_snapshot_infos.update(environment.snapshots)
|
|
871
|
+
snapshots = self.state_reader.get_snapshots(environment.snapshots).values()
|
|
872
|
+
for snapshot in snapshots:
|
|
873
|
+
if snapshot.is_model and not snapshot.is_symbolic:
|
|
874
|
+
# Get the appropriate adapter
|
|
875
|
+
if environment.gateway_managed and snapshot.model_gateway:
|
|
876
|
+
adapter = self.engine_adapters.get(
|
|
877
|
+
snapshot.model_gateway, self.engine_adapter
|
|
878
|
+
)
|
|
879
|
+
else:
|
|
880
|
+
adapter = self.engine_adapter
|
|
881
|
+
|
|
882
|
+
if environment.suffix_target.is_schema or environment.suffix_target.is_catalog:
|
|
883
|
+
schema = snapshot.qualified_view_name.schema_for_environment(
|
|
884
|
+
environment.naming_info, dialect=adapter.dialect
|
|
885
|
+
)
|
|
886
|
+
catalog = snapshot.qualified_view_name.catalog_for_environment(
|
|
887
|
+
environment.naming_info, dialect=adapter.dialect
|
|
888
|
+
)
|
|
889
|
+
if catalog:
|
|
890
|
+
schemas_to_delete.add(f"{catalog}.{schema}")
|
|
891
|
+
else:
|
|
892
|
+
schemas_to_delete.add(schema)
|
|
893
|
+
|
|
894
|
+
if environment.suffix_target.is_table:
|
|
895
|
+
view_name = snapshot.qualified_view_name.for_environment(
|
|
896
|
+
environment.naming_info, dialect=adapter.dialect
|
|
897
|
+
)
|
|
898
|
+
views_to_delete.add(view_name)
|
|
899
|
+
|
|
900
|
+
# Add snapshot tables
|
|
901
|
+
table_name = snapshot.table_name()
|
|
902
|
+
tables_to_delete.add(table_name)
|
|
903
|
+
|
|
904
|
+
if self.console.start_destroy(schemas_to_delete, views_to_delete, tables_to_delete):
|
|
853
905
|
try:
|
|
854
|
-
self._destroy()
|
|
855
|
-
success = True
|
|
906
|
+
success = self._destroy()
|
|
856
907
|
finally:
|
|
857
908
|
self.console.stop_destroy(success=success)
|
|
858
909
|
|
|
@@ -2714,7 +2765,7 @@ class GenericContext(BaseContext, t.Generic[C]):
|
|
|
2714
2765
|
always_recreate_environment=always_recreate_environment,
|
|
2715
2766
|
)
|
|
2716
2767
|
|
|
2717
|
-
def _destroy(self) ->
|
|
2768
|
+
def _destroy(self) -> bool:
|
|
2718
2769
|
# Invalidate all environments, including prod
|
|
2719
2770
|
for environment in self.state_reader.get_environments():
|
|
2720
2771
|
self.state_sync.invalidate_environment(name=environment.name, protect_prod=False)
|
|
@@ -2730,6 +2781,8 @@ class GenericContext(BaseContext, t.Generic[C]):
|
|
|
2730
2781
|
# Finally clear caches
|
|
2731
2782
|
self.clear_caches()
|
|
2732
2783
|
|
|
2784
|
+
return True
|
|
2785
|
+
|
|
2733
2786
|
def _run_janitor(self, ignore_ttl: bool = False) -> None:
|
|
2734
2787
|
current_ts = now_timestamp()
|
|
2735
2788
|
|
sqlmesh/core/test/context.py
CHANGED
|
@@ -43,8 +43,8 @@ class TestExecutionContext(ExecutionContext):
|
|
|
43
43
|
# Include upstream dependencies to ensure they can be resolved during test execution
|
|
44
44
|
return {
|
|
45
45
|
name: self._test._test_fixture_table(name).sql()
|
|
46
|
-
for model in self._models.
|
|
47
|
-
for name in [
|
|
46
|
+
for normalized_model_name, model in self._models.items()
|
|
47
|
+
for name in [normalized_model_name, *model.depends_on]
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
def with_variables(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
sqlmesh/__init__.py,sha256=QjwaamJIdW7voXoS880yAx7tHm-Im4_mqGA-XJgafos,7631
|
|
2
|
-
sqlmesh/_version.py,sha256=
|
|
2
|
+
sqlmesh/_version.py,sha256=Npi18qjpGhOypL2z3gbMqb8wyitchxvaKjCvvz8KYMM,530
|
|
3
3
|
sqlmesh/magics.py,sha256=bEzYqXHcM0P3CjyUZ1O9arlmXAdLAhoglKbQ29fD9AE,41842
|
|
4
4
|
sqlmesh/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
sqlmesh/cicd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -11,9 +11,9 @@ sqlmesh/cli/options.py,sha256=-4ZclMIeIg8tghLowtmQNmpEFlm0QtOVEh40NqRdFHA,2499
|
|
|
11
11
|
sqlmesh/cli/project_init.py,sha256=5JmDmUK0WJs39hM-p76uzHYdo1Hnx6fKuJg_pR3Hn5A,16419
|
|
12
12
|
sqlmesh/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
sqlmesh/core/_typing.py,sha256=e1f7xO2aZCy38M_3VoDy-XI3shyd99-IFctgIFSgXWM,497
|
|
14
|
-
sqlmesh/core/console.py,sha256=
|
|
14
|
+
sqlmesh/core/console.py,sha256=lb6Zq6BhimfQkcSd19t35owSmaGCqw0WHMhGK-WZ-y4,165491
|
|
15
15
|
sqlmesh/core/constants.py,sha256=gUABXWYgH_XOSbaZAJsR5o1dmA61JDCvBDyxqqXX3LM,2630
|
|
16
|
-
sqlmesh/core/context.py,sha256=
|
|
16
|
+
sqlmesh/core/context.py,sha256=0EH5FEoPEoxgr3_yu2pasH_Itei7daInEL1uEJgpgwM,127360
|
|
17
17
|
sqlmesh/core/context_diff.py,sha256=_Ur55fGLJ58Icsp44I4pVhdi7_JHiHq45mWIco9oFzk,21792
|
|
18
18
|
sqlmesh/core/dialect.py,sha256=1ykYwb9WZn_nCaX08PcQ0BJh2Pihv9SPvoMNjpMeCfs,50158
|
|
19
19
|
sqlmesh/core/environment.py,sha256=odus40R-YzdQdS_IiUq_tFouUXIhnpwmNwo8dE8Aw1k,13041
|
|
@@ -118,7 +118,7 @@ sqlmesh/core/state_sync/db/snapshot.py,sha256=LV5w3hvwxa-v_ilC1iuQb4iAJDNoi9DH1a
|
|
|
118
118
|
sqlmesh/core/state_sync/db/utils.py,sha256=204OpT3ISFPCwWP9Aqq8nr6ETl24sbG5uOyo86IJv6E,3819
|
|
119
119
|
sqlmesh/core/state_sync/db/version.py,sha256=fl5g1tNMYu8O6WTN4J3bciwjGq0c5nZlRDlxxRKGU78,2210
|
|
120
120
|
sqlmesh/core/test/__init__.py,sha256=e83TJPwPRR_rAG29Y0OVbZb-5oWVBzz-_wrcd22Qk10,418
|
|
121
|
-
sqlmesh/core/test/context.py,sha256=
|
|
121
|
+
sqlmesh/core/test/context.py,sha256=9mmskKXpzsIkW_I31uN1n3Ioj8ngvyGAqyL_AZvVHpc,2253
|
|
122
122
|
sqlmesh/core/test/definition.py,sha256=FxrY-D7dFOkWFVXislLvMTD0ps62LjsXOV1Y20zpoUA,41536
|
|
123
123
|
sqlmesh/core/test/discovery.py,sha256=WXIwPidLoacAGHoT_3TVFFEKamG89nHNtaMsZ01uGjs,1188
|
|
124
124
|
sqlmesh/core/test/result.py,sha256=IIyR4uMDDFJ9Hf57iwrHgZ_W_tLwnr0KSWKeBJ0Pc6k,3961
|
|
@@ -284,7 +284,7 @@ sqlmesh/utils/pydantic.py,sha256=o_NsXbIpDqNpUA1Uc5xF0ZzoXQYYB0DfHwdRxBwXPNk,120
|
|
|
284
284
|
sqlmesh/utils/rich.py,sha256=BpB47G0-JcU41LkGkeGKroexj4NOV5fox4-GOIXPgIc,3545
|
|
285
285
|
sqlmesh/utils/windows.py,sha256=r7Yin4WEwbvH7sKA3hOJtRsclmscNuBeCklCfVPvtQs,611
|
|
286
286
|
sqlmesh/utils/yaml.py,sha256=hvo5lmybYLcIx4p6CQwufS8X4MbwS60lEBnCmYJCXmU,2336
|
|
287
|
-
sqlmesh-0.200.1.
|
|
287
|
+
sqlmesh-0.200.1.dev23.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
|
|
288
288
|
web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
289
289
|
web/client/dist/index.html,sha256=DAv6ABGogw4xRLb0T_92WP_S7XWyqVhwBgGKWtuQwU4,5472
|
|
290
290
|
web/client/dist/assets/Audits-BuHAmFO8.js,sha256=zbYUF6WdUGMbnMm01GMNPb7xAJwj-o5wMdL56vPo2qE,1041
|
|
@@ -402,8 +402,8 @@ web/server/api/endpoints/models.py,sha256=kwj0s7uve3iZSMfmjkoPVMFMeY1sD0peTeyrWf
|
|
|
402
402
|
web/server/api/endpoints/modules.py,sha256=8hqqgonGay_mJmpCw0IdbjsPhWlQH2VLdKAqha-myac,468
|
|
403
403
|
web/server/api/endpoints/plan.py,sha256=bbbY50W_2MsZSTxOHWMKz0tbIm75nsRSlPy8GI2fg9Q,9306
|
|
404
404
|
web/server/api/endpoints/table_diff.py,sha256=SCy3-pr5x6bEEiOaZGCDbiHQhpgxwmnz3Acqa2Ie6jI,2090
|
|
405
|
-
sqlmesh-0.200.1.
|
|
406
|
-
sqlmesh-0.200.1.
|
|
407
|
-
sqlmesh-0.200.1.
|
|
408
|
-
sqlmesh-0.200.1.
|
|
409
|
-
sqlmesh-0.200.1.
|
|
405
|
+
sqlmesh-0.200.1.dev23.dist-info/METADATA,sha256=k_IZ-1m9C8722pgu_tsNx0HU9mFspEpSCs4YDfJOxvM,26679
|
|
406
|
+
sqlmesh-0.200.1.dev23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
407
|
+
sqlmesh-0.200.1.dev23.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
|
|
408
|
+
sqlmesh-0.200.1.dev23.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
|
|
409
|
+
sqlmesh-0.200.1.dev23.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|