-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathtb.ts
702 lines (701 loc) · 19.5 KB
/
tb.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
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
const completionSpec: Fig.Spec = {
name: "tb",
description: "Tinybird CLI",
options: [
{
name: "--debug",
description:
"Prints internal representation, can be combined with any command to get more information",
exclusiveOn: ["--no-debug"],
},
{
name: "--no-debug",
description:
"Prints internal representation, can be combined with any command to get more information",
exclusiveOn: ["--debug"],
},
{
name: "--token",
description:
"Use auth token, defaults to TB_TOKEN envvar, then to the .tinyb file",
args: {
name: "text",
},
},
{
name: "--host",
description:
"Use custom host, defaults to TB_HOST envvar, then to https://api.tinybird.co",
args: {
name: "text",
},
},
{
name: "--gcp-project-id",
description: "The Google Cloud project ID",
args: {
name: "text",
},
},
{
name: "--gcs-bucket",
description:
"The Google Cloud Storage bucket to write temp files when using the connectors",
args: {
name: "text",
},
},
{
name: "--google-application-credentials",
description: "Set GOOGLE_APPLICATION_CREDENTIALS",
args: {
name: "text",
},
},
{
name: "--sf-account",
description: "The Snowflake Account (e.g. your-domain.west-europe.azure)",
args: {
name: "text",
},
},
{
name: "--sf-warehouse",
description: "The Snowflake warehouse name",
args: {
name: "text",
},
},
{
name: "--sf-database",
description: "The Snowflake database name",
args: {
name: "text",
},
},
{
name: "--sf-schema",
description: "The Snowflake schema name",
args: {
name: "text",
},
},
{
name: "--sf-role",
description: "The Snowflake role name",
args: {
name: "text",
},
},
{
name: "--sf-user",
description: "The Snowflake user name",
args: {
name: "text",
},
},
{
name: "--sf-password",
description: "The Snowflake password",
args: {
name: "text",
},
},
{
name: "--sf-storage-integration",
description:
"The Snowflake GCS storage integration name (leave empty to auto-generate one)",
args: {
name: "text",
},
},
{
name: "--sf-stage",
description:
"The Snowflake GCS stage name (leave empty to auto-generate one)",
args: {
name: "text",
},
},
{
name: "--with-headers",
description: "Flag to enable connector to export with headers",
},
{
name: "--version-warning",
description:
"Don't print version warning message if there's a new available version. You can use TB_VERSION_WARNING envar",
exclusiveOn: ["--no-version-warning"],
},
{
name: "--no-version-warning",
description:
"Don't print version warning message if there's a new available version. You can use TB_VERSION_WARNING envar",
exclusiveOn: ["--version-warning"],
},
{
name: "--hide-tokens",
description: "Disable the output of tokens",
},
{
name: "--version",
description: "Show the version and exit",
},
{
name: "--help",
description: "Show this message and exit",
},
],
subcommands: [
{
name: "check",
description: "Check file syntax",
options: [
{
name: "--debug",
description: "Print internal representation",
},
{
name: "--help",
description: "Show this message and exit",
},
],
args: {
name: "path",
template: ["folders", "filepaths"],
},
},
{
name: "dependencies",
description: "Print all data sources dependencies",
options: [
{
name: "--no-deps",
description: "Print only data sources with no pipes using them",
},
{
name: "--match",
description: "Retrieve any resource matching the pattern",
args: {
name: "text",
},
},
{
name: "--pipe",
description: "Retrieve any resource used by pipe",
args: {
name: "text",
},
},
{
name: "--datasource",
description: "Retrieve resources depending on this Data Source",
args: {
name: "text",
},
},
{
name: "--check-for-partial-replace",
description:
"Retrieve dependant Data Sources that will have their data replaced if a partial replace is executed in the Data Source selected",
},
{
name: "--recursive",
description: "Calculate recursive dependencies",
},
{
name: "--help",
description: "Show this message and exit",
},
],
},
{
name: "diff",
description:
"Diffs local datafiles to the corresponding remote files in the workspace",
options: [
{
name: "--fmt",
description:
"Format files before doing the diff, default is True so both files match the format",
exclusiveOn: ["--no-fmt"],
},
{
name: "--no-fmt",
description:
"Format files before doing the diff, default is True so both files match the format",
exclusiveOn: ["--fmt"],
},
{
name: "--no-color",
description: "Don't colorize diff",
},
{
name: "--main",
description:
"Diffs local datafiles to the corresponding remote files in the main workspace. Only works when authenticated on a branch",
},
{
name: "--help",
description: "Show this message and exit",
},
],
args: {
name: "path",
template: ["folders", "filepaths"],
isVariadic: true,
},
},
{
name: "drop-prefix",
description:
"Drop all the resources inside a project with prefix. This command is dangerous because it removes everything, use with care",
options: [
{
name: "--yes",
description: "Do not ask for confirmation",
},
{
name: "--dry-run",
description: "Run the command without removing anything",
},
{
name: "--help",
description: "Show this message and exit",
},
],
args: {
name: "text",
},
},
{
name: "fmt",
description:
"Formats a .datasource, .pipe or .incl file\n\nThis command removes comments starting with # from the file, use DESCRIPTION instead.\n\nThe format command tries to parse the datafile so syntax errors might rise.\n\n.incl files must contain a NODE definition",
options: [
{
name: "--line-length",
description:
"A number indicating the maximum characters per line in the node SQL, lines will be splitted based on the SQL syntax and the number of characters passed as a parameter",
args: {
name: "integer",
},
},
{
name: "--dry-run",
description: "Don't ask to override the local file",
},
{
name: "--yes",
description:
"Do not ask for confirmation to overwrite the local file",
},
{
name: "--help",
description: "Show this message and exit",
},
],
args: {
name: "path",
template: ["folders", "filepaths"],
isVariadic: true,
},
},
{
name: "init",
description: "Initialize folder layout",
options: [
{
name: "--generate-datasources",
description:
"Generate datasources based on CSV, NDJSON and Parquet files in this folder",
},
{
name: "--folder",
description: "Folder where files will be placed",
args: {
name: "directory",
template: ["folders"],
},
},
{
name: "--force",
description: "Overrides existing files",
},
{
name: "--help",
description: "Show this message and exit",
},
],
},
{
name: "materialize",
description:
"[BETA] Given a local Pipe datafile path (FILENAME) and optionally a Materialized View name (TARGET_DATASOURCE), choose one of its nodes to materialize.\n\nThis command guides you to generate the Materialized View with name TARGET_DATASOURCE, the only requirement is having a valid Pipe datafile locally. Use `tb pull` to download resources from your workspace when needed.\n\nSyntax: tb materialize path/to/pipe.pipe",
options: [
{
name: "--prefix",
description: "Use prefix for all the resources",
args: {
name: "text",
},
},
{
name: "--push-deps",
description: "Push dependencies, disabled by default",
},
{
name: "--workspace_map",
isRepeatable: true,
args: [
{
name: "text",
},
{
name: "text",
},
],
},
{
name: "--workspace",
description:
"Add a workspace path to the list of external workspaces, usage: --workspace name path/to/folder",
isRepeatable: true,
args: [
{
name: "text",
},
{
name: "text",
},
],
},
{
name: "--no-versions",
description:
"When set, resource dependency versions are not used, it pushes the dependencies as-is",
},
{
name: "--verbose",
description: "Prints more log",
},
{
name: "--force-populate",
description: "Subset or full",
args: {
name: "text",
},
},
{
name: "--unlink-on-populate-error",
description:
"If the populate job fails the Materialized View is unlinked and new data won't be ingested in the Materialized View. First time a populate job fails, the Materialized View is always unlinked",
},
{
name: "--override-pipe",
description: "Override pipe if exists or prompt",
},
{
name: "--override-datasource",
description: "Override data source if exists or prompt",
},
{
name: "--help",
description: "Show this message and exit",
},
],
args: [
{
name: "path",
template: ["folders", "filepaths"],
},
{
name: "text",
},
],
},
{
name: "prompt",
description:
"Learn how to include info about the CLI in your shell PROMPT",
options: [
{
name: "--help",
description: "Show this message and exit",
},
],
},
{
name: "pull",
description: "Retrieve latest versions for project files from Tinybird",
options: [
{
name: "--folder",
description: "Folder where files will be placed",
args: {
name: "directory",
template: ["folders"],
},
},
{
name: "--auto",
description:
"Saves datafiles automatically into their default directories (/datasources or /pipes)",
},
{
name: "--match",
description:
"Retrieve any resourcing matching the pattern. eg --match _test",
args: {
name: "text",
},
},
{
name: "--prefix",
description: "Download only resources with this prefix",
args: {
name: "text",
},
},
{
name: "--force",
description: "Override existing files",
},
{
name: "--help",
description: "Show this message and exit",
},
],
},
{
name: "push",
description: "Push files to Tinybird\n",
options: [
{
name: "--prefix",
description: "Use prefix for all the resources",
args: {
name: "text",
},
},
{
name: "--dry-run",
description:
"Run the command without creating resources on the Tinybird account or any side effect",
},
{
name: "--check",
description: "Enable/Disable output checking, enabled by default",
exclusiveOn: ["--no-check"],
},
{
name: "--no-check",
description: "Enable/Disable output checking, enabled by default",
exclusiveOn: ["--check"],
},
{
name: "--push-deps",
description: "Push dependencies, disabled by default",
},
{
name: "--debug",
description:
"Prints internal representation, can be combined with any command to get more information",
},
{
name: ["-f", "--force"],
description: "Override pipes when they already exist",
},
{
name: "--override-datasource",
description:
"When pushing a pipe with a Materialized node if the target Data Source exists it will try to override it",
},
{
name: "--populate",
description: "Populate materialized nodes when pushing them",
},
{
name: "--subset",
description:
"Populate with a subset percent of the data (limited to a maximum of 2M rows), this is useful to quickly test a materialized node with some data. The subset must be greater than 0 and lower than 0.1. A subset of 0.1 means a 10 percent of the data in the source Data Source will be used to populate the materialized view. Use it together with --populate, it has precedence over --sql-condition",
args: {
name: "float",
},
},
{
name: "--sql-condition",
description:
"Populate with a SQL condition to be applied to the trigger Data Source of the Materialized View. For instance, `--sql-condition='date == toYYYYMM(now())'` it'll populate taking all the rows from the trigger Data Source which `date` is the current month. Use it together with --populate. --sql-condition is not taken into account if the --subset param is present. Including in the ``sql_condition`` any column present in the Data Source ``engine_sorting_key`` will make the populate job process less data",
args: {
name: "text",
},
},
{
name: "--unlink-on-populate-error",
description:
"If the populate job fails the Materialized View is unlinked and new data won't be ingested in the Materialized View. First time a populate job fails, the Materialized View is always unlinked",
},
{
name: "--fixtures",
description: "Append fixtures to data sources",
},
{
name: "--wait",
description:
"To be used along with --populate command. Waits for populate jobs to finish, showing a progress bar. Disabled by default",
},
{
name: "--yes",
description: "Do not ask for confirmation",
},
{
name: "--only-response-times",
description: "Checks only response times, when --force push a pipe",
},
{
name: "--workspace_map",
isRepeatable: true,
args: [
{
name: "text",
},
{
name: "text",
},
],
},
{
name: "--workspace",
description:
"Add a workspace path to the list of external workspaces, usage: --workspace name path/to/folder",
isRepeatable: true,
args: [
{
name: "text",
},
{
name: "text",
},
],
},
{
name: "--no-versions",
description:
"When set, resource dependency versions are not used, it pushes the dependencies as-is",
},
{
name: "--timeout",
description: "Timeout you want to use for the job populate",
args: {
name: "float",
},
},
{
name: ["-l", "--limit"],
description: "Number of requests to validate",
args: {
name: "integer range",
},
},
{
name: "--sample-by-params",
description:
"When set, we will aggregate the pipe_stats_rt requests by extractURLParameterNames(assumeNotNull(url)) and for each combination we will take a sample of N requests",
args: {
name: "integer range",
},
},
{
name: ["-ff", "--failfast"],
description: "When set, the checker will exit as soon one test fails",
},
{
name: "--ignore-order",
description:
"When set, the checker will ignore the order of list properties",
},
{
name: "--validate-processed-bytes",
description:
"When set, the checker will validate that the new version doesn't process more than 25% than the current version",
},
{
name: "--last-requests-from-main",
description:
"When set, the checker will get top requests requests from main",
},
{
name: "--help",
description: "Show this message and exit",
},
],
args: {
name: "path",
template: ["folders", "filepaths"],
isVariadic: true,
},
},
{
name: "sql",
description: "Run SQL query over data sources and pipes",
options: [
{
name: "--rows_limit",
description: "Max number of rows retrieved",
args: {
name: "integer",
},
},
{
name: "--pipeline",
description: "The name of the Pipe to run the SQL Query",
args: {
name: "text",
},
},
{
name: "--pipe",
description:
"The path to the .pipe file to run the SQL Query of a specific NODE",
args: {
name: "text",
},
},
{
name: "--node",
description: "The NODE name",
args: {
name: "text",
},
},
{
name: "--format",
description: "Output format",
args: {
name: "choice",
suggestions: ["json", "csv", "human"],
},
},
{
name: "--stats",
description: "Show query stats",
exclusiveOn: ["--no-stats"],
},
{
name: "--no-stats",
description: "Show query stats",
exclusiveOn: ["--stats"],
},
{
name: "--help",
description: "Show this message and exit",
},
],
args: {
name: "text",
},
},
],
};
export default completionSpec;