sqlmesh 0.194.2.dev9__py3-none-any.whl → 0.194.2.dev11__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.194.2.dev9'
21
- __version_tuple__ = version_tuple = (0, 194, 2, 'dev9')
20
+ __version__ = version = '0.194.2.dev11'
21
+ __version_tuple__ = version_tuple = (0, 194, 2, 'dev11')
sqlmesh/cli/main.py CHANGED
@@ -191,6 +191,7 @@ def init(
191
191
  help="The SQL dialect to render the query as.",
192
192
  )
193
193
  @click.option("--no-format", is_flag=True, help="Disable fancy formatting of the query.")
194
+ @opt.format_options
194
195
  @click.pass_context
195
196
  @error_handler
196
197
  @cli_analytics
@@ -203,6 +204,7 @@ def render(
203
204
  expand: t.Optional[t.Union[bool, t.Iterable[str]]] = None,
204
205
  dialect: t.Optional[str] = None,
205
206
  no_format: bool = False,
207
+ **format_kwargs: t.Any,
206
208
  ) -> None:
207
209
  """Render a model's query, optionally expanding referenced models."""
208
210
  rendered = ctx.obj.render(
@@ -213,7 +215,17 @@ def render(
213
215
  expand=expand,
214
216
  )
215
217
 
216
- sql = rendered.sql(pretty=True, dialect=ctx.obj.config.dialect if dialect is None else dialect)
218
+ format_config = ctx.obj.config_for_node(model).format
219
+ format_kwargs = {
220
+ **format_config.generator_options,
221
+ **{k: v for k, v in format_kwargs.items() if v is not None},
222
+ }
223
+
224
+ sql = rendered.sql(
225
+ pretty=True,
226
+ dialect=ctx.obj.config.dialect if dialect is None else dialect,
227
+ **format_kwargs,
228
+ )
217
229
  if no_format:
218
230
  print(sql)
219
231
  else:
@@ -264,55 +276,23 @@ def evaluate(
264
276
  help="Transpile project models to the specified dialect.",
265
277
  )
266
278
  @click.option(
267
- "--append-newline",
268
- is_flag=True,
269
- help="Include a newline at the end of each file.",
270
- default=None,
271
- )
272
- @click.option(
273
- "--no-rewrite-casts",
274
- is_flag=True,
275
- help="Preserve the existing casts, without rewriting them to use the :: syntax.",
276
- default=None,
277
- )
278
- @click.option(
279
- "--normalize",
279
+ "--check",
280
280
  is_flag=True,
281
- help="Whether or not to normalize identifiers to lowercase.",
281
+ help="Whether or not to check formatting (but not actually format anything).",
282
282
  default=None,
283
283
  )
284
284
  @click.option(
285
- "--pad",
286
- type=int,
287
- help="Determines the pad size in a formatted string.",
288
- )
289
- @click.option(
290
- "--indent",
291
- type=int,
292
- help="Determines the indentation size in a formatted string.",
293
- )
294
- @click.option(
295
- "--normalize-functions",
296
- type=str,
297
- help="Whether or not to normalize all function names. Possible values are: 'upper', 'lower'",
298
- )
299
- @click.option(
300
- "--leading-comma",
285
+ "--rewrite-casts/--no-rewrite-casts",
301
286
  is_flag=True,
302
- help="Determines whether or not the comma is leading or trailing in select expressions. Default is trailing.",
287
+ help="Rewrite casts to use the :: syntax.",
303
288
  default=None,
304
289
  )
305
290
  @click.option(
306
- "--max-text-width",
307
- type=int,
308
- help="The max number of characters in a segment before creating new lines in pretty mode.",
309
- )
310
- @click.option(
311
- "--check",
291
+ "--append-newline",
312
292
  is_flag=True,
313
- help="Whether or not to check formatting (but not actually format anything).",
314
- default=None,
293
+ help="Include a newline at the end of each file.",
315
294
  )
295
+ @opt.format_options
316
296
  @click.pass_context
317
297
  @error_handler
318
298
  @cli_analytics
@@ -320,9 +300,6 @@ def format(
320
300
  ctx: click.Context, paths: t.Optional[t.Tuple[str, ...]] = None, **kwargs: t.Any
321
301
  ) -> None:
322
302
  """Format all SQL models and audits."""
323
- if kwargs.pop("no_rewrite_casts", None):
324
- kwargs["rewrite_casts"] = False
325
-
326
303
  if not ctx.obj.format(**{k: v for k, v in kwargs.items() if v is not None}, paths=paths):
327
304
  ctx.exit(1)
328
305
 
sqlmesh/cli/options.py CHANGED
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import os
4
+ import typing as t
4
5
 
5
6
  import click
6
7
 
@@ -54,3 +55,38 @@ verbose = click.option(
54
55
  count=True,
55
56
  help="Verbose output. Use -vv for very verbose output.",
56
57
  )
58
+
59
+
60
+ def format_options(func: t.Callable) -> t.Callable:
61
+ """Decorator to add common format options to CLI commands."""
62
+ func = click.option(
63
+ "--normalize",
64
+ is_flag=True,
65
+ help="Whether or not to normalize identifiers to lowercase.",
66
+ )(func)
67
+ func = click.option(
68
+ "--pad",
69
+ type=int,
70
+ help="Determines the pad size in a formatted string.",
71
+ )(func)
72
+ func = click.option(
73
+ "--indent",
74
+ type=int,
75
+ help="Determines the indentation size in a formatted string.",
76
+ )(func)
77
+ func = click.option(
78
+ "--normalize-functions",
79
+ type=str,
80
+ help="Whether or not to normalize all function names. Possible values are: 'upper', 'lower'",
81
+ )(func)
82
+ func = click.option(
83
+ "--leading-comma",
84
+ is_flag=True,
85
+ help="Determines whether or not the comma is leading or trailing in select expressions. Default is trailing.",
86
+ )(func)
87
+ func = click.option(
88
+ "--max-text-width",
89
+ type=int,
90
+ help="The max number of characters in a segment before creating new lines in pretty mode.",
91
+ )(func)
92
+ return func
sqlmesh/core/dialect.py CHANGED
@@ -346,12 +346,14 @@ def _parse_select(
346
346
  table: bool = False,
347
347
  parse_subquery_alias: bool = True,
348
348
  parse_set_operation: bool = True,
349
+ consume_pipe: bool = True,
349
350
  ) -> t.Optional[exp.Expression]:
350
351
  select = self.__parse_select( # type: ignore
351
352
  nested=nested,
352
353
  table=table,
353
354
  parse_subquery_alias=parse_subquery_alias,
354
355
  parse_set_operation=parse_set_operation,
356
+ consume_pipe=consume_pipe,
355
357
  )
356
358
 
357
359
  if (
sqlmesh/magics.py CHANGED
@@ -93,6 +93,43 @@ def pass_sqlmesh_context(func: t.Callable) -> t.Callable:
93
93
  return wrapper
94
94
 
95
95
 
96
+ def format_arguments(func: t.Callable) -> t.Callable:
97
+ """Decorator to add common format arguments to magic commands."""
98
+ func = argument(
99
+ "--normalize",
100
+ action="store_true",
101
+ help="Whether or not to normalize identifiers to lowercase.",
102
+ default=None,
103
+ )(func)
104
+ func = argument(
105
+ "--pad",
106
+ type=int,
107
+ help="Determines the pad size in a formatted string.",
108
+ )(func)
109
+ func = argument(
110
+ "--indent",
111
+ type=int,
112
+ help="Determines the indentation size in a formatted string.",
113
+ )(func)
114
+ func = argument(
115
+ "--normalize-functions",
116
+ type=str,
117
+ help="Whether or not to normalize all function names. Possible values are: 'upper', 'lower'",
118
+ )(func)
119
+ func = argument(
120
+ "--leading-comma",
121
+ action="store_true",
122
+ help="Determines whether or not the comma is leading or trailing in select expressions. Default is trailing.",
123
+ default=None,
124
+ )(func)
125
+ func = argument(
126
+ "--max-text-width",
127
+ type=int,
128
+ help="The max number of characters in a segment before creating new lines in pretty mode.",
129
+ )(func)
130
+ return func
131
+
132
+
96
133
  @magics_class
97
134
  class SQLMeshMagics(Magics):
98
135
  @property
@@ -579,23 +616,39 @@ class SQLMeshMagics(Magics):
579
616
  )
580
617
  @argument("--dialect", type=str, help="SQL dialect to render.")
581
618
  @argument("--no-format", action="store_true", help="Disable fancy formatting of the query.")
619
+ @format_arguments
582
620
  @line_magic
583
621
  @pass_sqlmesh_context
584
622
  def render(self, context: Context, line: str) -> None:
585
623
  """Renders a model's query, optionally expanding referenced models."""
586
624
  context.refresh()
587
- args = parse_argstring(self.render, line)
625
+ render_opts = vars(parse_argstring(self.render, line))
626
+ model = render_opts.pop("model")
627
+ dialect = render_opts.pop("dialect", None)
588
628
 
589
629
  query = context.render(
590
- args.model,
591
- start=args.start,
592
- end=args.end,
593
- execution_time=args.execution_time,
594
- expand=args.expand,
630
+ model,
631
+ start=render_opts.pop("start", None),
632
+ end=render_opts.pop("end", None),
633
+ execution_time=render_opts.pop("execution_time", None),
634
+ expand=render_opts.pop("expand", False),
595
635
  )
596
636
 
597
- sql = query.sql(pretty=True, dialect=args.dialect or context.config.dialect)
598
- if args.no_format:
637
+ no_format = render_opts.pop("no_format", False)
638
+
639
+ format_config = context.config_for_node(model).format
640
+ format_options = {
641
+ **format_config.generator_options,
642
+ **{k: v for k, v in render_opts.items() if v is not None},
643
+ }
644
+
645
+ sql = query.sql(
646
+ pretty=True,
647
+ dialect=context.config.dialect if dialect is None else dialect,
648
+ **format_options,
649
+ )
650
+
651
+ if no_format:
599
652
  context.console.log_status_update(sql)
600
653
  else:
601
654
  context.console.show_sql(sql)
@@ -853,55 +906,24 @@ class SQLMeshMagics(Magics):
853
906
  help="Transpile project models to the specified dialect.",
854
907
  )
