sqlmesh 0.186.2.dev19__py3-none-any.whl → 0.186.2.dev20__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/context.py +46 -26
- sqlmesh/lsp/main.py +27 -8
- {sqlmesh-0.186.2.dev19.dist-info → sqlmesh-0.186.2.dev20.dist-info}/METADATA +1 -1
- {sqlmesh-0.186.2.dev19.dist-info → sqlmesh-0.186.2.dev20.dist-info}/RECORD +9 -9
- {sqlmesh-0.186.2.dev19.dist-info → sqlmesh-0.186.2.dev20.dist-info}/WHEEL +0 -0
- {sqlmesh-0.186.2.dev19.dist-info → sqlmesh-0.186.2.dev20.dist-info}/entry_points.txt +0 -0
- {sqlmesh-0.186.2.dev19.dist-info → sqlmesh-0.186.2.dev20.dist-info}/licenses/LICENSE +0 -0
- {sqlmesh-0.186.2.dev19.dist-info → sqlmesh-0.186.2.dev20.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.186.2.
|
|
21
|
-
__version_tuple__ = version_tuple = (0, 186, 2, '
|
|
20
|
+
__version__ = version = '0.186.2.dev20'
|
|
21
|
+
__version_tuple__ = version_tuple = (0, 186, 2, 'dev20')
|
sqlmesh/core/context.py
CHANGED
|
@@ -1129,33 +1129,15 @@ class GenericContext(BaseContext, t.Generic[C]):
|
|
|
1129
1129
|
|
|
1130
1130
|
with open(target._path, "r+", encoding="utf-8") as file:
|
|
1131
1131
|
before = file.read()
|
|
1132
|
-
expressions = parse(before, default_dialect=self.config_for_node(target).dialect)
|
|
1133
|
-
if transpile and is_meta_expression(expressions[0]):
|
|
1134
|
-
for prop in expressions[0].expressions:
|
|
1135
|
-
if prop.name.lower() == "dialect":
|
|
1136
|
-
prop.replace(
|
|
1137
|
-
exp.Property(
|
|
1138
|
-
this="dialect",
|
|
1139
|
-
value=exp.Literal.string(transpile or target.dialect),
|
|
1140
|
-
)
|
|
1141
|
-
)
|
|
1142
|
-
|
|
1143
|
-
format_config = self.config_for_node(target).format
|
|
1144
|
-
after = format_model_expressions(
|
|
1145
|
-
expressions,
|
|
1146
|
-
transpile or target.dialect,
|
|
1147
|
-
rewrite_casts=(
|
|
1148
|
-
rewrite_casts
|
|
1149
|
-
if rewrite_casts is not None
|
|
1150
|
-
else not format_config.no_rewrite_casts
|
|
1151
|
-
),
|
|
1152
|
-
**{**format_config.generator_options, **kwargs},
|
|
1153
|
-
)
|
|
1154
1132
|
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1133
|
+
after = self._format(
|
|
1134
|
+
target,
|
|
1135
|
+
before,
|
|
1136
|
+
transpile=transpile,
|
|
1137
|
+
rewrite_casts=rewrite_casts,
|
|
1138
|
+
append_newline=append_newline,
|
|
1139
|
+
**kwargs,
|
|
1140
|
+
)
|
|
1159
1141
|
|
|
1160
1142
|
if not check:
|
|
1161
1143
|
file.seek(0)
|
|
@@ -1174,6 +1156,44 @@ class GenericContext(BaseContext, t.Generic[C]):
|
|
|
1174
1156
|
|
|
1175
1157
|
return True
|
|
1176
1158
|
|
|
1159
|
+
def _format(
|
|
1160
|
+
self,
|
|
1161
|
+
target: Model | Audit,
|
|
1162
|
+
before: str,
|
|
1163
|
+
*,
|
|
1164
|
+
transpile: t.Optional[str] = None,
|
|
1165
|
+
rewrite_casts: t.Optional[bool] = None,
|
|
1166
|
+
append_newline: t.Optional[bool] = None,
|
|
1167
|
+
**kwargs: t.Any,
|
|
1168
|
+
) -> str:
|
|
1169
|
+
expressions = parse(before, default_dialect=self.config_for_node(target).dialect)
|
|
1170
|
+
if transpile and is_meta_expression(expressions[0]):
|
|
1171
|
+
for prop in expressions[0].expressions:
|
|
1172
|
+
if prop.name.lower() == "dialect":
|
|
1173
|
+
prop.replace(
|
|
1174
|
+
exp.Property(
|
|
1175
|
+
this="dialect",
|
|
1176
|
+
value=exp.Literal.string(transpile or target.dialect),
|
|
1177
|
+
)
|
|
1178
|
+
)
|
|
1179
|
+
|
|
1180
|
+
format_config = self.config_for_node(target).format
|
|
1181
|
+
after = format_model_expressions(
|
|
1182
|
+
expressions,
|
|
1183
|
+
transpile or target.dialect,
|
|
1184
|
+
rewrite_casts=(
|
|
1185
|
+
rewrite_casts if rewrite_casts is not None else not format_config.no_rewrite_casts
|
|
1186
|
+
),
|
|
1187
|
+
**{**format_config.generator_options, **kwargs},
|
|
1188
|
+
)
|
|
1189
|
+
|
|
1190
|
+
if append_newline is None:
|
|
1191
|
+
append_newline = format_config.append_newline
|
|
1192
|
+
if append_newline:
|
|
1193
|
+
after += "\n"
|
|
1194
|
+
|
|
1195
|
+
return after
|
|
1196
|
+
|
|
1177
1197
|
@python_api_analytics
|
|
1178
1198
|
def plan(
|
|
1179
1199
|
self,
|
sqlmesh/lsp/main.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
"""A Language Server Protocol (LSP) server for SQL with SQLMesh integration, refactored without globals."""
|
|
3
3
|
|
|
4
|
+
from itertools import chain
|
|
4
5
|
import logging
|
|
5
6
|
import typing as t
|
|
6
7
|
from pathlib import Path
|
|
@@ -20,7 +21,11 @@ from sqlmesh.lsp.api import (
|
|
|
20
21
|
ApiResponseGetModels,
|
|
21
22
|
)
|
|
22
23
|
from sqlmesh.lsp.completions import get_sql_completions
|
|
23
|
-
from sqlmesh.lsp.context import
|
|
24
|
+
from sqlmesh.lsp.context import (
|
|
25
|
+
LSPContext,
|
|
26
|
+
ModelTarget,
|
|
27
|
+
render_model as render_model_context,
|
|
28
|
+
)
|
|
24
29
|
from sqlmesh.lsp.custom import (
|
|
25
30
|
ALL_MODELS_FEATURE,
|
|
26
31
|
RENDER_MODEL_FEATURE,
|
|
@@ -213,15 +218,29 @@ class SQLMeshLanguageServer:
|
|
|
213
218
|
uri = URI(params.text_document.uri)
|
|
214
219
|
self._ensure_context_for_document(uri)
|
|
215
220
|
document = ls.workspace.get_text_document(params.text_document.uri)
|
|
221
|
+
before = document.source
|
|
216
222
|
if self.lsp_context is None:
|
|
217
223
|
raise RuntimeError(f"No context found for document: {document.path}")
|
|
218
224
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
+
target = next(
|
|
226
|
+
(
|
|
227
|
+
target
|
|
228
|
+
for target in chain(
|
|
229
|
+
self.lsp_context.context._models.values(),
|
|
230
|
+
self.lsp_context.context._audits.values(),
|
|
231
|
+
)
|
|
232
|
+
if target._path is not None
|
|
233
|
+
and target._path.suffix == ".sql"
|
|
234
|
+
and (target._path.samefile(uri.to_path()))
|
|
235
|
+
),
|
|
236
|
+
None,
|
|
237
|
+
)
|
|
238
|
+
if target is None:
|
|
239
|
+
return []
|
|
240
|
+
after = self.lsp_context.context._format(
|
|
241
|
+
target=target,
|
|
242
|
+
before=before,
|
|
243
|
+
)
|
|
225
244
|
return [
|
|
226
245
|
types.TextEdit(
|
|
227
246
|
range=types.Range(
|
|
@@ -231,7 +250,7 @@ class SQLMeshLanguageServer:
|
|
|
231
250
|
character=len(document.lines[-1]) if document.lines else 0,
|
|
232
251
|
),
|
|
233
252
|
),
|
|
234
|
-
new_text=
|
|
253
|
+
new_text=after,
|
|
235
254
|
)
|
|
236
255
|
]
|
|
237
256
|
except Exception as e:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
sqlmesh/__init__.py,sha256=69xw6bTmi4cW90M-sl3g6wLDgxVcLHcKg1q8GS3lqyA,7466
|
|
2
|
-
sqlmesh/_version.py,sha256=
|
|
2
|
+
sqlmesh/_version.py,sha256=md758L-6fCOTdjqRZ-XWWVl4pSKbkoIiqBeQD-HssQk,530
|
|
3
3
|
sqlmesh/magics.py,sha256=JHorAZNtezf123jmTyNSoUC9yHmv-08hMP205PJmmIo,39750
|
|
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=e1f7xO2aZCy38M_3VoDy-XI3shyd99-IFctgIFSgXWM,497
|
|
14
14
|
sqlmesh/core/console.py,sha256=ZAaGLOWBJGBxPzLV7KZZ9akPExgD5m5AboCM8O0Q0nY,150944
|
|
15
15
|
sqlmesh/core/constants.py,sha256=oqt6zjepUhQoWlgapKn_HpG7Pu9mrFwepdX5caNfJUI,2499
|
|
16
|
-
sqlmesh/core/context.py,sha256=
|
|
16
|
+
sqlmesh/core/context.py,sha256=gOwToFkXSQjb71Ki3cEqfxYjS64p2T2XKfZPVBtjGQA,115624
|
|
17
17
|
sqlmesh/core/context_diff.py,sha256=s9toP17d4tJfOpFH91LcjGK2CM64PVuB0MPkeFgF4hQ,20415
|
|
18
18
|
sqlmesh/core/dialect.py,sha256=fPTV517IOS0nWMxYznNNQnXkQkFFrPOSKe8ghsQ0o8A,49759
|
|
19
19
|
sqlmesh/core/environment.py,sha256=0TTQf4C4LXwf37fm-dfYv1qyG7vtZfQI5rizgm5g0j0,11442
|
|
@@ -160,7 +160,7 @@ sqlmesh/lsp/completions.py,sha256=Uo8lUzPBeoB58Eu2642YoAtNI0pgIFWFSvwmuJALTv4,35
|
|
|
160
160
|
sqlmesh/lsp/context.py,sha256=nCWg2uVH28-IJC2uDYuCbiXTh1lUFElSpNu4Q-fDWi4,2918
|
|
161
161
|
sqlmesh/lsp/custom.py,sha256=1YVcQz0y-4cdsvTdOQvlhUQXwOqPBWi3v_u1X2EqQxE,901
|
|
162
162
|
sqlmesh/lsp/description.py,sha256=4QIGC9ix8IzmWF6DVUNhY4m1Crk3sNQA6hZ1RbyqU78,827
|
|
163
|
-
sqlmesh/lsp/main.py,sha256=
|
|
163
|
+
sqlmesh/lsp/main.py,sha256=s8e9mD-J6pbxCrEZiMlRL0DvUu1rD3vxVdebgx5kjhA,19609
|
|
164
164
|
sqlmesh/lsp/reference.py,sha256=v4VXMYQY9rPC8b5w-jzob3i77VdZ1FZ8sA_-sWuPx7M,10502
|
|
165
165
|
sqlmesh/lsp/uri.py,sha256=mvSLbZGmMTHPpliThOtVWiFcHnfJzp1w39q9l-xD2SI,802
|
|
166
166
|
sqlmesh/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -270,7 +270,7 @@ sqlmesh/utils/pydantic.py,sha256=I898jAFqa3qU6lG2uPpRebVFncOUo8ZrLWM_R3K3DHU,116
|
|
|
270
270
|
sqlmesh/utils/rich.py,sha256=xNZyPCqEc4TAlJlsEthg-5eYUWpaizz0QjBzO7a1Yv4,1509
|
|
271
271
|
sqlmesh/utils/windows.py,sha256=r7Yin4WEwbvH7sKA3hOJtRsclmscNuBeCklCfVPvtQs,611
|
|
272
272
|
sqlmesh/utils/yaml.py,sha256=np-WVcwmwsKghCgAj1OBBMsK1SXSRn4wR-H37cGiFr8,2282
|
|
273
|
-
sqlmesh-0.186.2.
|
|
273
|
+
sqlmesh-0.186.2.dev20.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
|
|
274
274
|
web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
275
275
|
web/client/dist/index.html,sha256=M50OuwjW63dRCS0Dz40Yecgvw9ecLFqizbTa6gv5Nd4,5472
|
|
276
276
|
web/client/dist/assets/Audits-BPlxzqeG.js,sha256=TCx1qCjCGgmUSvH6HoPr5t8ztbRXMlOxrcW4o7hRjlA,1041
|
|
@@ -388,8 +388,8 @@ web/server/api/endpoints/models.py,sha256=ud-lRwriyI_OYg9tZchrBgeiXELiRTLNEodraf
|
|
|
388
388
|
web/server/api/endpoints/modules.py,sha256=8hqqgonGay_mJmpCw0IdbjsPhWlQH2VLdKAqha-myac,468
|
|
389
389
|
web/server/api/endpoints/plan.py,sha256=OYuQ_4dgbhG9ibTcX1a8mvYgH3ANxw9Fhbb4wg6QWqc,9222
|
|
390
390
|
web/server/api/endpoints/table_diff.py,sha256=Wd5YxeKbZB7AkrDvqFgvV9ZQlnKYOF1n5W_w2EHE_Zw,2085
|
|
391
|
-
sqlmesh-0.186.2.
|
|
392
|
-
sqlmesh-0.186.2.
|
|
393
|
-
sqlmesh-0.186.2.
|
|
394
|
-
sqlmesh-0.186.2.
|
|
395
|
-
sqlmesh-0.186.2.
|
|
391
|
+
sqlmesh-0.186.2.dev20.dist-info/METADATA,sha256=7njLBJTTA1FSif3Pvs0NSw7SoMzwz3DzupTHsU1ZS40,25524
|
|
392
|
+
sqlmesh-0.186.2.dev20.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
|
393
|
+
sqlmesh-0.186.2.dev20.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
|
|
394
|
+
sqlmesh-0.186.2.dev20.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
|
|
395
|
+
sqlmesh-0.186.2.dev20.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|