-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathsqlmesh.ts
641 lines (640 loc) · 16 KB
/
sqlmesh.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
const completionSpec: Fig.Spec = {
name: "sqlmesh",
description: "SQLMesh command line tool",
options: [
{
name: "--paths",
description: "Paths to SQLMesh project files",
args: {
name: "paths",
template: "folders",
isVariadic: true,
},
},
{
name: "--config",
description: "Path to config file",
args: {
name: "config",
template: "filepaths",
},
},
{
name: "--gateway",
description: "The name of the gateway",
args: {
name: "gateway",
},
},
{
name: "--ignore-warnings",
description: "Ignore warnings",
},
{
name: "--debug",
description: "Enable debug mode",
},
{
name: "--log-to-stdout",
description: "Display logs in stdout",
},
{
name: "--log-file-dir",
description: "The directory to write log files to",
args: {
name: "directory",
template: "folders",
},
},
],
subcommands: [
{
name: "init",
description: "Create a new SQLMesh repository",
options: [
{
name: ["-t", "--template"],
description:
"Project template. Supported values: airflow, dbt, dlt, default, empty",
args: {
name: "template",
suggestions: ["airflow", "dbt", "dlt", "default", "empty"],
},
},
{
name: "--dlt-pipeline",
description:
"DLT pipeline for which to generate a SQLMesh project. Use alongside template: dlt",
args: {
name: "pipeline",
},
},
],
args: {
name: "sql_dialect",
isOptional: true,
},
},
{
name: "render",
description:
"Render a model's query, optionally expanding referenced models",
options: [
{
name: "--dialect",
description: "The SQL dialect to render the query as",
args: {
name: "dialect",
},
},
{
name: "--no-format",
description: "Disable fancy formatting of the query",
},
{
name: "--start",
description: "Start time for the render",
args: {
name: "start",
},
},
{
name: "--end",
description: "End time for the render",
args: {
name: "end",
},
},
{
name: "--execution-time",
description: "Execution time for the render",
args: {
name: "time",
},
},
{
name: "--expand",
description: "Expand referenced models",
args: {
name: "models",
isVariadic: true,
},
},
],
args: {
name: "model",
},
},
{
name: "evaluate",
description:
"Evaluate a model and return a dataframe with a default limit of 1000",
options: [
{
name: "--start",
description: "Start time for evaluation",
args: {
name: "start",
},
},
{
name: "--end",
description: "End time for evaluation",
args: {
name: "end",
},
},
{
name: "--execution-time",
description: "Execution time for evaluation",
args: {
name: "time",
},
},
{
name: "--limit",
description:
"The number of rows which the query should be limited to",
args: {
name: "limit",
},
},
],
args: {
name: "model",
},
},
{
name: "format",
description: "Format all SQL models and audits",
options: [
{
name: ["-t", "--transpile"],
description: "Transpile project models to the specified dialect",
args: {
name: "dialect",
},
},
{
name: "--append-newline",
description: "Include a newline at the end of each file",
},
{
name: "--no-rewrite-casts",
description:
"Preserve the existing casts, without rewriting them to use the :: syntax",
},
{
name: "--normalize",
description: "Whether or not to normalize identifiers to lowercase",
},
{
name: "--pad",
description: "Determines the pad size in a formatted string",
args: {
name: "size",
},
},
{
name: "--indent",
description: "Determines the indentation size in a formatted string",
args: {
name: "size",
},
},
{
name: "--normalize-functions",
description: "Whether or not to normalize all function names",
args: {
name: "mode",
suggestions: ["upper", "lower"],
},
},
{
name: "--leading-comma",
description:
"Determines whether or not the comma is leading or trailing in select expressions",
},
{
name: "--max-text-width",
description:
"The max number of characters in a segment before creating new lines in pretty mode",
args: {
name: "width",
},
},
{
name: "--check",
description:
"Whether or not to check formatting (but not actually format anything)",
},
],
args: {
name: "paths",
template: "filepaths",
isVariadic: true,
isOptional: true,
},
},
{
name: "diff",
description:
"Show the diff between the local state and the target environment",
args: {
name: "environment",
},
},
{
name: "plan",
description: "Apply local changes to the target environment",
options: [
{
name: "--create-from",
description:
"The environment to create the target environment from if it doesn't exist. Default: prod",
args: {
name: "environment",
},
},
{
name: "--skip-tests",
description:
"Skip tests prior to generating the plan if they are defined",
},
{
name: "--restate-model",
description:
"Restate data for specified models and models downstream from the one specified",
args: {
name: "model",
},
isRepeatable: true,
},
{
name: "--no-gaps",
description:
"Ensure that new snapshots have no data gaps when comparing to existing snapshots",
},
{
name: "--skip-backfill",
description:
"Skip the backfill step and only create a virtual update for the plan",
},
{
name: "--empty-backfill",
description: "Produce empty backfill",
},
{
name: "--forward-only",
description: "Create a plan for forward-only changes",
},
{
name: "--allow-destructive-model",
description:
"Allow destructive forward-only changes to models whose names match the expression",
args: {
name: "model",
},
isRepeatable: true,
},
{
name: "--effective-from",
description:
"The effective date from which to apply forward-only changes on production",
args: {
name: "date",
},
},
{
name: "--no-prompts",
description:
"Disable interactive prompts for the backfill time range",
},
{
name: "--auto-apply",
description: "Automatically apply the new plan after creation",
},
{
name: "--no-auto-categorization",
description: "Disable automatic change categorization",
},
{
name: "--include-unmodified",
description: "Include unmodified models in the target environment",
},
{
name: "--select-model",
description:
"Select specific model changes that should be included in the plan",
args: {
name: "model",
},
isRepeatable: true,
},
{
name: "--backfill-model",
description:
"Backfill only the models whose names match the expression",
args: {
name: "model",
},
isRepeatable: true,
},
{
name: "--no-diff",
description: "Hide text differences for changed models",
},
{
name: "--run",
description:
"Run latest intervals as part of the plan application (prod environment only)",
},
{
name: "--enable-preview",
description:
"Enable preview for forward-only models when targeting a development environment",
},
{
name: "--verbose",
description: "Enable verbose output",
},
],
args: {
name: "environment",
isOptional: true,
},
},
{
name: "run",
description: "Evaluate missing intervals for the target environment",
options: [
{
name: "--start",
description: "Start time for the run",
args: {
name: "start",
},
},
{
name: "--end",
description: "End time for the run",
args: {
name: "end",
},
},
{
name: "--skip-janitor",
description: "Skip the janitor task",
},
{
name: "--ignore-cron",
description:
"Run for all missing intervals, ignoring individual cron schedules",
},
{
name: "--select-model",
description:
"Select specific models to run. Note: this always includes upstream dependencies",
args: {
name: "model",
},
isRepeatable: true,
},
{
name: "--exit-on-env-update",
description:
"Exit with specified code if the run is interrupted by an update to the target environment",
args: {
name: "code",
},
},
{
name: "--no-auto-upstream",
description:
"Do not automatically include upstream models. Only applicable when --select-model is used",
},
],
args: {
name: "environment",
isOptional: true,
},
},
{
name: "invalidate",
description:
"Invalidate the target environment, forcing its removal during the next run of the janitor process",
options: [
{
name: ["-s", "--sync"],
description:
"Wait for the environment to be deleted before returning",
},
],
args: {
name: "environment",
},
},
{
name: "janitor",
description: "Run the janitor process on-demand",
options: [
{
name: "--ignore-ttl",
description:
"Cleanup snapshots that are not referenced in any environment, regardless of when they're set to expire",
},
],
},
{
name: "dag",
description: "Render the DAG as an html file",
options: [
{
name: "--select-model",
description: "Select specific models to include in the dag",
args: {
name: "model",
},
isRepeatable: true,
},
],
args: {
name: "file",
},
},
{
name: "create_test",
description: "Generate a unit test fixture for a given model",
options: [
{
name: ["-q", "--query"],
description:
"Queries that will be used to generate data for the model's dependencies",
args: [
{
name: "name",
},
{
name: "query",
},
],
isRepeatable: true,
},
{
name: ["-o", "--overwrite"],
description:
"When true, the fixture file will be overwritten in case it already exists",
},
{
name: ["-v", "--var"],
description:
"Key-value pairs that will define variables needed by the model",
args: [
{
name: "key",
},
{
name: "value",
},
],
isRepeatable: true,
},
{
name: ["-p", "--path"],
description:
"The file path corresponding to the fixture, relative to the test directory",
args: {
name: "path",
},
},
{
name: ["-n", "--name"],
description: "The name of the test that will be created",
args: {
name: "name",
},
},
{
name: "--include-ctes",
description: "When true, CTE fixtures will also be generated",
},
],
args: {
name: "model",
},
},
{
name: "test",
description: "Run model unit tests",
options: [
{
name: ["-k", "--match-pattern"],
description: "Only run tests matching pattern",
args: {
name: "pattern",
},
isRepeatable: true,
},
{
name: "--verbose",
description: "Enable verbose output",
},
{
name: "--preserve-fixtures",
description:
"Preserve the fixture tables in the testing database, useful for debugging",
},
],
args: {
name: "tests",
isVariadic: true,
},
},
{
name: "audit",
description: "Run audits for the target model(s)",
options: [
{
name: "--model",
description: "A model to audit",
args: {
name: "model",
},
isRepeatable: true,
},
{
name: "--start",
description: "Start time for the audit",
args: {
name: "start",
},
},
{
name: "--end",
description: "End time for the audit",
args: {
name: "end",
},
},
{
name: "--execution-time",
description: "Execution time for the audit",
args: {
name: "time",
},
},
],
},
{
name: "ui",
description: "Start a browser-based SQLMesh UI",
options: [
{
name: "--host",
description: "Bind socket to this host",
args: {
name: "host",
default: "127.0.0.1",
},
},
{
name: "--port",
description: "Bind socket to this port",
args: {
name: "port",
default: "8000",
},
},
{
name: "--mode",
description: "Mode to start the UI in",
args: {
name: "mode",
suggestions: ["ide", "catalog", "docs", "plan"],
default: "ide",
},
},
],
},
{
name: "migrate",
description: "Migrate SQLMesh to the current running version",
},
{
name: "rollback",
description: "Rollback SQLMesh to the previous migration",
},
{
name: "create_external_models",
description: "Create a schema file containing external model schemas",
options: [
{
name: "--strict",
description:
"Raise an error if the external model is missing in the database",
},
],
},
],
};
export default completionSpec;