sqlmesh 0.189.3.dev24__py3-none-any.whl → 0.189.3.dev26__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.189.3.dev24'
21
- __version_tuple__ = version_tuple = (0, 189, 3, 'dev24')
20
+ __version__ = version = '0.189.3.dev26'
21
+ __version_tuple__ = version_tuple = (0, 189, 3, 'dev26')
@@ -5,6 +5,7 @@ import typing as t
5
5
  from pathlib import Path
6
6
 
7
7
  from astor import to_source
8
+ from difflib import get_close_matches
8
9
  from sqlglot import exp
9
10
  from sqlglot.helper import ensure_list
10
11
 
@@ -267,13 +268,33 @@ def validate_extra_and_required_fields(
267
268
  ) -> None:
268
269
  missing_required_fields = klass.missing_required_fields(provided_fields)
269
270
  if missing_required_fields:
271
+ field_names = "'" + "', '".join(missing_required_fields) + "'"
270
272
  raise_config_error(
271
- f"Missing required fields {missing_required_fields} in the {entity_name}"
273
+ f"Please add required field{'s' if len(missing_required_fields) > 1 else ''} {field_names} to the {entity_name}."
272
274
  )
273
275
 
274
276
  extra_fields = klass.extra_fields(provided_fields)
275
277
  if extra_fields:
276
- raise_config_error(f"Invalid extra fields {extra_fields} in the {entity_name}")
278
+ extra_field_names = "'" + "', '".join(extra_fields) + "'"
279
+
280
+ all_fields = klass.all_fields()
281
+ close_matches = {}
282
+ for field in extra_fields:
283
+ matches = get_close_matches(field, all_fields, n=1)
284
+ if matches:
285
+ close_matches[field] = matches[0]
286
+
287
+ if len(close_matches) == 1:
288
+ similar_msg = ". Did you mean " + "'" + "', '".join(close_matches.values()) + "'?"
289
+ else:
290
+ similar = [
291
+ f"- {field}: Did you mean '{match}'?" for field, match in close_matches.items()
292
+ ]
293
+ similar_msg = "\n\n " + "\n ".join(similar) if similar else ""
294
+
295
+ raise_config_error(
296
+ f"Invalid field name{'s' if len(extra_fields) > 1 else ''} present in the {entity_name}: {extra_field_names}{similar_msg}"
297
+ )
277
298
 
278
299
 
279
300
  def single_value_or_tuple(values: t.Sequence) -> exp.Identifier | exp.Tuple:
@@ -2156,7 +2156,10 @@ Learn more at https://sqlmesh.readthedocs.io/en/stable/concepts/models/overview
2156
2156
  name = get_model_name(path)
2157
2157
 
2158
2158
  if not name:
2159
- raise_config_error("Model must have a name", path)
2159
+ raise_config_error(
2160
+ "Please add the required 'name' field to the MODEL block at the top of the file.\n\n"
2161
+ + "Learn more at https://sqlmesh.readthedocs.io/en/stable/concepts/models/overview"
2162
+ )
2160
2163
  if "default_catalog" in meta_fields:
2161
2164
  raise_config_error(
2162
2165
  "`default_catalog` cannot be set on a per-model basis. It must be set at the connection level.",
@@ -2400,7 +2403,7 @@ def _create_model(
2400
2403
  **kwargs: t.Any,
2401
2404
  ) -> Model:
2402
2405
  validate_extra_and_required_fields(
2403
- klass, {"name", *kwargs} - {"grain", "table_properties"}, "model definition"
2406
+ klass, {"name", *kwargs} - {"grain", "table_properties"}, "MODEL block"
2404
2407
  )
2405
2408
 
2406
2409
  for prop in PROPERTIES:
@@ -1015,7 +1015,9 @@ def create_model_kind(v: t.Any, dialect: str, defaults: t.Dict[str, t.Any]) -> M
1015
1015
  actual_kind_type, _ = custom_materialization
1016
1016
  return actual_kind_type(**props)
1017
1017
 
1018
- validate_extra_and_required_fields(kind_type, set(props), f"model kind '{name}'")
1018
+ validate_extra_and_required_fields(
1019
+ kind_type, set(props), f"MODEL block 'kind {name}' field"
1020
+ )
1019
1021
  return kind_type(**props)
1020
1022
 
1021
1023
  name = (v.name if isinstance(v, exp.Expression) else str(v)).upper()
sqlmesh/lsp/main.py CHANGED
@@ -88,6 +88,8 @@ class SQLMeshLanguageServer:
88
88
  def _create_lsp_context(self, paths: t.List[Path]) -> t.Optional[LSPContext]:
89
89
  """Create a new LSPContext instance using the configured context class.
90
90
 
91
+ On success, sets self.lsp_context and returns the created context.
92
+
91
93
  Args:
92
94
  paths: List of paths to pass to the context constructor
93
95
 
@@ -96,7 +98,9 @@ class SQLMeshLanguageServer:
96
98
  """
97
99
  try:
98
100
  context = self.context_class(paths=paths)
99
- return LSPContext(context)
101
+ lsp_context = LSPContext(context)
102
+ self.lsp_context = lsp_context
103
+ return lsp_context
100
104
  except Exception as e:
101
105
  self.server.log_trace(f"Error creating context: {e}")
102
106
  return None
@@ -132,9 +136,7 @@ class SQLMeshLanguageServer:
132
136
  for ext in ("py", "yml", "yaml"):
133
137
  config_path = folder_path / f"config.{ext}"
134
138
  if config_path.exists():
135
- lsp_context = self._create_lsp_context([folder_path])
136
- if lsp_context:
137
- self.lsp_context = lsp_context
139
+ if self._create_lsp_context([folder_path]):
138
140
  loaded_sqlmesh_message(ls, folder_path)
139
141
  return # Exit after successfully loading any config
140
142
  except Exception as e:
@@ -299,9 +301,7 @@ class SQLMeshLanguageServer:
299
301
 
300
302
  # Reload the entire context and create a new LSPContext
301
303
  if self.lsp_context is not None:
302
- new_lsp_context = self._create_lsp_context(list(self.lsp_context.context.configs))
303
- if new_lsp_context:
304
- self.lsp_context = new_lsp_context
304
+ if self._create_lsp_context(list(self.lsp_context.context.configs)):
305
305
  return
306
306
 
307
307
  context = self._context_get_or_load(uri)
@@ -672,9 +672,7 @@ class SQLMeshLanguageServer:
672
672
  for ext in ("py", "yml", "yaml"):
673
673
  config_path = folder_uri / f"config.{ext}"
674
674
  if config_path.exists():
675
- lsp_context = self._create_lsp_context([folder_uri])
676
- if lsp_context:
677
- self.lsp_context = lsp_context
675
+ if self._create_lsp_context([folder_uri]):
678
676
  loaded_sqlmesh_message(self.server, folder_uri)
679
677
  return
680
678
 
@@ -683,9 +681,7 @@ class SQLMeshLanguageServer:
683
681
  for ext in ("py", "yml", "yaml"):
684
682
  config_path = workspace_folder / f"config.{ext}"
685
683
  if config_path.exists():
686
- lsp_context = self._create_lsp_context([workspace_folder])
687
- if lsp_context:
688
- self.lsp_context = lsp_context
684
+ if self._create_lsp_context([workspace_folder]):
689
685
  loaded_sqlmesh_message(self.server, workspace_folder)
690
686
  return
691
687
 
@@ -714,9 +710,7 @@ class SQLMeshLanguageServer:
714
710
  for ext in ("py", "yml", "yaml"):
715
711
  config_path = path / f"config.{ext}"
716
712
  if config_path.exists():
717
- lsp_context = self._create_lsp_context([path])
718
- if lsp_context:
719
- self.lsp_context = lsp_context
713
+ if self._create_lsp_context([path]):
720
714
  loaded = True
721
715
  # Re-check context for the document now that it's loaded
722
716
  return self._ensure_context_for_document(document_uri)
@@ -728,9 +722,7 @@ class SQLMeshLanguageServer:
728
722
  for ext in ("py", "yml", "yaml"):
729
723
  config_path = workspace_folder / f"config.{ext}"
730
724
  if config_path.exists():
731
- lsp_context = self._create_lsp_context([workspace_folder])
732
- if lsp_context:
733
- self.lsp_context = lsp_context
725
+ if self._create_lsp_context([workspace_folder]):
734
726
  loaded_sqlmesh_message(self.server, workspace_folder)
735
727
  return
736
728
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlmesh
3
- Version: 0.189.3.dev24
3
+ Version: 0.189.3.dev26
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=QjwaamJIdW7voXoS880yAx7tHm-Im4_mqGA-XJgafos,7631
2
- sqlmesh/_version.py,sha256=UVSc5rHw9Ijtrxery7cxNfYMoA7Ntm8dKrodV0E-RaI,530
2
+ sqlmesh/_version.py,sha256=Tv9ovWxOSpdbHXuF6XXZZB7EB3Hl6WhHiNMGv71Eeq4,530
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
@@ -86,10 +86,10 @@ sqlmesh/core/metric/definition.py,sha256=Yd5aVgsZCDPJ43aGP7WqtzZOuuSUtB8uJGVA6Jw
86
86
  sqlmesh/core/metric/rewriter.py,sha256=GiSTHfn2kinqCfNPYgZPRk93JFLzVaaejHtHDQ0yXZI,7326
87
87
  sqlmesh/core/model/__init__.py,sha256=C8GRZ53xuXEA9hQv3BQS9pNNyd9rZ06R_B96UYGhDu4,1644
88
88
  sqlmesh/core/model/cache.py,sha256=csun0RJguHzKX6-qITcOs4fVP4f8_Ts8qiUVV4sHY6Q,7869
89
- sqlmesh/core/model/common.py,sha256=vbcXFhWE22-FeKYAVIlKWvTb-wkeC8XISjU_TIlak0c,16252
89
+ sqlmesh/core/model/common.py,sha256=-AC57zytc-AGtSpk6lDcnpw-7g0FXV6aW8OfiyTqcBM,17151
90
90
  sqlmesh/core/model/decorator.py,sha256=v_sVudNROGrtj5cZ3vgcOFnwPdzwoUGY6REAkQpIMQc,8927
91
- sqlmesh/core/model/definition.py,sha256=G2FHqCsJaDOzRcJCdTlfe6Ygl55rh9RAEXC1Zaka8uA,108470
92
- sqlmesh/core/model/kind.py,sha256=i6_AMBarXPGPoMdF9kzBkyqS9tu__a2339-BoX7TgCM,36010
91
+ sqlmesh/core/model/definition.py,sha256=052_23d3oAfzk62DPzjfyhHkwqUtf_ZY5Hm03u7pV5U,108638
92
+ sqlmesh/core/model/kind.py,sha256=ZyjfGuXO5pSGJfAZC91-RR4Kc2mwL6g3LO0tgew9Ldk,36044
93
93
  sqlmesh/core/model/meta.py,sha256=D9InI9M2-IXeb34vkXNQSLALL8xVXjZ_LXwI-Tqxm7I,21197
94
94
  sqlmesh/core/model/schema.py,sha256=OClbAeA8LpW-IiSiLT_TlDWkEqmIIvSk0GXq8SWI-GQ,3443
95
95
  sqlmesh/core/model/seed.py,sha256=a0M-1zY1gOkN5ph2GQyataEdBSCtq50YjeFk2LyvInI,5058
@@ -165,7 +165,7 @@ sqlmesh/lsp/custom.py,sha256=40ekRrcsJ-lsF4-uPs4mo8CFegTWK_zKzi4am_NO9oo,2196
165
165
  sqlmesh/lsp/description.py,sha256=4QIGC9ix8IzmWF6DVUNhY4m1Crk3sNQA6hZ1RbyqU78,827
166
166
  sqlmesh/lsp/helpers.py,sha256=igzUgeYAO3LUZFr3qN4l9hzztOy66lRubX93KtCMduY,654
167
167
  sqlmesh/lsp/hints.py,sha256=j-blccBUil94yRoDjWfkSM0HqMmsKD6hP2TaWdWWVk4,3734
168
- sqlmesh/lsp/main.py,sha256=klOs4Gn0pLF161jWJaosXdN3a9GcPSrEZHmJkrsO7k4,35538
168
+ sqlmesh/lsp/main.py,sha256=-rthyo8sdcUHVEq0PY8DuvhydIldnY0vU3A5pckKjEE,35061
169
169
  sqlmesh/lsp/reference.py,sha256=2rAYfwrKRfxlYA3psTDLacxYWvuFaouMyS7plOSYHiQ,23883
170
170
  sqlmesh/lsp/uri.py,sha256=mvSLbZGmMTHPpliThOtVWiFcHnfJzp1w39q9l-xD2SI,802
171
171
  sqlmesh/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -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.189.3.dev24.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
278
+ sqlmesh-0.189.3.dev26.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.189.3.dev24.dist-info/METADATA,sha256=0PizIioIzUPUhpgbzjlzI6iNfv1y0tG8ikX1qh8MFf0,26541
397
- sqlmesh-0.189.3.dev24.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
398
- sqlmesh-0.189.3.dev24.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
399
- sqlmesh-0.189.3.dev24.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
400
- sqlmesh-0.189.3.dev24.dist-info/RECORD,,
396
+ sqlmesh-0.189.3.dev26.dist-info/METADATA,sha256=Z16WyPmLttfdZese8uvDUgK8MupC0mBXFxsM8v7GTOY,26541
397
+ sqlmesh-0.189.3.dev26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
398
+ sqlmesh-0.189.3.dev26.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
399
+ sqlmesh-0.189.3.dev26.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
400
+ sqlmesh-0.189.3.dev26.dist-info/RECORD,,