@malloydata/malloy-tests 0.0.119-dev240123183113 → 0.0.119-dev240124170348

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.
@@ -29,7 +29,7 @@ import {
29
29
  StructDef,
30
30
  StructRelationship,
31
31
  } from '@malloydata/malloy';
32
- import {describeIfDatabaseAvailable, fStringLike} from '../../util';
32
+ import {describeIfDatabaseAvailable, fStringLike, fToQF} from '../../util';
33
33
 
34
34
  import * as malloy from '@malloydata/malloy';
35
35
  import {RuntimeList} from '../../runtimes';
@@ -43,14 +43,14 @@ describe('BigQuery hand-built expression test', () => {
43
43
  await runtimes.closeAll();
44
44
  });
45
45
 
46
- function withJoin(leftKey: string, rightKey: string): StructRelationship {
46
+ function withJoin(leftKey: string[], rightKey: string[]): StructRelationship {
47
47
  return {
48
48
  type: 'one',
49
49
  matrixOperation: 'left',
50
50
  onExpression: [
51
- {type: 'field', path: `${leftKey}`},
51
+ {type: 'field', path: leftKey},
52
52
  '=',
53
- {type: 'field', path: `${rightKey}`},
53
+ {type: 'field', path: rightKey},
54
54
  ],
55
55
  };
56
56
  }
@@ -125,7 +125,7 @@ describe('BigQuery hand-built expression test', () => {
125
125
  {
126
126
  type: 'aggregate',
127
127
  function: 'sum',
128
- e: [{type: 'field', path: 'seats'}],
128
+ e: [{type: 'field', path: ['seats']}],
129
129
  },
130
130
  ],
131
131
  expressionType: 'aggregate',
@@ -142,7 +142,7 @@ describe('BigQuery hand-built expression test', () => {
142
142
  {
143
143
  type: 'aggregate',
144
144
  function: 'sum',
145
- e: [{type: 'field', path: 'seats'}],
145
+ e: [{type: 'field', path: ['seats']}],
146
146
  },
147
147
  ],
148
148
  filterList: [
@@ -152,7 +152,7 @@ describe('BigQuery hand-built expression test', () => {
152
152
  expression: [
153
153
  {
154
154
  type: 'field',
155
- path: 'manufacturer',
155
+ path: ['manufacturer'],
156
156
  },
157
157
  "='BOEING'",
158
158
  ],
@@ -167,9 +167,9 @@ describe('BigQuery hand-built expression test', () => {
167
167
  type: 'number',
168
168
  e: [
169
169
  '(',
170
- {type: 'field', path: 'boeing_seats'},
170
+ {type: 'field', path: ['boeing_seats']},
171
171
  '/',
172
- {type: 'field', path: 'total_seats'},
172
+ {type: 'field', path: ['total_seats']},
173
173
  ')*100',
174
174
  ],
175
175
  expressionType: 'aggregate',
@@ -179,7 +179,7 @@ describe('BigQuery hand-built expression test', () => {
179
179
  name: 'percent_boeing_floor',
180
180
  type: 'number',
181
181
  expressionType: 'aggregate',
182
- e: ['FLOOR(', {type: 'field', path: 'percent_boeing'}, ')'],
182
+ e: ['FLOOR(', {type: 'field', path: ['percent_boeing']}, ')'],
183
183
  numberType: 'float',
184
184
  },
185
185
  ],
@@ -238,14 +238,14 @@ describe('BigQuery hand-built expression test', () => {
238
238
  {
239
239
  type: 'turtle',
240
240
  name: 'hand_turtle',
241
- pipeline: [{type: 'reduce', fields: ['aircraft_count']}],
241
+ pipeline: [{type: 'reduce', queryFields: fToQF(['aircraft_count'])}],
242
242
  },
243
243
  {
244
244
  type: 'turtle',
245
245
  name: 'hand_turtle_pipeline',
246
246
  pipeline: [
247
- {type: 'reduce', fields: ['aircraft_count']},
248
- {type: 'reduce', fields: ['aircraft_count']},
247
+ {type: 'reduce', queryFields: fToQF(['aircraft_count'])},
248
+ {type: 'reduce', queryFields: fToQF(['aircraft_count'])},
249
249
  ],
250
250
  },
251
251
  ],
@@ -260,8 +260,8 @@ describe('BigQuery hand-built expression test', () => {
260
260
  {
261
261
  ...modelHandBase,
262
262
  structRelationship: withJoin(
263
- 'aircraft_model_code',
264
- 'aircraft_models.aircraft_model_code'
263
+ ['aircraft_model_code'],
264
+ ['aircraft_models', 'aircraft_model_code']
265
265
  ),
266
266
  },
267
267
  ],
@@ -290,7 +290,7 @@ describe('BigQuery hand-built expression test', () => {
290
290
  pipeline: [
291
291
  {
292
292
  type: 'reduce',
293
- fields: [
293
+ queryFields: [
294
294
  // "aircraft_models.total_seats",
295
295
  // "aircraft_models.boeing_seats"
296
296
  // "aircraft_models.percent_boeing",
@@ -319,7 +319,7 @@ describe('BigQuery hand-built expression test', () => {
319
319
  e: [
320
320
  {
321
321
  type: 'field',
322
- path: 'aircraft_models.seats',
322
+ path: ['aircraft_models', 'seats'],
323
323
  },
324
324
  ],
325
325
  },
@@ -331,7 +331,7 @@ describe('BigQuery hand-built expression test', () => {
331
331
  expression: [
332
332
  {
333
333
  type: 'field',
334
- path: 'aircraft_models.manufacturer',
334
+ path: ['aircraft_models', 'manufacturer'],
335
335
  },
336
336
  "='BOEING'",
337
337
  ],
@@ -359,7 +359,7 @@ describe('BigQuery hand-built expression test', () => {
359
359
  ._loadQueryFromQueryDef({
360
360
  structRef: 'aircraft',
361
361
  name: 'hand_turtle',
362
- pipeline: [{type: 'reduce', fields: ['aircraft_count']}],
362
+ pipeline: [{type: 'reduce', queryFields: fToQF(['aircraft_count'])}],
363
363
  })
364
364
  .run();
365
365
  expect(result.data.value[0]['aircraft_count']).toBe(3599);
@@ -413,17 +413,20 @@ describe('BigQuery hand-built expression test', () => {
413
413
  pipeline: [
414
414
  {
415
415
  type: 'reduce',
416
- fields: [
416
+ queryFields: fToQF([
417
417
  'state',
418
418
  'aircraft_count',
419
419
  {
420
420
  type: 'turtle',
421
421
  name: 'my_turtle',
422
422
  pipeline: [
423
- {type: 'reduce', fields: ['county', 'aircraft_count']},
423
+ {
424
+ type: 'reduce',
425
+ queryFields: fToQF(['county', 'aircraft_count']),
426
+ },
424
427
  ],
425
428
  },
426
- ],
429
+ ]),
427
430
  },
428
431
  ],
429
432
  });
@@ -438,7 +441,7 @@ describe('BigQuery hand-built expression test', () => {
438
441
  pipeline: [
439
442
  {
440
443
  type: 'reduce',
441
- fields: [
444
+ queryFields: fToQF([
442
445
  'state',
443
446
  'aircraft_count',
444
447
  {
@@ -448,11 +451,11 @@ describe('BigQuery hand-built expression test', () => {
448
451
  e: [
449
452
  {
450
453
  type: 'exclude',
451
- e: [{type: 'field', path: 'aircraft_count'}],
454
+ e: [{type: 'field', path: ['aircraft_count']}],
452
455
  },
453
456
  ],
454
457
  },
455
- ],
458
+ ]),
456
459
  },
457
460
  ],
458
461
  });
@@ -467,7 +470,7 @@ describe('BigQuery hand-built expression test', () => {
467
470
  pipeline: [
468
471
  {
469
472
  type: 'reduce',
470
- fields: ['state', 'aircraft_count', 'hand_turtle'],
473
+ queryFields: fToQF(['state', 'aircraft_count', 'hand_turtle']),
471
474
  },
472
475
  ],
473
476
  });
@@ -482,7 +485,7 @@ describe('BigQuery hand-built expression test', () => {
482
485
  pipeline: [
483
486
  {
484
487
  type: 'reduce',
485
- fields: [
488
+ queryFields: fToQF([
486
489
  'state',
487
490
  'aircraft_count',
488
491
  {
@@ -491,7 +494,7 @@ describe('BigQuery hand-built expression test', () => {
491
494
  pipeline: [
492
495
  {
493
496
  type: 'reduce',
494
- fields: [
497
+ queryFields: fToQF([
495
498
  'county',
496
499
  'aircraft_count',
497
500
  {
@@ -501,15 +504,15 @@ describe('BigQuery hand-built expression test', () => {
501
504
  e: [
502
505
  {
503
506
  type: 'exclude',
504
- e: [{type: 'field', path: 'aircraft_count'}],
507
+ e: [{type: 'field', path: ['aircraft_count']}],
505
508
  },
506
509
  ],
507
510
  },
508
- ],
511
+ ]),
509
512
  },
510
513
  ],
511
514
  },
512
- ],
515
+ ]),
513
516
  },
514
517
  ],
515
518
  });
@@ -523,8 +526,8 @@ describe('BigQuery hand-built expression test', () => {
523
526
  structRef: 'aircraft',
524
527
  name: 'hand_turtle_pipeline',
525
528
  pipeline: [
526
- {type: 'reduce', fields: ['aircraft_count']},
527
- {type: 'reduce', fields: ['aircraft_count']},
529
+ {type: 'reduce', queryFields: fToQF(['aircraft_count'])},
530
+ {type: 'reduce', queryFields: fToQF(['aircraft_count'])},
528
531
  ],
529
532
  });
530
533
  // console.log(result.sql);
@@ -540,7 +543,7 @@ describe('BigQuery hand-built expression test', () => {
540
543
  pipeline: [
541
544
  {
542
545
  type: 'reduce',
543
- fields: [
546
+ queryFields: fToQF([
544
547
  'aircraft_count',
545
548
  {
546
549
  type: 'turtle',
@@ -548,12 +551,12 @@ describe('BigQuery hand-built expression test', () => {
548
551
  pipeline: [
549
552
  {
550
553
  type: 'reduce',
551
- fields: ['state', 'county', 'aircraft_count'],
554
+ queryFields: fToQF(['state', 'county', 'aircraft_count']),
552
555
  },
553
556
  {
554
557
  type: 'reduce',
555
558
  filterList: [fStringLike('county', '2%')],
556
- fields: [
559
+ queryFields: fToQF([
557
560
  'state',
558
561
  {
559
562
  name: 'total_aircraft',
@@ -562,17 +565,17 @@ describe('BigQuery hand-built expression test', () => {
562
565
  {
563
566
  type: 'aggregate',
564
567
  function: 'sum',
565
- e: [{type: 'field', path: 'aircraft_count'}],
568
+ e: [{type: 'field', path: ['aircraft_count']}],
566
569
  },
567
570
  ],
568
571
  expressionType: 'aggregate',
569
572
  numberType: 'float',
570
573
  },
571
- ],
574
+ ]),
572
575
  },
573
576
  ],
574
577
  },
575
- ],
578
+ ]),
576
579
  },
577
580
  ],
578
581
  })
@@ -673,7 +676,7 @@ describe('BigQuery hand-built expression test', () => {
673
676
  pipeline: [
674
677
  {
675
678
  type: 'reduce',
676
- fields: [
679
+ queryFields: [
677
680
  {
678
681
  name: 'boeing_seats',
679
682
  type: 'number',
@@ -685,8 +688,10 @@ describe('BigQuery hand-built expression test', () => {
685
688
  {
686
689
  type: 'aggregate',
687
690
  function: 'sum',
688
- structPath: 'aircraft_models',
689
- e: [{type: 'field', path: 'aircraft_models.seats'}],
691
+ structPath: ['aircraft_models'],
692
+ e: [
693
+ {type: 'field', path: ['aircraft_models', 'seats']},
694
+ ],
690
695
  },
691
696
  ],
692
697
  filterList: [
@@ -696,7 +701,7 @@ describe('BigQuery hand-built expression test', () => {
696
701
  expression: [
697
702
  {
698
703
  type: 'field',
699
- path: 'aircraft_models.manufacturer',
704
+ path: ['aircraft_models', 'manufacturer'],
700
705
  },
701
706
  "='BOEING'",
702
707
  ],
@@ -725,9 +730,9 @@ describe('BigQuery hand-built expression test', () => {
725
730
  type: 'many',
726
731
  matrixOperation: 'left',
727
732
  onExpression: [
728
- {type: 'field', path: 'aircraft_model_code'},
733
+ {type: 'field', path: ['aircraft_model_code']},
729
734
  '=',
730
- {type: 'field', path: 'aircraft.aircraft_model_code'},
735
+ {type: 'field', path: ['aircraft', 'aircraft_model_code']},
731
736
  ],
732
737
  },
733
738
  },
@@ -753,11 +758,11 @@ describe('BigQuery hand-built expression test', () => {
753
758
  pipeline: [
754
759
  {
755
760
  type: 'reduce',
756
- fields: [
761
+ queryFields: fToQF([
757
762
  'aircraft.state',
758
763
  'aircraft.aircraft_count',
759
764
  'model_count',
760
- ],
765
+ ]),
761
766
  },
762
767
  ],
763
768
  })
@@ -774,7 +779,7 @@ describe('BigQuery hand-built expression test', () => {
774
779
  pipeline: [
775
780
  {
776
781
  type: 'reduce',
777
- fields: ['total_seats', 'aircraft.aircraft_count'],
782
+ queryFields: fToQF(['total_seats', 'aircraft.aircraft_count']),
778
783
  },
779
784
  ],
780
785
  })
@@ -26,7 +26,7 @@ import * as malloy from '@malloydata/malloy';
26
26
  import {Query} from '@malloydata/malloy';
27
27
  import {testModel} from '../../models/faa_model';
28
28
  import {BigQueryTestConnection, RuntimeList} from '../../runtimes';
29
- import {describeIfDatabaseAvailable, fStringEq} from '../../util';
29
+ import {describeIfDatabaseAvailable, fStringEq, fToQF} from '../../util';
30
30
  import '../../util/db-jest-matchers';
31
31
 
32
32
  const runtimeList = new RuntimeList(['bigquery']);
@@ -85,7 +85,7 @@ describe('BigQuery expression tests', () => {
85
85
  // top 5 routes per carrier
86
86
  {
87
87
  type: 'reduce',
88
- fields: [
88
+ queryFields: fToQF([
89
89
  'carrier',
90
90
  'flight_count',
91
91
  {
@@ -94,7 +94,7 @@ describe('BigQuery expression tests', () => {
94
94
  pipeline: [
95
95
  {
96
96
  type: 'reduce',
97
- fields: [
97
+ queryFields: fToQF([
98
98
  'origin_code',
99
99
  'destination_code',
100
100
  'flight_count',
@@ -110,23 +110,23 @@ describe('BigQuery expression tests', () => {
110
110
  },
111
111
  ],
112
112
  },
113
- ],
113
+ ]),
114
114
  },
115
115
  ],
116
116
  },
117
- ],
117
+ ]),
118
118
  limit: 5,
119
119
  orderBy: [{dir: 'desc', field: 'carrier'}],
120
120
  },
121
121
  // carrier top routes
122
122
  {
123
123
  type: 'project',
124
- fields: [
124
+ queryFields: fToQF([
125
125
  'carrier',
126
126
  'flight_count',
127
127
  'routes.origin_code',
128
128
  'routes.route_flights',
129
- ],
129
+ ]),
130
130
  },
131
131
  ],
132
132
  });
@@ -136,7 +136,9 @@ describe('BigQuery expression tests', () => {
136
136
  it('step_0', async () => {
137
137
  const sql = await compileQueryFromQueryDef(faa, {
138
138
  structRef: 'flights',
139
- pipeline: [{type: 'reduce', fields: ['carriers.name', 'flight_count']}],
139
+ pipeline: [
140
+ {type: 'reduce', queryFields: fToQF(['carriers.name', 'flight_count'])},
141
+ ],
140
142
  });
141
143
  await bqCompile(sql);
142
144
  });
@@ -148,7 +150,9 @@ describe('BigQuery expression tests', () => {
148
150
  fStringEq('origin.state', 'CA'),
149
151
  fStringEq('destination.state', 'NY'),
150
152
  ],
151
- pipeline: [{type: 'reduce', fields: ['carriers.name', 'flight_count']}],
153
+ pipeline: [
154
+ {type: 'reduce', queryFields: fToQF(['carriers.name', 'flight_count'])},
155
+ ],
152
156
  });
153
157
  await bqCompile(sql);
154
158
  });
@@ -158,7 +162,7 @@ describe('BigQuery expression tests', () => {
158
162
  structRef: 'flights',
159
163
  pipeline: [
160
164
  {
161
- fields: [
165
+ queryFields: [
162
166
  {
163
167
  as: 'dep_year',
164
168
  name: 'dep_time',
@@ -213,7 +217,7 @@ describe('BigQuery expression tests', () => {
213
217
  {
214
218
  type: 'aggregate',
215
219
  function: 'sum',
216
- e: [{type: 'field', path: 'distance'}],
220
+ e: [{type: 'field', path: ['distance']}],
217
221
  },
218
222
  ],
219
223
  },
@@ -232,7 +236,7 @@ describe('BigQuery expression tests', () => {
232
236
  const sql = await compileQueryFromQueryDef(faa, {
233
237
  pipeline: [
234
238
  {
235
- fields: [
239
+ queryFields: fToQF([
236
240
  {
237
241
  bucketFilter: 'AA,WN,DL',
238
242
  bucketOther: 'Other Carrier',
@@ -240,7 +244,7 @@ describe('BigQuery expression tests', () => {
240
244
  type: 'string',
241
245
  },
242
246
  'flight_count',
243
- ],
247
+ ]),
244
248
  orderBy: [{dir: 'asc', field: 2}],
245
249
  type: 'reduce',
246
250
  },
@@ -258,7 +262,9 @@ describe('BigQuery expression tests', () => {
258
262
  it('simple_reduce', async () => {
259
263
  const sql = await compileQueryFromQueryDef(faa, {
260
264
  structRef: 'flights',
261
- pipeline: [{type: 'reduce', fields: ['carrier', 'flight_count']}],
265
+ pipeline: [
266
+ {type: 'reduce', queryFields: fToQF(['carrier', 'flight_count'])},
267
+ ],
262
268
  });
263
269
  await bqCompile(sql);
264
270
  });
@@ -269,7 +275,7 @@ describe('BigQuery expression tests', () => {
269
275
  pipeline: [
270
276
  {
271
277
  type: 'reduce',
272
- fields: [
278
+ queryFields: fToQF([
273
279
  {
274
280
  type: 'number',
275
281
  expressionType: 'aggregate',
@@ -278,12 +284,12 @@ describe('BigQuery expression tests', () => {
278
284
  {
279
285
  type: 'aggregate',
280
286
  function: 'sum',
281
- e: [{type: 'field', path: 'distance'}],
287
+ e: [{type: 'field', path: ['distance']}],
282
288
  },
283
289
  ],
284
290
  },
285
291
  'aircraft.aircraft_models.total_seats',
286
- ],
292
+ ]),
287
293
  },
288
294
  ],
289
295
  });
@@ -296,14 +302,18 @@ describe('BigQuery expression tests', () => {
296
302
  pipeline: [
297
303
  {
298
304
  type: 'reduce',
299
- fields: [
305
+ queryFields: fToQF([
300
306
  {
301
307
  type: 'string',
302
308
  name: 'carrier',
303
- e: ['UPPER(', {type: 'field', path: 'carriers.nickname'}, ')'],
309
+ e: [
310
+ 'UPPER(',
311
+ {type: 'field', path: ['carriers', 'nickname']},
312
+ ')',
313
+ ],
304
314
  },
305
315
  'flight_count',
306
- ],
316
+ ]),
307
317
  },
308
318
  ],
309
319
  });
@@ -315,7 +325,7 @@ describe('BigQuery expression tests', () => {
315
325
  structRef: 'flights',
316
326
  pipeline: [
317
327
  {
318
- fields: [
328
+ queryFields: fToQF([
319
329
  'carriers.name',
320
330
  {
321
331
  type: 'number',
@@ -325,11 +335,11 @@ describe('BigQuery expression tests', () => {
325
335
  {
326
336
  type: 'aggregate',
327
337
  function: 'sum',
328
- e: [{type: 'field', path: 'distance'}],
338
+ e: [{type: 'field', path: ['distance']}],
329
339
  },
330
340
  ],
331
341
  },
332
- ],
342
+ ]),
333
343
  type: 'reduce',
334
344
  },
335
345
  ],
@@ -343,7 +353,7 @@ describe('BigQuery expression tests', () => {
343
353
  pipeline: [
344
354
  {
345
355
  type: 'reduce',
346
- fields: [
356
+ queryFields: fToQF([
347
357
  'aircraft.aircraft_models.manufacturer',
348
358
  {
349
359
  type: 'number',
@@ -357,13 +367,13 @@ describe('BigQuery expression tests', () => {
357
367
  {
358
368
  type: 'aggregate',
359
369
  function: 'sum',
360
- e: [{type: 'field', path: 'distance'}],
370
+ e: [{type: 'field', path: ['distance']}],
361
371
  },
362
372
  ],
363
373
  },
364
374
  ],
365
375
  },
366
- ],
376
+ ]),
367
377
  },
368
378
  ],
369
379
  });
@@ -376,7 +386,7 @@ describe('BigQuery expression tests', () => {
376
386
  pipeline: [
377
387
  {
378
388
  type: 'reduce',
379
- fields: [
389
+ queryFields: fToQF([
380
390
  'origin.state',
381
391
  'flight_count',
382
392
  {
@@ -391,13 +401,13 @@ describe('BigQuery expression tests', () => {
391
401
  {
392
402
  type: 'aggregate',
393
403
  function: 'sum',
394
- e: [{type: 'field', path: 'distance'}],
404
+ e: [{type: 'field', path: ['distance']}],
395
405
  },
396
406
  ],
397
407
  },
398
408
  ],
399
409
  },
400
- ],
410
+ ]),
401
411
  filterList: [fStringEq('carriers.code', 'WN')],
402
412
  },
403
413
  ],
@@ -456,14 +466,14 @@ describe('BigQuery expression tests', () => {
456
466
  structRef: 'flights',
457
467
  pipeline: [
458
468
  {
459
- fields: [
469
+ queryFields: fToQF([
460
470
  'origin.state',
461
471
  'flight_count',
462
472
  'flights_by_model',
463
473
  'flights_by_carrier',
464
474
  'measures_first',
465
475
  'first_turtle',
466
- ],
476
+ ]),
467
477
  type: 'reduce',
468
478
  },
469
479
  ],
@@ -592,7 +602,7 @@ describe('BigQuery expression tests', () => {
592
602
  pipeline: [
593
603
  {
594
604
  type: 'reduce',
595
- fields: ['provider_state', 'num_providers'],
605
+ queryFields: fToQF(['provider_state', 'num_providers']),
596
606
  orderBy: [{dir: 'desc', field: 2}],
597
607
  },
598
608
  ],
@@ -160,7 +160,7 @@ describe.each(runtimes.runtimeList)(
160
160
  limit: 10
161
161
  }
162
162
  `).malloyResultMatches(gaModel, {
163
- fieldName: 'channelGrouping',
163
+ // fieldName: 'channelGrouping',
164
164
  // fieldValue: 'Organic Search',
165
165
  // weight: 10,
166
166
  });
@@ -173,7 +173,7 @@ describe.each(runtimes.runtimeList)(
173
173
  }
174
174
  await expect(`
175
175
  run: ${databaseName}.table('malloytest.ga_sample')-> {
176
- index: everything
176
+ index: *
177
177
  sample: ${sampleSize}
178
178
  }
179
179
  -> {