855
908
  @argument(
856
- "--append-newline",
857
- action="store_true",
858
- help="Whether or not to append a newline to the end of the file.",
859
- default=None,
860
- )
861
- @argument(
862
- "--no-rewrite-casts",
863
- action="store_true",
864
- help="Whether or not to preserve the existing casts, without rewriting them to use the :: syntax.",
865
- default=None,
866
- )
867
- @argument(
868
- "--normalize",
909
+ "--check",
869
910
  action="store_true",
870
- help="Whether or not to normalize identifiers to lowercase.",
911
+ help="Whether or not to check formatting (but not actually format anything).",
871
912
  default=None,
872
913
  )
873
914
  @argument(
874
- "--pad",
875
- type=int,
876
- help="Determines the pad size in a formatted string.",
877
- )
878
- @argument(
879
- "--indent",
880
- type=int,
881
- help="Determines the indentation size in a formatted string.",
882
- )
883
- @argument(
884
- "--normalize-functions",
885
- type=str,
886
- help="Whether or not to normalize all function names. Possible values are: 'upper', 'lower'",
887
- )
888
- @argument(
889
- "--leading-comma",
915
+ "--append-newline",
890
916
  action="store_true",
891
- help="Determines whether or not the comma is leading or trailing in select expressions. Default is trailing.",
917
+ help="Include a newline at the end of the output.",
892
918
  default=None,
893
919
  )
