sqlmesh 0.190.1.dev1__py3-none-any.whl → 0.190.1.dev3__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/lsp/helpers.py +24 -11
- sqlmesh/lsp/main.py +21 -5
- sqlmesh/lsp/reference.py +74 -12
- {sqlmesh-0.190.1.dev1.dist-info → sqlmesh-0.190.1.dev3.dist-info}/METADATA +2 -2
- {sqlmesh-0.190.1.dev1.dist-info → sqlmesh-0.190.1.dev3.dist-info}/RECORD +10 -10
- {sqlmesh-0.190.1.dev1.dist-info → sqlmesh-0.190.1.dev3.dist-info}/WHEEL +0 -0
- {sqlmesh-0.190.1.dev1.dist-info → sqlmesh-0.190.1.dev3.dist-info}/entry_points.txt +0 -0
- {sqlmesh-0.190.1.dev1.dist-info → sqlmesh-0.190.1.dev3.dist-info}/licenses/LICENSE +0 -0
- {sqlmesh-0.190.1.dev1.dist-info → sqlmesh-0.190.1.dev3.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.190.1.
|
|
21
|
-
__version_tuple__ = version_tuple = (0, 190, 1, '
|
|
20
|
+
__version__ = version = '0.190.1.dev3'
|
|
21
|
+
__version_tuple__ = version_tuple = (0, 190, 1, 'dev3')
|
sqlmesh/lsp/helpers.py
CHANGED
|
@@ -6,22 +6,35 @@ from sqlmesh.core.linter.helpers import (
|
|
|
6
6
|
)
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
def
|
|
10
|
-
range: SQLMeshRange,
|
|
11
|
-
) -> Range:
|
|
9
|
+
def to_sqlmesh_position(position: Position) -> SQLMeshPosition:
|
|
12
10
|
"""
|
|
13
|
-
Converts
|
|
11
|
+
Converts an LSP Position to a SQLMesh Position.
|
|
14
12
|
"""
|
|
15
|
-
return
|
|
16
|
-
start=Position(line=range.start.line, character=range.start.character),
|
|
17
|
-
end=Position(line=range.end.line, character=range.end.character),
|
|
18
|
-
)
|
|
13
|
+
return SQLMeshPosition(line=position.line, character=position.character)
|
|
19
14
|
|
|
20
15
|
|
|
21
|
-
def to_lsp_position(
|
|
22
|
-
position: SQLMeshPosition,
|
|
23
|
-
) -> Position:
|
|
16
|
+
def to_lsp_position(position: SQLMeshPosition) -> Position:
|
|
24
17
|
"""
|
|
25
18
|
Converts a SQLMesh Position to an LSP Position.
|
|
26
19
|
"""
|
|
27
20
|
return Position(line=position.line, character=position.character)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def to_sqlmesh_range(range: Range) -> SQLMeshRange:
|
|
24
|
+
"""
|
|
25
|
+
Converts an LSP Range to a SQLMesh Range.
|
|
26
|
+
"""
|
|
27
|
+
return SQLMeshRange(
|
|
28
|
+
start=to_sqlmesh_position(range.start),
|
|
29
|
+
end=to_sqlmesh_position(range.end),
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def to_lsp_range(range: SQLMeshRange) -> Range:
|
|
34
|
+
"""
|
|
35
|
+
Converts a SQLMesh Range to an LSP Range.
|
|
36
|
+
"""
|
|
37
|
+
return Range(
|
|
38
|
+
start=to_lsp_position(range.start),
|
|
39
|
+
end=to_lsp_position(range.end),
|
|
40
|
+
)
|
sqlmesh/lsp/main.py
CHANGED
|
@@ -48,6 +48,7 @@ from sqlmesh.lsp.hints import get_hints
|
|
|
48
48
|
from sqlmesh.lsp.reference import (
|
|
49
49
|
LSPCteReference,
|
|
50
50
|
LSPModelReference,
|
|
51
|
+
LSPExternalModelReference,
|
|
51
52
|
get_references,
|
|
52
53
|
get_all_references,
|
|
53
54
|
)
|
|
@@ -444,11 +445,19 @@ class SQLMeshLanguageServer:
|
|
|
444
445
|
references = get_references(self.lsp_context, uri, params.position)
|
|
445
446
|
location_links = []
|
|
446
447
|
for reference in references:
|
|
447
|
-
# Use target_range if available (CTEs, Macros
|
|
448
|
-
if
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
448
|
+
# Use target_range if available (CTEs, Macros, and external models in YAML)
|
|
449
|
+
if isinstance(reference, LSPModelReference):
|
|
450
|
+
# Regular SQL models - default to start of file
|
|
451
|
+
target_range = types.Range(
|
|
452
|
+
start=types.Position(line=0, character=0),
|
|
453
|
+
end=types.Position(line=0, character=0),
|
|
454
|
+
)
|
|
455
|
+
target_selection_range = types.Range(
|
|
456
|
+
start=types.Position(line=0, character=0),
|
|
457
|
+
end=types.Position(line=0, character=0),
|
|
458
|
+
)
|
|
459
|
+
elif isinstance(reference, LSPExternalModelReference):
|
|
460
|
+
# External models may have target_range set for YAML files
|
|
452
461
|
target_range = types.Range(
|
|
453
462
|
start=types.Position(line=0, character=0),
|
|
454
463
|
end=types.Position(line=0, character=0),
|
|
@@ -457,6 +466,13 @@ class SQLMeshLanguageServer:
|
|
|
457
466
|
start=types.Position(line=0, character=0),
|
|
458
467
|
end=types.Position(line=0, character=0),
|
|
459
468
|
)
|
|
469
|
+
if reference.target_range is not None:
|
|
470
|
+
target_range = reference.target_range
|
|
471
|
+
target_selection_range = reference.target_range
|
|
472
|
+
else:
|
|
473
|
+
# CTEs and Macros always have target_range
|
|
474
|
+
target_range = reference.target_range
|
|
475
|
+
target_selection_range = reference.target_range
|
|
460
476
|
|
|
461
477
|
location_links.append(
|
|
462
478
|
types.LocationLink(
|
sqlmesh/lsp/reference.py
CHANGED
|
@@ -8,7 +8,7 @@ from sqlmesh.core.dialect import normalize_model_name
|
|
|
8
8
|
from sqlmesh.core.linter.helpers import (
|
|
9
9
|
TokenPositionDetails,
|
|
10
10
|
)
|
|
11
|
-
from sqlmesh.core.model.definition import SqlModel
|
|
11
|
+
from sqlmesh.core.model.definition import SqlModel, ExternalModel
|
|
12
12
|
from sqlmesh.lsp.context import LSPContext, ModelTarget, AuditTarget
|
|
13
13
|
from sqlglot import exp
|
|
14
14
|
from sqlmesh.lsp.description import generate_markdown_description
|
|
@@ -22,10 +22,11 @@ import ast
|
|
|
22
22
|
from sqlmesh.core.model import Model
|
|
23
23
|
from sqlmesh import macro
|
|
24
24
|
import inspect
|
|
25
|
+
from ruamel.yaml import YAML
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
class LSPModelReference(PydanticModel):
|
|
28
|
-
"""A LSP reference to a model."""
|
|
29
|
+
"""A LSP reference to a model, excluding external models."""
|
|
29
30
|
|
|
30
31
|
type: t.Literal["model"] = "model"
|
|
31
32
|
uri: str
|
|
@@ -33,6 +34,16 @@ class LSPModelReference(PydanticModel):
|
|
|
33
34
|
markdown_description: t.Optional[str] = None
|
|
34
35
|
|
|
35
36
|
|
|
37
|
+
class LSPExternalModelReference(PydanticModel):
|
|
38
|
+
"""A LSP reference to an external model."""
|
|
39
|
+
|
|
40
|
+
type: t.Literal["external_model"] = "external_model"
|
|
41
|
+
uri: str
|
|
42
|
+
range: Range
|
|
43
|
+
markdown_description: t.Optional[str] = None
|
|
44
|
+
target_range: t.Optional[Range] = None
|
|
45
|
+
|
|
46
|
+
|
|
36
47
|
class LSPCteReference(PydanticModel):
|
|
37
48
|
"""A LSP reference to a CTE."""
|
|
38
49
|
|
|
@@ -53,7 +64,8 @@ class LSPMacroReference(PydanticModel):
|
|
|
53
64
|
|
|
54
65
|
|
|
55
66
|
Reference = t.Annotated[
|
|
56
|
-
t.Union[LSPModelReference, LSPCteReference, LSPMacroReference],
|
|
67
|
+
t.Union[LSPModelReference, LSPCteReference, LSPMacroReference, LSPExternalModelReference],
|
|
68
|
+
Field(discriminator="type"),
|
|
57
69
|
]
|
|
58
70
|
|
|
59
71
|
|
|
@@ -243,16 +255,38 @@ def get_model_definitions_for_a_path(
|
|
|
243
255
|
|
|
244
256
|
description = generate_markdown_description(referenced_model)
|
|
245
257
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
258
|
+
# For external models in YAML files, find the specific model block
|
|
259
|
+
if isinstance(referenced_model, ExternalModel):
|
|
260
|
+
yaml_target_range: t.Optional[Range] = None
|
|
261
|
+
if (
|
|
262
|
+
referenced_model_path.suffix in (".yaml", ".yml")
|
|
263
|
+
and referenced_model_path.is_file()
|
|
264
|
+
):
|
|
265
|
+
yaml_target_range = _get_yaml_model_range(
|
|
266
|
+
referenced_model_path, referenced_model.name
|
|
267
|
+
)
|
|
268
|
+
references.append(
|
|
269
|
+
LSPExternalModelReference(
|
|
270
|
+
uri=referenced_model_uri.value,
|
|
271
|
+
range=Range(
|
|
272
|
+
start=to_lsp_position(start_pos_sqlmesh),
|
|
273
|
+
end=to_lsp_position(end_pos_sqlmesh),
|
|
274
|
+
),
|
|
275
|
+
markdown_description=description,
|
|
276
|
+
target_range=yaml_target_range,
|
|
277
|
+
)
|
|
278
|
+
)
|
|
279
|
+
else:
|
|
280
|
+
references.append(
|
|
281
|
+
LSPModelReference(
|
|
282
|
+
uri=referenced_model_uri.value,
|
|
283
|
+
range=Range(
|
|
284
|
+
start=to_lsp_position(start_pos_sqlmesh),
|
|
285
|
+
end=to_lsp_position(end_pos_sqlmesh),
|
|
286
|
+
),
|
|
287
|
+
markdown_description=description,
|
|
288
|
+
)
|
|
254
289
|
)
|
|
255
|
-
)
|
|
256
290
|
|
|
257
291
|
return references
|
|
258
292
|
|
|
@@ -699,3 +733,31 @@ def _position_within_range(position: Position, range: Range) -> bool:
|
|
|
699
733
|
range.end.line > position.line
|
|
700
734
|
or (range.end.line == position.line and range.end.character >= position.character)
|
|
701
735
|
)
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
def _get_yaml_model_range(path: Path, model_name: str) -> t.Optional[Range]:
|
|
739
|
+
"""
|
|
740
|
+
Find the range of a specific model block in a YAML file.
|
|
741
|
+
|
|
742
|
+
Args:
|
|
743
|
+
yaml_path: Path to the YAML file
|
|
744
|
+
model_name: Name of the model to find
|
|
745
|
+
|
|
746
|
+
Returns:
|
|
747
|
+
The Range of the model block in the YAML file, or None if not found
|
|
748
|
+
"""
|
|
749
|
+
yaml = YAML()
|
|
750
|
+
with path.open("r", encoding="utf-8") as f:
|
|
751
|
+
data = yaml.load(f)
|
|
752
|
+
|
|
753
|
+
if not isinstance(data, list):
|
|
754
|
+
return None
|
|
755
|
+
|
|
756
|
+
for item in data:
|
|
757
|
+
if isinstance(item, dict) and item.get("name") == model_name:
|
|
758
|
+
# Get size of block by taking the earliest line/col in the items block and the last line/col of the block
|
|
759
|
+
position_data = item.lc.data["name"] # type: ignore
|
|
760
|
+
start = Position(line=position_data[2], character=position_data[3])
|
|
761
|
+
end = Position(line=position_data[2], character=position_data[3] + len(item["name"]))
|
|
762
|
+
return Range(start=start, end=end)
|
|
763
|
+
return None
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlmesh
|
|
3
|
-
Version: 0.190.1.
|
|
3
|
+
Version: 0.190.1.dev3
|
|
4
4
|
Summary: Next-generation data transformation framework
|
|
5
5
|
Author-email: "TobikoData Inc." <engineering@tobikodata.com>
|
|
6
6
|
License: Apache License
|
|
@@ -233,7 +233,7 @@ Requires-Dist: pydantic>=2.0.0
|
|
|
233
233
|
Requires-Dist: requests
|
|
234
234
|
Requires-Dist: rich[jupyter]
|
|
235
235
|
Requires-Dist: ruamel.yaml
|
|
236
|
-
Requires-Dist: sqlglot[rs]~=26.
|
|
236
|
+
Requires-Dist: sqlglot[rs]~=26.26.0
|
|
237
237
|
Requires-Dist: tenacity
|
|
238
238
|
Requires-Dist: time-machine
|
|
239
239
|
Requires-Dist: json-stream
|
|
@@ -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=hqtfkM900kyLDFBA0kXts6JWhLh4HOvDmPLKEFfLcJQ,528
|
|
3
3
|
sqlmesh/magics.py,sha256=gjzoxREb1XT8Yho_PQMlMqhhkLq_sEfBM8S3PTgxvWE,40337
|
|
4
4
|
sqlmesh/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
sqlmesh/cicd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -163,10 +163,10 @@ sqlmesh/lsp/completions.py,sha256=OTI7Ga6NNtaC_k80W1wI9Tft0gMBmaTJOt6gW_DF6GE,64
|
|
|
163
163
|
sqlmesh/lsp/context.py,sha256=QGbNL0sifxzVJ7T1U5oWcJ5FXrOrLrVKt1jtH1qM_50,6099
|
|
164
164
|
sqlmesh/lsp/custom.py,sha256=3eNuwP4Q5vT7l9RxpPYUiY-91c2w5FSTEKSHdGJf7CA,2705
|
|
165
165
|
sqlmesh/lsp/description.py,sha256=4QIGC9ix8IzmWF6DVUNhY4m1Crk3sNQA6hZ1RbyqU78,827
|
|
166
|
-
sqlmesh/lsp/helpers.py,sha256=
|
|
166
|
+
sqlmesh/lsp/helpers.py,sha256=EFc1u3-b7kSv5-tNwmKUDxId72RCLDBnN2lLTgRSzzQ,1020
|
|
167
167
|
sqlmesh/lsp/hints.py,sha256=j-blccBUil94yRoDjWfkSM0HqMmsKD6hP2TaWdWWVk4,3734
|
|
168
|
-
sqlmesh/lsp/main.py,sha256=
|
|
169
|
-
sqlmesh/lsp/reference.py,sha256=
|
|
168
|
+
sqlmesh/lsp/main.py,sha256=4fpL59afwuI4iPBHQedWEarM9Wa5e5IWQ_KMF8eW6NU,36664
|
|
169
|
+
sqlmesh/lsp/reference.py,sha256=8hZT3wH8zmWiFEySS1_nVhhLg-CKCGncf9wG3LGBef8,26432
|
|
170
170
|
sqlmesh/lsp/uri.py,sha256=mvSLbZGmMTHPpliThOtVWiFcHnfJzp1w39q9l-xD2SI,802
|
|
171
171
|
sqlmesh/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
172
172
|
sqlmesh/migrations/v0001_init.py,sha256=h8FwMYJj9_O8yGpk12guaSaGwX5A3we2GiKeHrXi15o,2048
|
|
@@ -275,7 +275,7 @@ sqlmesh/utils/pydantic.py,sha256=I898jAFqa3qU6lG2uPpRebVFncOUo8ZrLWM_R3K3DHU,116
|
|
|
275
275
|
sqlmesh/utils/rich.py,sha256=xNZyPCqEc4TAlJlsEthg-5eYUWpaizz0QjBzO7a1Yv4,1509
|
|
276
276
|
sqlmesh/utils/windows.py,sha256=r7Yin4WEwbvH7sKA3hOJtRsclmscNuBeCklCfVPvtQs,611
|
|
277
277
|
sqlmesh/utils/yaml.py,sha256=np-WVcwmwsKghCgAj1OBBMsK1SXSRn4wR-H37cGiFr8,2282
|
|
278
|
-
sqlmesh-0.190.1.
|
|
278
|
+
sqlmesh-0.190.1.dev3.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
|
|
279
279
|
web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
280
280
|
web/client/dist/index.html,sha256=k5bAEoPDJ0BhYQ4hBcKWObITCxIgqOUC28nGXvEDrt0,5472
|
|
281
281
|
web/client/dist/assets/Audits-Pgs8N6IE.js,sha256=BQuc9kiznZSqTnzNrJSDNqAAdOTGjNQJt32M1sHZFok,1041
|
|
@@ -393,8 +393,8 @@ web/server/api/endpoints/models.py,sha256=ud-lRwriyI_OYg9tZchrBgeiXELiRTLNEodraf
|
|
|
393
393
|
web/server/api/endpoints/modules.py,sha256=8hqqgonGay_mJmpCw0IdbjsPhWlQH2VLdKAqha-myac,468
|
|
394
394
|
web/server/api/endpoints/plan.py,sha256=OYuQ_4dgbhG9ibTcX1a8mvYgH3ANxw9Fhbb4wg6QWqc,9222
|
|
395
395
|
web/server/api/endpoints/table_diff.py,sha256=SCy3-pr5x6bEEiOaZGCDbiHQhpgxwmnz3Acqa2Ie6jI,2090
|
|
396
|
-
sqlmesh-0.190.1.
|
|
397
|
-
sqlmesh-0.190.1.
|
|
398
|
-
sqlmesh-0.190.1.
|
|
399
|
-
sqlmesh-0.190.1.
|
|
400
|
-
sqlmesh-0.190.1.
|
|
396
|
+
sqlmesh-0.190.1.dev3.dist-info/METADATA,sha256=pS822y8QNXG1CP3s9f3hbOJlnbj7cMrX9QHeNzLvor4,26540
|
|
397
|
+
sqlmesh-0.190.1.dev3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
398
|
+
sqlmesh-0.190.1.dev3.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
|
|
399
|
+
sqlmesh-0.190.1.dev3.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
|
|
400
|
+
sqlmesh-0.190.1.dev3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|