sqlmesh 0.181.1.dev3__py3-none-any.whl → 0.181.1.dev5__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 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.181.1.dev3'
21
- __version_tuple__ = version_tuple = (0, 181, 1, 'dev3')
20
+ __version__ = version = '0.181.1.dev5'
21
+ __version_tuple__ = version_tuple = (0, 181, 1, 'dev5')
@@ -105,6 +105,7 @@ class SparkEngineAdapter(
105
105
  exp.DataType.Type.BINARY: spark_types.BinaryType,
106
106
  exp.DataType.Type.BOOLEAN: spark_types.BooleanType,
107
107
  exp.DataType.Type.DATE: spark_types.DateType,
108
+ exp.DataType.Type.TIMESTAMPNTZ: spark_types.TimestampNTZType,
108
109
  exp.DataType.Type.DATETIME: spark_types.TimestampNTZType,
109
110
  exp.DataType.Type.TIMESTAMPLTZ: spark_types.TimestampType,
110
111
  exp.DataType.Type.TIMESTAMP: spark_types.TimestampType,
sqlmesh/lsp/main.py CHANGED
@@ -15,8 +15,7 @@ from sqlmesh.lsp.completions import get_sql_completions
15
15
  from sqlmesh.lsp.context import LSPContext, ModelTarget
16
16
  from sqlmesh.lsp.custom import ALL_MODELS_FEATURE, AllModelsRequest, AllModelsResponse
17
17
  from sqlmesh.lsp.reference import (
18
- get_model_definitions_for_a_path,
19
- filter_references_by_position,
18
+ get_references,
20
19
  )
21
20
 
22
21
 
@@ -178,6 +177,34 @@ class SQLMeshLanguageServer:
178
177
  ls.show_message(f"Error formatting SQL: {e}", types.MessageType.Error)
179
178
  return []
180
179
 
180
+ @self.server.feature(types.TEXT_DOCUMENT_HOVER)
181
+ def hover(ls: LanguageServer, params: types.HoverParams) -> t.Optional[types.Hover]:
182
+ """Provide hover information for an object."""
183
+ try:
184
+ self._ensure_context_for_document(params.text_document.uri)
185
+ document = ls.workspace.get_document(params.text_document.uri)
186
+ if self.lsp_context is None:
187
+ raise RuntimeError(f"No context found for document: {document.path}")
188
+
189
+ references = get_references(
190
+ self.lsp_context, params.text_document.uri, params.position
191
+ )
192
+ if not references:
193
+ return None
194
+ reference = references[0]
195
+ if not reference.description:
196
+ return None
197
+ return types.Hover(
198
+ contents=types.MarkupContent(
199
+ kind=types.MarkupKind.Markdown, value=reference.description
200
+ ),
201
+ range=reference.range,
202
+ )
203
+
204
+ except Exception as e:
205
+ ls.show_message(f"Error getting hover information: {e}", types.MessageType.Error)
206
+ return None
207
+
181
208
  @self.server.feature(types.TEXT_DOCUMENT_DEFINITION)
182
209
  def goto_definition(
183
210
  ls: LanguageServer, params: types.DefinitionParams
@@ -189,10 +216,9 @@ class SQLMeshLanguageServer:
189
216
  if self.lsp_context is None:
190
217
  raise RuntimeError(f"No context found for document: {document.path}")
191
218
 
192
- references = get_model_definitions_for_a_path(
193
- self.lsp_context, params.text_document.uri
219
+ references = get_references(
220
+ self.lsp_context, params.text_document.uri, params.position
194
221
  )
195
- filtered_references = filter_references_by_position(references, params.position)
196
222
  return [
197
223
  types.LocationLink(
198
224
  target_uri=reference.uri,
@@ -206,9 +232,8 @@ class SQLMeshLanguageServer:
206
232
  ),
207
233
  origin_selection_range=reference.range,
208
234
  )
209
- for reference in filtered_references
235
+ for reference in references
210
236
  ]
211
-
212
237
  except Exception as e:
213
238
  ls.show_message(f"Error getting references: {e}", types.MessageType.Error)
214
239
  return []
sqlmesh/lsp/reference.py CHANGED
@@ -10,40 +10,64 @@ from sqlmesh.utils.pydantic import PydanticModel
10
10
 
11
11
 
12
12
  class Reference(PydanticModel):
13
+ """
14
+ A reference to a model.
15
+
16
+ Attributes:
17
+ range: The range of the reference in the source file
18
+ uri: The uri of the referenced model
19
+ description: The description of the referenced model
20
+ """
21
+
13
22
  range: Range
14
23
  uri: str
24
+ description: t.Optional[str] = None
15
25
 
16
26
 
17
- def filter_references_by_position(
18
- references: t.List[Reference], position: Position
19
- ) -> t.List[Reference]:
27
+ def by_position(position: Position) -> t.Callable[[Reference], bool]:
20
28
  """
21
- Filter references to only include those that contain the given position.
29
+ Filter reference to only filter references that contain the given position.
22
30
 
23
31
  Args:
24
- references: List of Reference objects
25
32
  position: The cursor position to check
26
33
 
27
34
  Returns:
28
- List of Reference objects that contain the position
35
+ A function that returns True if the reference contains the position, False otherwise
29
36
  """
30
- filtered_references = []
31
-
32
- for reference in references:
33
- # Check if position is within the reference range
34
- range_start = reference.range.start
35
- range_end = reference.range.end
36
37
 
37
- # Position is within range if it's after or at start and before or at end
38
- if (
39
- range_start.line < position.line
40
- or (range_start.line == position.line and range_start.character <= position.character)
38
+ def contains_position(r: Reference) -> bool:
39
+ return (
40
+ r.range.start.line < position.line
41
+ or (
42
+ r.range.start.line == position.line
43
+ and r.range.start.character <= position.character
44
+ )
41
45
  ) and (
42
- range_end.line > position.line
43
- or (range_end.line == position.line and range_end.character >= position.character)
44
- ):
45
- filtered_references.append(reference)
46
+ r.range.end.line > position.line
47
+ or (r.range.end.line == position.line and r.range.end.character >= position.character)
48
+ )
49
+
50
+ return contains_position
46
51
 
52
+
53
+ def get_references(
54
+ lint_context: LSPContext, document_uri: str, position: Position
55
+ ) -> t.List[Reference]:
56
+ """
57
+ Get references at a specific position in a document.
58
+
59
+ Used for hover information.
60
+
61
+ Args:
62
+ lint_context: The LSP context
63
+ document_uri: The URI of the document
64
+ position: The position to check for references
65
+
66
+ Returns:
67
+ A list of references at the given position
68
+ """
69
+ references = get_model_definitions_for_a_path(lint_context, document_uri)
70
+ filtered_references = list(filter(by_position(position), references))
47
71
  return filtered_references
48
72
 
49
73
 
@@ -154,7 +178,11 @@ def get_model_definitions_for_a_path(
154
178
  start_pos = catalog_or_db_range.start
155
179
 
156
180
  references.append(
157
- Reference(uri=referenced_model_uri, range=Range(start=start_pos, end=end_pos))
181
+ Reference(
182
+ uri=referenced_model_uri,
183
+ range=Range(start=start_pos, end=end_pos),
184
+ description=referenced_model.description,
185
+ )
158
186
  )
159
187
 
160
188
  return references
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlmesh
3
- Version: 0.181.1.dev3
3
+ Version: 0.181.1.dev5
4
4
  Summary: Next-generation data transformation framework
5
5
  Author-email: "TobikoData Inc." <engineering@tobikodata.com>
6
6
  License: Apache License
@@ -1,5 +1,5 @@
1
1
  sqlmesh/__init__.py,sha256=uPXld_xTZ2NTruSfVJ_vR_w-uAxR3T-gMXAb-EphTe8,7167
2
- sqlmesh/_version.py,sha256=UmyRudwujStwkg8fCiTZPPqrQz-uxV47SXbuZcuhJOI,528
2
+ sqlmesh/_version.py,sha256=V8bpUP0oeVbvVW84PK7nOlJ-2zYX3cciqF_2AM_17dM,528
3
3
  sqlmesh/magics.py,sha256=7BU9ec9zE4tjvZ3hdEqwFX2VVV-CI0h06TGZo_Ssi8M,39070
4
4
  sqlmesh/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  sqlmesh/cicd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -73,7 +73,7 @@ sqlmesh/core/engine_adapter/redshift.py,sha256=_rZWv4rchDAzB6m6idoV1NLHFBKK_gM4n
73
73
  sqlmesh/core/engine_adapter/risingwave.py,sha256=NXXuiPfbB5ZSp7igMqZpaX2c-5TYreOlIouPU7iCVJ8,936
74
74
  sqlmesh/core/engine_adapter/shared.py,sha256=NyF2osSJDWPp7KlJUBR4GZcS_cJFr4daUPvhGyp4XcQ,12909
75
75
  sqlmesh/core/engine_adapter/snowflake.py,sha256=LKiQq43JNukLcDq5OnKALpiZ0xjFK7fVJYJvlXHAWxo,23361
76
- sqlmesh/core/engine_adapter/spark.py,sha256=0wTMRs3emclwSThp05qvWPobu-Zor9Oc4pDCGMwQlZg,22310
76
+ sqlmesh/core/engine_adapter/spark.py,sha256=VOXStkBBZIzebPo_ivdQFvZtRMiWJHHo7h118Lh5Yt8,22384
77
77
  sqlmesh/core/engine_adapter/trino.py,sha256=pZ2E1owyC6DPmkU3RkibR3CIE1gE-8fNd016YHh52II,14915
78
78
  sqlmesh/core/linter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
79
79
  sqlmesh/core/linter/definition.py,sha256=UL05OjFBfoLSYGWXNf4zjZYzIKr-OyFIMIcIh7RhR8s,5237
@@ -158,8 +158,8 @@ sqlmesh/integrations/github/cicd/controller.py,sha256=AiEMsRW4WSVxXP_7oQSIdzBzmY
158
158
  sqlmesh/lsp/completions.py,sha256=ScW0H9couhfW6QckEX2djVYTClRPXpT2Hdcg1qLfUUY,3479
159
159
  sqlmesh/lsp/context.py,sha256=vUpbWYjKYuwDvU3zkzhAgw9An-TeVYe_5KTk-ec_UwM,1569
160
160
  sqlmesh/lsp/custom.py,sha256=GvNAiW7imPI8xmIx3qLWN5FljGPHFJKh0N5b6aZnwRo,489
161
- sqlmesh/lsp/main.py,sha256=Xt7cwoocmmefsFO4UvBPlIsiXWs7YEGRp6jgT2tKn60,13672
162
- sqlmesh/lsp/reference.py,sha256=veet4JZpVmUOIMiRPOvMtzu4DQEPT9Vk9c2bWAsFuQA,7366
161
+ sqlmesh/lsp/main.py,sha256=OftpChYMN1_sNeaLM5wxK5umiHCiOwPNnFFpaG6sAu8,14774
162
+ sqlmesh/lsp/reference.py,sha256=2rANWlO4Z4Pt9KuUhZSWoaTdPfmeNVDgi7iiXFTb7zY,8076
163
163
  sqlmesh/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
164
164
  sqlmesh/migrations/v0001_init.py,sha256=h8FwMYJj9_O8yGpk12guaSaGwX5A3we2GiKeHrXi15o,2048
165
165
  sqlmesh/migrations/v0002_remove_identify.py,sha256=ZeHuodZcQzRRZX0B0Y7SSkK3qqlDuz316kmvzojeyoU,113
@@ -265,7 +265,7 @@ sqlmesh/utils/pandas.py,sha256=j_tYhuPcWpzuPceZZ6IhdTVbmxYyGJW7l4FHr4bQqjM,1824
265
265
  sqlmesh/utils/pydantic.py,sha256=ioaAzYF42PutEJRyAS11-AHguiCG3yWI6VRcTVa2G-g,10470
266
266
  sqlmesh/utils/rich.py,sha256=xNZyPCqEc4TAlJlsEthg-5eYUWpaizz0QjBzO7a1Yv4,1509
267
267
  sqlmesh/utils/yaml.py,sha256=np-WVcwmwsKghCgAj1OBBMsK1SXSRn4wR-H37cGiFr8,2282
268
- sqlmesh-0.181.1.dev3.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
268
+ sqlmesh-0.181.1.dev5.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
269
269
  web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
270
270
  web/client/dist/index.html,sha256=cQRIlDgkl6OgeWuHI9hM8bJhKUE9-Ji2NpQa2hlgNM8,5472
271
271
  web/client/dist/assets/Audits-4U9LnWyN.js,sha256=reXu-sKJ76kiaAZIGkCPvgO68Km9tj1PN_9mx6X6WAY,997
@@ -382,8 +382,8 @@ web/server/api/endpoints/models.py,sha256=SzS5bshzdXyM6hb948sZ_3k-xhpGCHkxkb7pHz
382
382
  web/server/api/endpoints/modules.py,sha256=8hqqgonGay_mJmpCw0IdbjsPhWlQH2VLdKAqha-myac,468
383
383
  web/server/api/endpoints/plan.py,sha256=OYuQ_4dgbhG9ibTcX1a8mvYgH3ANxw9Fhbb4wg6QWqc,9222
384
384
  web/server/api/endpoints/table_diff.py,sha256=Wd5YxeKbZB7AkrDvqFgvV9ZQlnKYOF1n5W_w2EHE_Zw,2085
385
- sqlmesh-0.181.1.dev3.dist-info/METADATA,sha256=l36AoWMTkn-01VKUdqHoDQDnrgOqRuaB8_RQ6WXFDhE,25307
386
- sqlmesh-0.181.1.dev3.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
387
- sqlmesh-0.181.1.dev3.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
388
- sqlmesh-0.181.1.dev3.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
389
- sqlmesh-0.181.1.dev3.dist-info/RECORD,,
385
+ sqlmesh-0.181.1.dev5.dist-info/METADATA,sha256=4zzJW4BjZ10b_SHIa919RjR9Auj8Wfi-V2P402pQ-0c,25307
386
+ sqlmesh-0.181.1.dev5.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
387
+ sqlmesh-0.181.1.dev5.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
388
+ sqlmesh-0.181.1.dev5.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
389
+ sqlmesh-0.181.1.dev5.dist-info/RECORD,,