894
920
  @argument(
895
- "--max-text-width",
896
- type=int,
897
- help="The max number of characters in a segment before creating new lines in pretty mode.",
898
- )
899
- @argument(
900
- "--check",
921
+ "--no-rewrite-casts",
901
922
  action="store_true",
902
- help="Whether or not to check formatting (but not actually format anything).",
923
+ help="Preserve the existing casts, without rewriting them to use the :: syntax.",
903
924
  default=None,
904
925
  )
926
+ @format_arguments
905
927
  @line_magic
906
928
  @pass_sqlmesh_context
907
929
  def format(self, context: Context, line: str) -> bool:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sqlmesh
3
- Version: 0.194.2.dev9
3
+ Version: 0.194.2.dev11
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.29.0
236
+ Requires-Dist: sqlglot[rs]~=26.30.0
237
237
  Requires-Dist: tenacity
238
238
  Requires-Dist: time-machine
239
239
  Requires-Dist: json-stream
@@ -1,21 +1,21 @@
1
1
  sqlmesh/__init__.py,sha256=QjwaamJIdW7voXoS880yAx7tHm-Im4_mqGA-XJgafos,7631
2
- sqlmesh/_version.py,sha256=ROnxoSchqF5Mlj88PjpE5GRJwgCe1mrGEpio2fy4Z08,528
3
- sqlmesh/magics.py,sha256=ysPC5ohXpgQ8IHQPwtQtwGoVypmVq_YBlm1noUueDIw,40448
2
+ sqlmesh/_version.py,sha256=MNQTsCYy-w7J4BscaAPLUKS1LdzZ-X95OrTOYfZBTr8,530
3
+ sqlmesh/magics.py,sha256=d7udR_sieKWzp_YXNFPA2O173xDCqk6u9CIKB7Skb2c,41206
4
4
  sqlmesh/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  sqlmesh/cicd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  sqlmesh/cicd/bot.py,sha256=2zlbn-DXkqQzr3lA0__IGU4XaIfXBXBKLWXNI2DRJX8,759
