sqlmesh 0.183.1.dev12__py3-none-any.whl → 0.183.1.dev14__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/macros.py +21 -17
- sqlmesh/lsp/completions.py +4 -3
- sqlmesh/lsp/context.py +7 -8
- sqlmesh/lsp/main.py +40 -45
- sqlmesh/lsp/reference.py +6 -7
- sqlmesh/lsp/uri.py +33 -0
- {sqlmesh-0.183.1.dev12.dist-info → sqlmesh-0.183.1.dev14.dist-info}/METADATA +1 -1
- {sqlmesh-0.183.1.dev12.dist-info → sqlmesh-0.183.1.dev14.dist-info}/RECORD +13 -12
- {sqlmesh-0.183.1.dev12.dist-info → sqlmesh-0.183.1.dev14.dist-info}/WHEEL +0 -0
- {sqlmesh-0.183.1.dev12.dist-info → sqlmesh-0.183.1.dev14.dist-info}/entry_points.txt +0 -0
- {sqlmesh-0.183.1.dev12.dist-info → sqlmesh-0.183.1.dev14.dist-info}/licenses/LICENSE +0 -0
- {sqlmesh-0.183.1.dev12.dist-info → sqlmesh-0.183.1.dev14.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.183.1.
|
|
21
|
-
__version_tuple__ = version_tuple = (0, 183, 1, '
|
|
20
|
+
__version__ = version = '0.183.1.dev14'
|
|
21
|
+
__version_tuple__ = version_tuple = (0, 183, 1, 'dev14')
|
sqlmesh/core/macros.py
CHANGED
|
@@ -1087,17 +1087,17 @@ def haversine_distance(
|
|
|
1087
1087
|
@macro()
|
|
1088
1088
|
def pivot(
|
|
1089
1089
|
evaluator: MacroEvaluator,
|
|
1090
|
-
column:
|
|
1091
|
-
values: t.
|
|
1092
|
-
alias:
|
|
1093
|
-
agg:
|
|
1094
|
-
cmp:
|
|
1095
|
-
prefix:
|
|
1096
|
-
suffix:
|
|
1097
|
-
then_value:
|
|
1098
|
-
else_value:
|
|
1099
|
-
quote:
|
|
1100
|
-
distinct:
|
|
1090
|
+
column: SQL,
|
|
1091
|
+
values: t.List[SQL],
|
|
1092
|
+
alias: bool = True,
|
|
1093
|
+
agg: SQL = SQL("SUM"),
|
|
1094
|
+
cmp: SQL = SQL("="),
|
|
1095
|
+
prefix: SQL = SQL(""),
|
|
1096
|
+
suffix: SQL = SQL(""),
|
|
1097
|
+
then_value: SQL = SQL("1"),
|
|
1098
|
+
else_value: SQL = SQL("0"),
|
|
1099
|
+
quote: bool = True,
|
|
1100
|
+
distinct: bool = False,
|
|
1101
1101
|
) -> t.List[exp.Expression]:
|
|
1102
1102
|
"""Returns a list of projections as a result of pivoting the given column on the given values.
|
|
1103
1103
|
|
|
@@ -1109,15 +1109,19 @@ def pivot(
|
|
|
1109
1109
|
'SELECT date_day, SUM(CASE WHEN status = \\'cancelled\\' THEN 1 ELSE 0 END) AS "\\'cancelled\\'", SUM(CASE WHEN status = \\'completed\\' THEN 1 ELSE 0 END) AS "\\'completed\\'" FROM rides GROUP BY 1'
|
|
1110
1110
|
"""
|
|
1111
1111
|
aggregates: t.List[exp.Expression] = []
|
|
1112
|
-
for value in values
|
|
1113
|
-
proj = f"{agg
|
|
1114
|
-
if distinct
|
|
1112
|
+
for value in values:
|
|
1113
|
+
proj = f"{agg}("
|
|
1114
|
+
if distinct:
|
|
1115
1115
|
proj += "DISTINCT "
|
|
1116
|
-
|
|
1116
|
+
|
|
1117
|
+
proj += f"CASE WHEN {column} {cmp} {value} THEN {then_value} ELSE {else_value} END) "
|
|
1117
1118
|
node = evaluator.parse_one(proj)
|
|
1118
|
-
|
|
1119
|
-
|
|
1119
|
+
|
|
1120
|
+
if alias:
|
|
1121
|
+
node = node.as_(f"{prefix}{value}{suffix}", quoted=quote, copy=False)
|
|
1122
|
+
|
|
1120
1123
|
aggregates.append(node)
|
|
1124
|
+
|
|
1121
1125
|
return aggregates
|
|
1122
1126
|
|
|
1123
1127
|
|
sqlmesh/lsp/completions.py
CHANGED
|
@@ -3,9 +3,10 @@ from sqlglot import Dialect, Tokenizer
|
|
|
3
3
|
from sqlmesh.lsp.custom import AllModelsResponse
|
|
4
4
|
import typing as t
|
|
5
5
|
from sqlmesh.lsp.context import AuditTarget, LSPContext, ModelTarget
|
|
6
|
+
from sqlmesh.lsp.uri import URI
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
def get_sql_completions(context: t.Optional[LSPContext], file_uri:
|
|
9
|
+
def get_sql_completions(context: t.Optional[LSPContext], file_uri: URI) -> AllModelsResponse:
|
|
9
10
|
"""
|
|
10
11
|
Return a list of completions for a given file.
|
|
11
12
|
"""
|
|
@@ -15,7 +16,7 @@ def get_sql_completions(context: t.Optional[LSPContext], file_uri: str) -> AllMo
|
|
|
15
16
|
)
|
|
16
17
|
|
|
17
18
|
|
|
18
|
-
def get_models(context: t.Optional[LSPContext], file_uri: t.Optional[
|
|
19
|
+
def get_models(context: t.Optional[LSPContext], file_uri: t.Optional[URI]) -> t.Set[str]:
|
|
19
20
|
"""
|
|
20
21
|
Return a list of models for a given file.
|
|
21
22
|
|
|
@@ -41,7 +42,7 @@ def get_models(context: t.Optional[LSPContext], file_uri: t.Optional[str]) -> t.
|
|
|
41
42
|
return all_models
|
|
42
43
|
|
|
43
44
|
|
|
44
|
-
def get_keywords(context: t.Optional[LSPContext], file_uri: t.Optional[
|
|
45
|
+
def get_keywords(context: t.Optional[LSPContext], file_uri: t.Optional[URI]) -> t.Set[str]:
|
|
45
46
|
"""
|
|
46
47
|
Return a list of sql keywords for a given file.
|
|
47
48
|
If no context is provided, return ANSI SQL keywords.
|
sqlmesh/lsp/context.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
|
-
from pathlib import Path
|
|
3
2
|
from sqlmesh.core.context import Context
|
|
4
3
|
import typing as t
|
|
5
4
|
|
|
5
|
+
from sqlmesh.lsp.uri import URI
|
|
6
|
+
|
|
6
7
|
|
|
7
8
|
@dataclass
|
|
8
9
|
class ModelTarget:
|
|
@@ -28,26 +29,24 @@ class LSPContext:
|
|
|
28
29
|
self.context = context
|
|
29
30
|
|
|
30
31
|
# Add models to the map
|
|
31
|
-
model_map: t.Dict[
|
|
32
|
+
model_map: t.Dict[URI, ModelTarget] = {}
|
|
32
33
|
for model in context.models.values():
|
|
33
34
|
if model._path is not None:
|
|
34
|
-
|
|
35
|
-
uri = f"file://{path.as_posix()}"
|
|
35
|
+
uri = URI.from_path(model._path)
|
|
36
36
|
if uri in model_map:
|
|
37
37
|
model_map[uri].names.append(model.name)
|
|
38
38
|
else:
|
|
39
39
|
model_map[uri] = ModelTarget(names=[model.name])
|
|
40
40
|
|
|
41
41
|
# Add standalone audits to the map
|
|
42
|
-
audit_map: t.Dict[
|
|
42
|
+
audit_map: t.Dict[URI, AuditTarget] = {}
|
|
43
43
|
for audit in context.standalone_audits.values():
|
|
44
44
|
if audit._path is not None:
|
|
45
|
-
|
|
46
|
-
uri = f"file://{path.as_posix()}"
|
|
45
|
+
uri = URI.from_path(audit._path)
|
|
47
46
|
if uri not in audit_map:
|
|
48
47
|
audit_map[uri] = AuditTarget(name=audit.name)
|
|
49
48
|
|
|
50
|
-
self.map: t.Dict[
|
|
49
|
+
self.map: t.Dict[URI, t.Union[ModelTarget, AuditTarget]] = {
|
|
51
50
|
**model_map,
|
|
52
51
|
**audit_map,
|
|
53
52
|
}
|
sqlmesh/lsp/main.py
CHANGED
|
@@ -23,6 +23,7 @@ from sqlmesh.lsp.custom import ALL_MODELS_FEATURE, AllModelsRequest, AllModelsRe
|
|
|
23
23
|
from sqlmesh.lsp.reference import (
|
|
24
24
|
get_references,
|
|
25
25
|
)
|
|
26
|
+
from sqlmesh.lsp.uri import URI
|
|
26
27
|
from web.server.api.endpoints.lineage import model_lineage
|
|
27
28
|
from web.server.api.endpoints.models import get_models
|
|
28
29
|
|
|
@@ -42,7 +43,7 @@ class SQLMeshLanguageServer:
|
|
|
42
43
|
self.server = LanguageServer(server_name, version)
|
|
43
44
|
self.context_class = context_class
|
|
44
45
|
self.lsp_context: t.Optional[LSPContext] = None
|
|
45
|
-
self.lint_cache: t.Dict[
|
|
46
|
+
self.lint_cache: t.Dict[URI, t.List[AnnotatedRuleViolation]] = {}
|
|
46
47
|
|
|
47
48
|
# Register LSP features (e.g., formatting, hover, etc.)
|
|
48
49
|
self._register_features()
|
|
@@ -82,10 +83,11 @@ class SQLMeshLanguageServer:
|
|
|
82
83
|
@self.server.feature(ALL_MODELS_FEATURE)
|
|
83
84
|
def all_models(ls: LanguageServer, params: AllModelsRequest) -> AllModelsResponse:
|
|
84
85
|
try:
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
uri = URI(params.textDocument.uri)
|
|
87
|
+
context = self._context_get_or_load(uri)
|
|
88
|
+
return get_sql_completions(context, uri)
|
|
87
89
|
except Exception as e:
|
|
88
|
-
return get_sql_completions(None,
|
|
90
|
+
return get_sql_completions(None, uri)
|
|
89
91
|
|
|
90
92
|
@self.server.feature(API_FEATURE)
|
|
91
93
|
def api(
|
|
@@ -106,67 +108,62 @@ class SQLMeshLanguageServer:
|
|
|
106
108
|
|
|
107
109
|
@self.server.feature(types.TEXT_DOCUMENT_DID_OPEN)
|
|
108
110
|
def did_open(ls: LanguageServer, params: types.DidOpenTextDocumentParams) -> None:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
uri = URI(params.text_document.uri)
|
|
112
|
+
context = self._context_get_or_load(uri)
|
|
113
|
+
if self.lint_cache.get(uri) is not None:
|
|
111
114
|
ls.publish_diagnostics(
|
|
112
115
|
params.text_document.uri,
|
|
113
|
-
SQLMeshLanguageServer._diagnostics_to_lsp_diagnostics(
|
|
114
|
-
self.lint_cache[params.text_document.uri]
|
|
115
|
-
),
|
|
116
|
+
SQLMeshLanguageServer._diagnostics_to_lsp_diagnostics(self.lint_cache[uri]),
|
|
116
117
|
)
|
|
117
118
|
return
|
|
118
|
-
models = context.map[
|
|
119
|
+
models = context.map[uri]
|
|
119
120
|
if models is None:
|
|
120
121
|
return
|
|
121
122
|
if not isinstance(models, ModelTarget):
|
|
122
123
|
return
|
|
123
|
-
self.lint_cache[
|
|
124
|
+
self.lint_cache[uri] = context.context.lint_models(
|
|
124
125
|
models.names,
|
|
125
126
|
raise_on_error=False,
|
|
126
127
|
)
|
|
127
128
|
ls.publish_diagnostics(
|
|
128
129
|
params.text_document.uri,
|
|
129
|
-
SQLMeshLanguageServer._diagnostics_to_lsp_diagnostics(
|
|
130
|
-
self.lint_cache[params.text_document.uri]
|
|
131
|
-
),
|
|
130
|
+
SQLMeshLanguageServer._diagnostics_to_lsp_diagnostics(self.lint_cache[uri]),
|
|
132
131
|
)
|
|
133
132
|
|
|
134
133
|
@self.server.feature(types.TEXT_DOCUMENT_DID_CHANGE)
|
|
135
134
|
def did_change(ls: LanguageServer, params: types.DidChangeTextDocumentParams) -> None:
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
uri = URI(params.text_document.uri)
|
|
136
|
+
context = self._context_get_or_load(uri)
|
|
137
|
+
models = context.map[uri]
|
|
138
138
|
if models is None:
|
|
139
139
|
return
|
|
140
140
|
if not isinstance(models, ModelTarget):
|
|
141
141
|
return
|
|
142
|
-
self.lint_cache[
|
|
142
|
+
self.lint_cache[uri] = context.context.lint_models(
|
|
143
143
|
models.names,
|
|
144
144
|
raise_on_error=False,
|
|
145
145
|
)
|
|
146
146
|
ls.publish_diagnostics(
|
|
147
147
|
params.text_document.uri,
|
|
148
|
-
SQLMeshLanguageServer._diagnostics_to_lsp_diagnostics(
|
|
149
|
-
self.lint_cache[params.text_document.uri]
|
|
150
|
-
),
|
|
148
|
+
SQLMeshLanguageServer._diagnostics_to_lsp_diagnostics(self.lint_cache[uri]),
|
|
151
149
|
)
|
|
152
150
|
|
|
153
151
|
@self.server.feature(types.TEXT_DOCUMENT_DID_SAVE)
|
|
154
152
|
def did_save(ls: LanguageServer, params: types.DidSaveTextDocumentParams) -> None:
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
uri = URI(params.text_document.uri)
|
|
154
|
+
context = self._context_get_or_load(uri)
|
|
155
|
+
models = context.map[uri]
|
|
157
156
|
if models is None:
|
|
158
157
|
return
|
|
159
158
|
if not isinstance(models, ModelTarget):
|
|
160
159
|
return
|
|
161
|
-
self.lint_cache[
|
|
160
|
+
self.lint_cache[uri] = context.context.lint_models(
|
|
162
161
|
models.names,
|
|
163
162
|
raise_on_error=False,
|
|
164
163
|
)
|
|
165
164
|
ls.publish_diagnostics(
|
|
166
165
|
params.text_document.uri,
|
|
167
|
-
SQLMeshLanguageServer._diagnostics_to_lsp_diagnostics(
|
|
168
|
-
self.lint_cache[params.text_document.uri]
|
|
169
|
-
),
|
|
166
|
+
SQLMeshLanguageServer._diagnostics_to_lsp_diagnostics(self.lint_cache[uri]),
|
|
170
167
|
)
|
|
171
168
|
|
|
172
169
|
@self.server.feature(types.TEXT_DOCUMENT_FORMATTING)
|
|
@@ -175,14 +172,15 @@ class SQLMeshLanguageServer:
|
|
|
175
172
|
) -> t.List[types.TextEdit]:
|
|
176
173
|
"""Format the document using SQLMesh `format_model_expressions`."""
|
|
177
174
|
try:
|
|
178
|
-
|
|
175
|
+
uri = URI(params.text_document.uri)
|
|
176
|
+
self._ensure_context_for_document(uri)
|
|
179
177
|
document = ls.workspace.get_text_document(params.text_document.uri)
|
|
180
178
|
if self.lsp_context is None:
|
|
181
179
|
raise RuntimeError(f"No context found for document: {document.path}")
|
|
182
180
|
|
|
183
181
|
# Perform formatting using the loaded context
|
|
184
|
-
self.lsp_context.context.format(paths=(
|
|
185
|
-
with open(
|
|
182
|
+
self.lsp_context.context.format(paths=(str(uri.to_path()),))
|
|
183
|
+
with open(uri.to_path(), "r+", encoding="utf-8") as file:
|
|
186
184
|
new_text = file.read()
|
|
187
185
|
|
|
188
186
|
# Return a single edit that replaces the entire file.
|
|
@@ -206,14 +204,13 @@ class SQLMeshLanguageServer:
|
|
|
206
204
|
def hover(ls: LanguageServer, params: types.HoverParams) -> t.Optional[types.Hover]:
|
|
207
205
|
"""Provide hover information for an object."""
|
|
208
206
|
try:
|
|
209
|
-
|
|
207
|
+
uri = URI(params.text_document.uri)
|
|
208
|
+
self._ensure_context_for_document(uri)
|
|
210
209
|
document = ls.workspace.get_text_document(params.text_document.uri)
|
|
211
210
|
if self.lsp_context is None:
|
|
212
211
|
raise RuntimeError(f"No context found for document: {document.path}")
|
|
213
212
|
|
|
214
|
-
references = get_references(
|
|
215
|
-
self.lsp_context, params.text_document.uri, params.position
|
|
216
|
-
)
|
|
213
|
+
references = get_references(self.lsp_context, uri, params.position)
|
|
217
214
|
if not references:
|
|
218
215
|
return None
|
|
219
216
|
reference = references[0]
|
|
@@ -236,14 +233,13 @@ class SQLMeshLanguageServer:
|
|
|
236
233
|
) -> t.List[types.LocationLink]:
|
|
237
234
|
"""Jump to an object's definition."""
|
|
238
235
|
try:
|
|
239
|
-
|
|
236
|
+
uri = URI(params.text_document.uri)
|
|
237
|
+
self._ensure_context_for_document(uri)
|
|
240
238
|
document = ls.workspace.get_text_document(params.text_document.uri)
|
|
241
239
|
if self.lsp_context is None:
|
|
242
240
|
raise RuntimeError(f"No context found for document: {document.path}")
|
|
243
241
|
|
|
244
|
-
references = get_references(
|
|
245
|
-
self.lsp_context, params.text_document.uri, params.position
|
|
246
|
-
)
|
|
242
|
+
references = get_references(self.lsp_context, uri, params.position)
|
|
247
243
|
return [
|
|
248
244
|
types.LocationLink(
|
|
249
245
|
target_uri=reference.uri,
|
|
@@ -263,7 +259,7 @@ class SQLMeshLanguageServer:
|
|
|
263
259
|
ls.show_message(f"Error getting references: {e}", types.MessageType.Error)
|
|
264
260
|
return []
|
|
265
261
|
|
|
266
|
-
def _context_get_or_load(self, document_uri:
|
|
262
|
+
def _context_get_or_load(self, document_uri: URI) -> LSPContext:
|
|
267
263
|
if self.lsp_context is None:
|
|
268
264
|
self._ensure_context_for_document(document_uri)
|
|
269
265
|
if self.lsp_context is None:
|
|
@@ -272,7 +268,7 @@ class SQLMeshLanguageServer:
|
|
|
272
268
|
|
|
273
269
|
def _ensure_context_for_document(
|
|
274
270
|
self,
|
|
275
|
-
document_uri:
|
|
271
|
+
document_uri: URI,
|
|
276
272
|
) -> None:
|
|
277
273
|
"""
|
|
278
274
|
Ensure that a context exists for the given document if applicable by searching
|
|
@@ -285,7 +281,7 @@ class SQLMeshLanguageServer:
|
|
|
285
281
|
return
|
|
286
282
|
|
|
287
283
|
# No context yet: try to find config and load it
|
|
288
|
-
path =
|
|
284
|
+
path = document_uri.to_path()
|
|
289
285
|
if path.suffix not in (".sql", ".py"):
|
|
290
286
|
return
|
|
291
287
|
|
|
@@ -321,7 +317,8 @@ class SQLMeshLanguageServer:
|
|
|
321
317
|
|
|
322
318
|
# Get rule definition location for diagnostics link
|
|
323
319
|
rule_location = diagnostic.rule.get_definition_location()
|
|
324
|
-
|
|
320
|
+
rule_uri_wihout_extension = URI.from_path(rule_location.file_path)
|
|
321
|
+
rule_uri = f"{rule_uri_wihout_extension.value}#L{rule_location.start_line}"
|
|
325
322
|
|
|
326
323
|
# Use URI format to create a link for "related information"
|
|
327
324
|
return types.Diagnostic(
|
|
@@ -350,11 +347,9 @@ class SQLMeshLanguageServer:
|
|
|
350
347
|
return lsp_diagnostics
|
|
351
348
|
|
|
352
349
|
@staticmethod
|
|
353
|
-
def _uri_to_path(uri: str) ->
|
|
350
|
+
def _uri_to_path(uri: str) -> Path:
|
|
354
351
|
"""Convert a URI to a path."""
|
|
355
|
-
|
|
356
|
-
return Path(uri[7:]).resolve().as_posix()
|
|
357
|
-
return Path(uri).resolve().as_posix()
|
|
352
|
+
return URI(uri).to_path()
|
|
358
353
|
|
|
359
354
|
def start(self) -> None:
|
|
360
355
|
"""Start the server with I/O transport."""
|
sqlmesh/lsp/reference.py
CHANGED
|
@@ -5,7 +5,7 @@ from sqlmesh.core.dialect import normalize_model_name
|
|
|
5
5
|
from sqlmesh.core.model.definition import SqlModel
|
|
6
6
|
from sqlmesh.lsp.context import LSPContext, ModelTarget, AuditTarget
|
|
7
7
|
from sqlglot import exp
|
|
8
|
-
|
|
8
|
+
from sqlmesh.lsp.uri import URI
|
|
9
9
|
from sqlmesh.utils.pydantic import PydanticModel
|
|
10
10
|
|
|
11
11
|
|
|
@@ -51,7 +51,7 @@ def by_position(position: Position) -> t.Callable[[Reference], bool]:
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
def get_references(
|
|
54
|
-
lint_context: LSPContext, document_uri:
|
|
54
|
+
lint_context: LSPContext, document_uri: URI, position: Position
|
|
55
55
|
) -> t.List[Reference]:
|
|
56
56
|
"""
|
|
57
57
|
Get references at a specific position in a document.
|
|
@@ -72,7 +72,7 @@ def get_references(
|
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
def get_model_definitions_for_a_path(
|
|
75
|
-
lint_context: LSPContext, document_uri:
|
|
75
|
+
lint_context: LSPContext, document_uri: URI
|
|
76
76
|
) -> t.List[Reference]:
|
|
77
77
|
"""
|
|
78
78
|
Get the model references for a given path.
|
|
@@ -89,9 +89,8 @@ def get_model_definitions_for_a_path(
|
|
|
89
89
|
- Match to models that the model refers to
|
|
90
90
|
"""
|
|
91
91
|
# Ensure the path is a sql file
|
|
92
|
-
if
|
|
92
|
+
if document_uri.to_path().suffix != ".sql":
|
|
93
93
|
return []
|
|
94
|
-
|
|
95
94
|
# Get the file info from the context map
|
|
96
95
|
if document_uri not in lint_context.map:
|
|
97
96
|
return []
|
|
@@ -163,7 +162,7 @@ def get_model_definitions_for_a_path(
|
|
|
163
162
|
# Check whether the path exists
|
|
164
163
|
if not referenced_model_path.is_file():
|
|
165
164
|
continue
|
|
166
|
-
referenced_model_uri =
|
|
165
|
+
referenced_model_uri = URI.from_path(referenced_model_path)
|
|
167
166
|
|
|
168
167
|
# Extract metadata for positioning
|
|
169
168
|
table_meta = TokenPositionDetails.from_meta(table.this.meta)
|
|
@@ -180,7 +179,7 @@ def get_model_definitions_for_a_path(
|
|
|
180
179
|
|
|
181
180
|
references.append(
|
|
182
181
|
Reference(
|
|
183
|
-
uri=referenced_model_uri,
|
|
182
|
+
uri=referenced_model_uri.value,
|
|
184
183
|
range=Range(start=start_pos, end=end_pos),
|
|
185
184
|
description=referenced_model.description,
|
|
186
185
|
)
|
sqlmesh/lsp/uri.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from pygls.uris import from_fs_path, to_fs_path
|
|
3
|
+
import typing as t
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class URI:
|
|
7
|
+
"""
|
|
8
|
+
A URI is a unique identifier for a file used in the LSP.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
def __init__(self, uri: str):
|
|
12
|
+
self.value: str = uri
|
|
13
|
+
|
|
14
|
+
def __hash__(self) -> int:
|
|
15
|
+
return hash(self.value)
|
|
16
|
+
|
|
17
|
+
def __eq__(self, other: object) -> bool:
|
|
18
|
+
if not isinstance(other, URI):
|
|
19
|
+
return False
|
|
20
|
+
return self.value == other.value
|
|
21
|
+
|
|
22
|
+
def __repr__(self) -> str:
|
|
23
|
+
return f"URI({self.value})"
|
|
24
|
+
|
|
25
|
+
def to_path(self) -> Path:
|
|
26
|
+
p = to_fs_path(self.value)
|
|
27
|
+
return Path(p)
|
|
28
|
+
|
|
29
|
+
@staticmethod
|
|
30
|
+
def from_path(path: t.Union[str, Path]) -> "URI":
|
|
31
|
+
if isinstance(path, Path):
|
|
32
|
+
path = path.as_posix()
|
|
33
|
+
return URI(from_fs_path(path))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
sqlmesh/__init__.py,sha256=DRovDXI-9D9xeYDP7t8Fq7mI31S2btlN-LHPOK3y7PA,7240
|
|
2
|
-
sqlmesh/_version.py,sha256=
|
|
2
|
+
sqlmesh/_version.py,sha256=VnBoor5vh_u_iSKeKhHSRMWq8keDXn2j6mPIWCYt5T8,530
|
|
3
3
|
sqlmesh/magics.py,sha256=9oY1Uz8uwsuTtPRg9HTYDxnGiJ7-OVRCpmCgAhbKHUU,39431
|
|
4
4
|
sqlmesh/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
sqlmesh/cicd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -19,7 +19,7 @@ sqlmesh/core/dialect.py,sha256=fPTV517IOS0nWMxYznNNQnXkQkFFrPOSKe8ghsQ0o8A,49759
|
|
|
19
19
|
sqlmesh/core/environment.py,sha256=0TTQf4C4LXwf37fm-dfYv1qyG7vtZfQI5rizgm5g0j0,11442
|
|
20
20
|
sqlmesh/core/lineage.py,sha256=zjB0Zfamo2Fja2r5SSZPMbrEKTXr1WjozZPVqvxdybI,3143
|
|
21
21
|
sqlmesh/core/loader.py,sha256=97_nTWdNdEnz-LNK7AO-tkH9mo_lpe5vJIDGMvaL-bs,31979
|
|
22
|
-
sqlmesh/core/macros.py,sha256=
|
|
22
|
+
sqlmesh/core/macros.py,sha256=itPrfJt8jXTtg5BMfMHShXca9sBpgeNGdv5hBhCUh90,58851
|
|
23
23
|
sqlmesh/core/node.py,sha256=r4_1MRTPcU0MAlwZ5KzrykLT58B7dkKvHzPCsJmEKD8,14497
|
|
24
24
|
sqlmesh/core/notification_target.py,sha256=PPGoDrgbRKxr27vJEu03XqNTQLYTw0ZF_b0yAapxGeI,16158
|
|
25
25
|
sqlmesh/core/reference.py,sha256=k7OSkLqTjPR8WJjNeFj0xAJ297nZUMgb_iTVwKRRKjc,4875
|
|
@@ -156,11 +156,12 @@ sqlmesh/integrations/github/cicd/command.py,sha256=a48qtSeRM7RD3IeydJwHLAZBHRbmF
|
|
|
156
156
|
sqlmesh/integrations/github/cicd/config.py,sha256=qEy0mRfPYJw1pm68UK0v1_4kZBj5QodnpIsOZ8JjZro,1838
|
|
157
157
|
sqlmesh/integrations/github/cicd/controller.py,sha256=AiEMsRW4WSVxXP_7oQSIdzBzmYPxfYDgYeOYRk9sfJA,41388
|
|
158
158
|
sqlmesh/lsp/api.py,sha256=Ls7BjrPSovvOu6VU_eFR0_nHcbsQl020eJvGbdWi7s8,1957
|
|
159
|
-
sqlmesh/lsp/completions.py,sha256=
|
|
160
|
-
sqlmesh/lsp/context.py,sha256=
|
|
159
|
+
sqlmesh/lsp/completions.py,sha256=Jadpjxod_VYq2dCUuFhEVyI9odO13ZtyGmtd3YSOuaM,3511
|
|
160
|
+
sqlmesh/lsp/context.py,sha256=N_sd9uuuDi40ABexjT_r9QuIrRBmYPfJltqaGGDekmM,1473
|
|
161
161
|
sqlmesh/lsp/custom.py,sha256=GvNAiW7imPI8xmIx3qLWN5FljGPHFJKh0N5b6aZnwRo,489
|
|
162
|
-
sqlmesh/lsp/main.py,sha256=
|
|
163
|
-
sqlmesh/lsp/reference.py,sha256=
|
|
162
|
+
sqlmesh/lsp/main.py,sha256=MmL5UuNkft1Yu4Fk_ILEkUJXctsfQ0kBvNz6eHpmgIY,15981
|
|
163
|
+
sqlmesh/lsp/reference.py,sha256=YsXAPkxo_qMC_rDimpJTn4ri0bo9H6RIAyNkD9oWgY4,8166
|
|
164
|
+
sqlmesh/lsp/uri.py,sha256=mvSLbZGmMTHPpliThOtVWiFcHnfJzp1w39q9l-xD2SI,802
|
|
164
165
|
sqlmesh/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
165
166
|
sqlmesh/migrations/v0001_init.py,sha256=h8FwMYJj9_O8yGpk12guaSaGwX5A3we2GiKeHrXi15o,2048
|
|
166
167
|
sqlmesh/migrations/v0002_remove_identify.py,sha256=ZeHuodZcQzRRZX0B0Y7SSkK3qqlDuz316kmvzojeyoU,113
|
|
@@ -266,7 +267,7 @@ sqlmesh/utils/pandas.py,sha256=WmNlTLuv_qLelrcTnwb05QMaW53AYM6dpOW0o3dz6qM,2051
|
|
|
266
267
|
sqlmesh/utils/pydantic.py,sha256=ioaAzYF42PutEJRyAS11-AHguiCG3yWI6VRcTVa2G-g,10470
|
|
267
268
|
sqlmesh/utils/rich.py,sha256=xNZyPCqEc4TAlJlsEthg-5eYUWpaizz0QjBzO7a1Yv4,1509
|
|
268
269
|
sqlmesh/utils/yaml.py,sha256=np-WVcwmwsKghCgAj1OBBMsK1SXSRn4wR-H37cGiFr8,2282
|
|
269
|
-
sqlmesh-0.183.1.
|
|
270
|
+
sqlmesh-0.183.1.dev14.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
|
|
270
271
|
web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
271
272
|
web/client/dist/index.html,sha256=nPqIDCJmonOaEAp4hhwrwgPdwt_F-5zzw-WW1kJqq3I,5472
|
|
272
273
|
web/client/dist/assets/Audits-DiRd7NXk.js,sha256=Q5dIFqsHps-vVYD8037NpTPW_1juQgn_Ov45smEm7Y8,1041
|
|
@@ -384,8 +385,8 @@ web/server/api/endpoints/models.py,sha256=SzS5bshzdXyM6hb948sZ_3k-xhpGCHkxkb7pHz
|
|
|
384
385
|
web/server/api/endpoints/modules.py,sha256=8hqqgonGay_mJmpCw0IdbjsPhWlQH2VLdKAqha-myac,468
|
|
385
386
|
web/server/api/endpoints/plan.py,sha256=OYuQ_4dgbhG9ibTcX1a8mvYgH3ANxw9Fhbb4wg6QWqc,9222
|
|
386
387
|
web/server/api/endpoints/table_diff.py,sha256=Wd5YxeKbZB7AkrDvqFgvV9ZQlnKYOF1n5W_w2EHE_Zw,2085
|
|
387
|
-
sqlmesh-0.183.1.
|
|
388
|
-
sqlmesh-0.183.1.
|
|
389
|
-
sqlmesh-0.183.1.
|
|
390
|
-
sqlmesh-0.183.1.
|
|
391
|
-
sqlmesh-0.183.1.
|
|
388
|
+
sqlmesh-0.183.1.dev14.dist-info/METADATA,sha256=0IaizQKxnmu58n7prmzXW96VJ8ic861z_V9fVqvQj00,25253
|
|
389
|
+
sqlmesh-0.183.1.dev14.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
390
|
+
sqlmesh-0.183.1.dev14.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
|
|
391
|
+
sqlmesh-0.183.1.dev14.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
|
|
392
|
+
sqlmesh-0.183.1.dev14.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|