7
7
  sqlmesh/cicd/config.py,sha256=mpgkisSBBovlNrNZir2unT8Wes6b38RW2UsU_o4e8vY,109
8
8
  sqlmesh/cli/__init__.py,sha256=MAXAyO7isbyM-PaSdFjkJNcjn32WjOl0XzxT5gvp_vo,1690
9
9
  sqlmesh/cli/example_project.py,sha256=QAFQbw_kzqn30GLTthqsuWXbFDBpX8W6RsCgQ-jx65M,9308
10
- sqlmesh/cli/main.py,sha256=CM97CwI_DkrcE6TfJOwpiAaheYDr8WE7Tl-8asgV-Yw,33845
11
- sqlmesh/cli/options.py,sha256=aC_L5WnMScKzMU55BD1Y-8R-QzqCkPSYrlCI-payHRA,1333
10
+ sqlmesh/cli/main.py,sha256=wo5_057ofKgB6D32bl6zBCNZDKwBSXrZv5IzGpRnB3o,33179
11
+ sqlmesh/cli/options.py,sha256=-4ZclMIeIg8tghLowtmQNmpEFlm0QtOVEh40NqRdFHA,2499
12
12
  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=pMIkBjaigneVqGkoGxOKVmT423RPfbDKX8TQ8D1SzpU,153466
15
15
  sqlmesh/core/constants.py,sha256=gUABXWYgH_XOSbaZAJsR5o1dmA61JDCvBDyxqqXX3LM,2630
16
16
  sqlmesh/core/context.py,sha256=jo-qLN33tDXEI7G2_r7inSDAAzQ6H97rFdN3M2z7lk8,118394
17
17
  sqlmesh/core/context_diff.py,sha256=TCzM8egBE35DskpouOB-GQM2Qf5iUHWbRgiB5yZ6tzg,21552
18
- sqlmesh/core/dialect.py,sha256=93cXYVuNoZ9CvJNTVn2Yz7WDOdHINwVXflbn0eZ-p14,49764
18
+ sqlmesh/core/dialect.py,sha256=h9bDZWbVs7SvIBGvlIAxqdWWFOwE2qzpzs7LwNQX7vc,49830
19
19
  sqlmesh/core/environment.py,sha256=7DbJX0r5nZRU3LhcgIxbSV-JosQYDjAt3V5Wc2Fpns8,13005
20
20
  sqlmesh/core/lineage.py,sha256=zjB0Zfamo2Fja2r5SSZPMbrEKTXr1WjozZPVqvxdybI,3143
21
21
  sqlmesh/core/loader.py,sha256=XVUd1UwK8jlJUaZdFBghSslipH2L80YVykjFzdGMCYA,40474
@@ -282,7 +282,7 @@ sqlmesh/utils/pydantic.py,sha256=I898jAFqa3qU6lG2uPpRebVFncOUo8ZrLWM_R3K3DHU,116
282
282
  sqlmesh/utils/rich.py,sha256=BpB47G0-JcU41LkGkeGKroexj4NOV5fox4-GOIXPgIc,3545
283
283
  sqlmesh/utils/windows.py,sha256=r7Yin4WEwbvH7sKA3hOJtRsclmscNuBeCklCfVPvtQs,611
284
284
  sqlmesh/utils/yaml.py,sha256=np-WVcwmwsKghCgAj1OBBMsK1SXSRn4wR-H37cGiFr8,2282
285
- sqlmesh-0.194.2.dev9.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
285
+ sqlmesh-0.194.2.dev11.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
286
286
  web/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
287
287
  web/client/dist/index.html,sha256=w71qWSLmp-xwmVJO8m41k8Rtni3iZlF0hmhiTr-NeCI,5472
288
288
  web/client/dist/assets/Audits-sYYNn2gO.js,sha256=zSAKkif2kU0JuPH05xjNYITNPmsbDlvLKUc2-orr8AY,1041
@@ -400,8 +400,8 @@ web/server/api/endpoints/models.py,sha256=ud-lRwriyI_OYg9tZchrBgeiXELiRTLNEodraf
400
400
  web/server/api/endpoints/modules.py,sha256=8hqqgonGay_mJmpCw0IdbjsPhWlQH2VLdKAqha-myac,468
401
401
  web/server/api/endpoints/plan.py,sha256=OYuQ_4dgbhG9ibTcX1a8mvYgH3ANxw9Fhbb4wg6QWqc,9222
402
402
  web/server/api/endpoints/table_diff.py,sha256=SCy3-pr5x6bEEiOaZGCDbiHQhpgxwmnz3Acqa2Ie6jI,2090
403
- sqlmesh-0.194.2.dev9.dist-info/METADATA,sha256=Fknqrc_KTyWU6dymgfpdeou0Ua8gKcaA6i4X-A-ewX0,26690
404
- sqlmesh-0.194.2.dev9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
405
- sqlmesh-0.194.2.dev9.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
406
- sqlmesh-0.194.2.dev9.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
407
- sqlmesh-0.194.2.dev9.dist-info/RECORD,,
403
+ sqlmesh-0.194.2.dev11.dist-info/METADATA,sha256=oq74Uag6ssiJ86MvYiKIxlOyrCeQLWxuEJI98oMSQ54,26691
404
+ sqlmesh-0.194.2.dev11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
405
+ sqlmesh-0.194.2.dev11.dist-info/entry_points.txt,sha256=pIYKtg-u-uO7BK_Y0qrdmfyj0bYrcMc3Xiqr5WE3VFk,121
406
+ sqlmesh-0.194.2.dev11.dist-info/top_level.txt,sha256=bspjo5vjELQkuN0qKuTFIbsrUt3Zeo8D2mlKeHG1LdE,12
407
+ sqlmesh-0.194.2.dev11.dist-info/RECORD,,