@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.
- package/dist/databases/all/db_index.spec.js +1 -1
- package/dist/databases/all/expr.spec.js +0 -45
- package/dist/databases/all/expr.spec.js.map +1 -1
- package/dist/databases/bigquery/handexpr.spec.js +50 -45
- package/dist/databases/bigquery/handexpr.spec.js.map +1 -1
- package/dist/databases/bigquery/malloy_query.spec.js +41 -31
- package/dist/databases/bigquery/malloy_query.spec.js.map +1 -1
- package/dist/databases/bigquery-duckdb/nested_source_table.spec.js +4 -4
- package/dist/databases/bigquery-duckdb/nested_source_table.spec.js.map +1 -1
- package/dist/models/faa_model.js +79 -80
- package/dist/models/faa_model.js.map +1 -1
- package/dist/models/medicare_model.js +33 -17
- package/dist/models/medicare_model.js.map +1 -1
- package/dist/tags.spec.js +17 -1
- package/dist/tags.spec.js.map +1 -1
- package/dist/util/index.d.ts +3 -1
- package/dist/util/index.js +14 -4
- package/dist/util/index.js.map +1 -1
- package/package.json +6 -6
- package/src/databases/all/db_index.spec.ts +1 -1
- package/src/databases/all/expr.spec.ts +0 -48
- package/src/databases/bigquery/handexpr.spec.ts +53 -48
- package/src/databases/bigquery/malloy_query.spec.ts +42 -32
- package/src/databases/bigquery-duckdb/nested_source_table.spec.ts +2 -2
- package/src/models/faa_model.ts +80 -81
- package/src/models/medicare_model.ts +33 -17
- package/src/tags.spec.ts +19 -1
- package/src/util/index.ts +19 -3
package/src/models/faa_model.ts
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
import {ModelDef, StructDef, StructRelationship} from '@malloydata/malloy';
|
|
25
25
|
|
|
26
|
-
import {fStringEq, fYearEq} from '../util';
|
|
26
|
+
import {fStringEq, fToIF, fToQF, fYearEq} from '../util';
|
|
27
27
|
|
|
28
28
|
import {medicareModel, medicareStateFacts} from './medicare_model';
|
|
29
29
|
|
|
@@ -32,9 +32,9 @@ function withJoin(leftKey: string, rightKey: string): StructRelationship {
|
|
|
32
32
|
type: 'one',
|
|
33
33
|
matrixOperation: 'left',
|
|
34
34
|
onExpression: [
|
|
35
|
-
{type: 'field', path:
|
|
35
|
+
{type: 'field', path: leftKey.split('.')},
|
|
36
36
|
'=',
|
|
37
|
-
{type: 'field', path:
|
|
37
|
+
{type: 'field', path: rightKey.split('.')},
|
|
38
38
|
],
|
|
39
39
|
};
|
|
40
40
|
}
|
|
@@ -82,7 +82,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
82
82
|
{
|
|
83
83
|
type: 'aggregate',
|
|
84
84
|
function: 'sum',
|
|
85
|
-
e: [{type: 'field', path: 'distance'}],
|
|
85
|
+
e: [{type: 'field', path: ['distance']}],
|
|
86
86
|
},
|
|
87
87
|
],
|
|
88
88
|
},
|
|
@@ -101,9 +101,9 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
101
101
|
type: 'one',
|
|
102
102
|
matrixOperation: 'left',
|
|
103
103
|
onExpression: [
|
|
104
|
-
{type: 'field', path: 'carrier'},
|
|
104
|
+
{type: 'field', path: ['carrier']},
|
|
105
105
|
'=',
|
|
106
|
-
{type: 'field', path: 'carriers
|
|
106
|
+
{type: 'field', path: ['carriers', 'code']},
|
|
107
107
|
],
|
|
108
108
|
},
|
|
109
109
|
primaryKey: 'code',
|
|
@@ -174,7 +174,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
174
174
|
{
|
|
175
175
|
type: 'aggregate',
|
|
176
176
|
function: 'sum',
|
|
177
|
-
e: [{type: 'field', path: 'aircraft_models
|
|
177
|
+
e: [{type: 'field', path: ['aircraft_models', 'engines']}],
|
|
178
178
|
},
|
|
179
179
|
],
|
|
180
180
|
},
|
|
@@ -226,7 +226,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
226
226
|
{
|
|
227
227
|
type: 'aggregate',
|
|
228
228
|
function: 'sum',
|
|
229
|
-
e: [{type: 'field', path: 'seats'}],
|
|
229
|
+
e: [{type: 'field', path: ['seats']}],
|
|
230
230
|
},
|
|
231
231
|
],
|
|
232
232
|
},
|
|
@@ -347,7 +347,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
347
347
|
pipeline: [
|
|
348
348
|
{
|
|
349
349
|
type: 'reduce',
|
|
350
|
-
|
|
350
|
+
queryFields: fToQF([
|
|
351
351
|
'tail_num',
|
|
352
352
|
{
|
|
353
353
|
type: 'number',
|
|
@@ -357,11 +357,11 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
357
357
|
{
|
|
358
358
|
type: 'aggregate',
|
|
359
359
|
function: 'sum',
|
|
360
|
-
e: [{type: 'field', path: 'distance'}],
|
|
360
|
+
e: [{type: 'field', path: ['distance']}],
|
|
361
361
|
},
|
|
362
362
|
],
|
|
363
363
|
},
|
|
364
|
-
],
|
|
364
|
+
]),
|
|
365
365
|
},
|
|
366
366
|
],
|
|
367
367
|
},
|
|
@@ -374,33 +374,13 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
374
374
|
],
|
|
375
375
|
},
|
|
376
376
|
|
|
377
|
-
// // Inline derived table
|
|
378
|
-
// {
|
|
379
|
-
// type: 'struct',
|
|
380
|
-
// name: "aircraft_facts2",
|
|
381
|
-
// structSource: {
|
|
382
|
-
// type: 'query',
|
|
383
|
-
// query: {
|
|
384
|
-
// type: 'reduce',
|
|
385
|
-
// fields: [
|
|
386
|
-
// 'tail_num',
|
|
387
|
-
// {name: 'total_distance', as: 'lifetime_distance'}
|
|
388
|
-
// ]
|
|
389
|
-
// }
|
|
390
|
-
// },
|
|
391
|
-
// structRelationship: {type: 'foreignKey', keyExpression: [{ type: "field", path: 'tail_num'},
|
|
392
|
-
// fields: [
|
|
393
|
-
// ]
|
|
394
|
-
// },
|
|
395
|
-
// query definition
|
|
396
|
-
// EXPLORE flights | REDUCE carriers.name, flight_count ORDER BY 1
|
|
397
377
|
{
|
|
398
378
|
type: 'turtle',
|
|
399
379
|
name: 'flights_by_carrier',
|
|
400
380
|
pipeline: [
|
|
401
381
|
{
|
|
402
382
|
type: 'reduce',
|
|
403
|
-
|
|
383
|
+
queryFields: fToQF([
|
|
404
384
|
'carriers.name',
|
|
405
385
|
'flight_count',
|
|
406
386
|
// { name: "origin.count", as: "origin_count" },
|
|
@@ -413,7 +393,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
413
393
|
type: 'aggregate',
|
|
414
394
|
function: 'count',
|
|
415
395
|
e: [],
|
|
416
|
-
structPath: 'origin',
|
|
396
|
+
structPath: ['origin'],
|
|
417
397
|
},
|
|
418
398
|
],
|
|
419
399
|
},
|
|
@@ -425,11 +405,11 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
425
405
|
{
|
|
426
406
|
type: 'aggregate',
|
|
427
407
|
function: 'sum',
|
|
428
|
-
e: [{type: 'field', path: 'distance'}],
|
|
408
|
+
e: [{type: 'field', path: ['distance']}],
|
|
429
409
|
},
|
|
430
410
|
],
|
|
431
411
|
},
|
|
432
|
-
],
|
|
412
|
+
]),
|
|
433
413
|
orderBy: [{field: 'name', dir: 'asc'}],
|
|
434
414
|
},
|
|
435
415
|
],
|
|
@@ -441,7 +421,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
441
421
|
{
|
|
442
422
|
type: 'reduce',
|
|
443
423
|
|
|
444
|
-
|
|
424
|
+
queryFields: fToQF([
|
|
445
425
|
'carriers.name',
|
|
446
426
|
{
|
|
447
427
|
name: 'flights_2001',
|
|
@@ -479,7 +459,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
479
459
|
},
|
|
480
460
|
],
|
|
481
461
|
},
|
|
482
|
-
],
|
|
462
|
+
]),
|
|
483
463
|
orderBy: [{field: 'name', dir: 'asc'}],
|
|
484
464
|
},
|
|
485
465
|
],
|
|
@@ -491,7 +471,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
491
471
|
pipeline: [
|
|
492
472
|
{
|
|
493
473
|
type: 'reduce',
|
|
494
|
-
|
|
474
|
+
queryFields: fToQF(['destination.city', 'flight_count']),
|
|
495
475
|
orderBy: [{field: 2, dir: 'desc'}],
|
|
496
476
|
limit: 5,
|
|
497
477
|
},
|
|
@@ -505,12 +485,12 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
505
485
|
pipeline: [
|
|
506
486
|
{
|
|
507
487
|
type: 'reduce',
|
|
508
|
-
|
|
488
|
+
queryFields: fToQF([
|
|
509
489
|
'aircraft.aircraft_models.manufacturer',
|
|
510
490
|
'aircraft.aircraft_models.model',
|
|
511
491
|
'aircraft.aircraft_count',
|
|
512
492
|
'flight_count',
|
|
513
|
-
],
|
|
493
|
+
]),
|
|
514
494
|
orderBy: [{field: 'flight_count', dir: 'desc'}],
|
|
515
495
|
filterList: [fStringEq('origin.state', 'CA')],
|
|
516
496
|
limit: 5,
|
|
@@ -525,7 +505,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
525
505
|
{
|
|
526
506
|
type: 'reduce',
|
|
527
507
|
|
|
528
|
-
|
|
508
|
+
queryFields: fToQF([
|
|
529
509
|
'tail_num',
|
|
530
510
|
{
|
|
531
511
|
type: 'number',
|
|
@@ -535,11 +515,11 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
535
515
|
{
|
|
536
516
|
type: 'aggregate',
|
|
537
517
|
function: 'sum',
|
|
538
|
-
e: [{type: 'field', path: 'distance'}],
|
|
518
|
+
e: [{type: 'field', path: ['distance']}],
|
|
539
519
|
},
|
|
540
520
|
],
|
|
541
521
|
},
|
|
542
|
-
],
|
|
522
|
+
]),
|
|
543
523
|
},
|
|
544
524
|
],
|
|
545
525
|
},
|
|
@@ -550,7 +530,11 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
550
530
|
pipeline: [
|
|
551
531
|
{
|
|
552
532
|
type: 'reduce',
|
|
553
|
-
|
|
533
|
+
queryFields: fToQF([
|
|
534
|
+
'carriers.name',
|
|
535
|
+
'aircraft.total_engines',
|
|
536
|
+
'flight_count',
|
|
537
|
+
]),
|
|
554
538
|
},
|
|
555
539
|
],
|
|
556
540
|
},
|
|
@@ -561,7 +545,10 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
561
545
|
pipeline: [
|
|
562
546
|
{
|
|
563
547
|
type: 'reduce',
|
|
564
|
-
|
|
548
|
+
queryFields: fToQF([
|
|
549
|
+
'aircraft_facts.lifetime_distance',
|
|
550
|
+
'flight_count',
|
|
551
|
+
]),
|
|
565
552
|
},
|
|
566
553
|
],
|
|
567
554
|
},
|
|
@@ -572,7 +559,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
572
559
|
pipeline: [
|
|
573
560
|
{
|
|
574
561
|
type: 'reduce',
|
|
575
|
-
|
|
562
|
+
queryFields: fToQF(['flight_count', 'origin.city', 'origin.state']),
|
|
576
563
|
},
|
|
577
564
|
],
|
|
578
565
|
},
|
|
@@ -592,7 +579,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
592
579
|
pipeline: [
|
|
593
580
|
{
|
|
594
581
|
type: 'reduce',
|
|
595
|
-
|
|
582
|
+
queryFields: fToQF([
|
|
596
583
|
'carrier',
|
|
597
584
|
'flight_count',
|
|
598
585
|
{
|
|
@@ -601,13 +588,17 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
601
588
|
pipeline: [
|
|
602
589
|
{
|
|
603
590
|
type: 'reduce',
|
|
604
|
-
|
|
591
|
+
queryFields: fToQF([
|
|
592
|
+
'origin_code',
|
|
593
|
+
'destination_code',
|
|
594
|
+
'flight_count',
|
|
595
|
+
]),
|
|
605
596
|
limit: 5,
|
|
606
597
|
orderBy: [{field: 'flight_count', dir: 'desc'}],
|
|
607
598
|
},
|
|
608
599
|
],
|
|
609
600
|
},
|
|
610
|
-
],
|
|
601
|
+
]),
|
|
611
602
|
},
|
|
612
603
|
],
|
|
613
604
|
},
|
|
@@ -622,7 +613,11 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
622
613
|
pipeline: [
|
|
623
614
|
{
|
|
624
615
|
type: 'reduce',
|
|
625
|
-
|
|
616
|
+
queryFields: fToQF([
|
|
617
|
+
'origin_code',
|
|
618
|
+
'destination_code',
|
|
619
|
+
'flight_count',
|
|
620
|
+
]),
|
|
626
621
|
limit: 5,
|
|
627
622
|
orderBy: [{field: 'flight_count', dir: 'desc'}],
|
|
628
623
|
},
|
|
@@ -635,7 +630,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
635
630
|
pipeline: [
|
|
636
631
|
{
|
|
637
632
|
type: 'reduce',
|
|
638
|
-
|
|
633
|
+
queryFields: fToQF(['carrier', 'flight_count', 'top_5_routes']),
|
|
639
634
|
},
|
|
640
635
|
],
|
|
641
636
|
},
|
|
@@ -646,7 +641,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
646
641
|
pipeline: [
|
|
647
642
|
{
|
|
648
643
|
type: 'reduce',
|
|
649
|
-
|
|
644
|
+
queryFields: fToQF(['destination.code', 'flight_count']),
|
|
650
645
|
filterList: [fStringEq('destination.state', 'NY')],
|
|
651
646
|
orderBy: [{field: 'flight_count', dir: 'desc'}],
|
|
652
647
|
},
|
|
@@ -659,11 +654,11 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
659
654
|
pipeline: [
|
|
660
655
|
{
|
|
661
656
|
type: 'reduce',
|
|
662
|
-
|
|
657
|
+
queryFields: fToQF([
|
|
663
658
|
'aircraft.aircraft_models.manufacturer',
|
|
664
659
|
'aircraft.aircraft_count',
|
|
665
660
|
'flight_count',
|
|
666
|
-
],
|
|
661
|
+
]),
|
|
667
662
|
orderBy: [{field: 'flight_count', dir: 'desc'}],
|
|
668
663
|
limit: 5,
|
|
669
664
|
},
|
|
@@ -676,12 +671,12 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
676
671
|
pipeline: [
|
|
677
672
|
{
|
|
678
673
|
type: 'reduce',
|
|
679
|
-
|
|
674
|
+
queryFields: fToQF([
|
|
680
675
|
'carrier',
|
|
681
676
|
'flight_count',
|
|
682
677
|
'top_5_routes',
|
|
683
678
|
'flights_by_manufacturer',
|
|
684
|
-
],
|
|
679
|
+
]),
|
|
685
680
|
filterList: [fStringEq('origin.state', 'CA')],
|
|
686
681
|
},
|
|
687
682
|
],
|
|
@@ -692,12 +687,12 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
692
687
|
pipeline: [
|
|
693
688
|
{
|
|
694
689
|
type: 'reduce',
|
|
695
|
-
|
|
690
|
+
queryFields: fToQF([
|
|
696
691
|
'origin_code',
|
|
697
692
|
'destination_code',
|
|
698
693
|
'flight_count',
|
|
699
694
|
'flights_by_carrier',
|
|
700
|
-
],
|
|
695
|
+
]),
|
|
701
696
|
limit: 5,
|
|
702
697
|
orderBy: [{field: 'flight_count', dir: 'desc'}],
|
|
703
698
|
},
|
|
@@ -710,14 +705,14 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
710
705
|
{
|
|
711
706
|
type: 'reduce',
|
|
712
707
|
filterList: [fStringEq('origin.state', 'CA')],
|
|
713
|
-
|
|
708
|
+
queryFields: fToQF([
|
|
714
709
|
{
|
|
715
710
|
type: 'turtle',
|
|
716
711
|
name: 'main',
|
|
717
712
|
pipeline: [
|
|
718
713
|
{
|
|
719
714
|
type: 'reduce',
|
|
720
|
-
|
|
715
|
+
queryFields: fToQF([
|
|
721
716
|
'carriers.name',
|
|
722
717
|
'flight_count',
|
|
723
718
|
//{ name: "origin.count", as: "origin_count" },
|
|
@@ -730,11 +725,11 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
730
725
|
type: 'aggregate',
|
|
731
726
|
function: 'count',
|
|
732
727
|
e: [],
|
|
733
|
-
structPath: 'origin',
|
|
728
|
+
structPath: ['origin'],
|
|
734
729
|
},
|
|
735
730
|
],
|
|
736
731
|
},
|
|
737
|
-
],
|
|
732
|
+
]),
|
|
738
733
|
orderBy: [{field: 'flight_count', dir: 'desc'}],
|
|
739
734
|
},
|
|
740
735
|
],
|
|
@@ -745,11 +740,11 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
745
740
|
pipeline: [
|
|
746
741
|
{
|
|
747
742
|
type: 'reduce',
|
|
748
|
-
|
|
743
|
+
queryFields: fToQF(['flight_count']),
|
|
749
744
|
},
|
|
750
745
|
],
|
|
751
746
|
},
|
|
752
|
-
],
|
|
747
|
+
]),
|
|
753
748
|
},
|
|
754
749
|
],
|
|
755
750
|
},
|
|
@@ -760,7 +755,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
760
755
|
{
|
|
761
756
|
type: 'reduce',
|
|
762
757
|
orderBy: [{field: 'dep_time', dir: 'asc'}],
|
|
763
|
-
|
|
758
|
+
queryFields: fToQF([
|
|
764
759
|
'id2',
|
|
765
760
|
'dep_time',
|
|
766
761
|
'tail_num',
|
|
@@ -769,7 +764,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
769
764
|
'destination_code',
|
|
770
765
|
'distance',
|
|
771
766
|
'dep_delay',
|
|
772
|
-
],
|
|
767
|
+
]),
|
|
773
768
|
limit: 500,
|
|
774
769
|
},
|
|
775
770
|
],
|
|
@@ -780,7 +775,11 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
780
775
|
pipeline: [
|
|
781
776
|
{
|
|
782
777
|
type: 'reduce',
|
|
783
|
-
|
|
778
|
+
queryFields: fToQF([
|
|
779
|
+
'flight_count',
|
|
780
|
+
'total_distance',
|
|
781
|
+
'aircraft.aircraft_count',
|
|
782
|
+
]),
|
|
784
783
|
},
|
|
785
784
|
],
|
|
786
785
|
},
|
|
@@ -795,7 +794,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
795
794
|
fStringEq('carrier', 'UA'),
|
|
796
795
|
],
|
|
797
796
|
limit: 20,
|
|
798
|
-
|
|
797
|
+
queryFields: fToQF([
|
|
799
798
|
{
|
|
800
799
|
type: 'timestamp',
|
|
801
800
|
name: 'dep_time',
|
|
@@ -809,7 +808,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
809
808
|
pipeline: [
|
|
810
809
|
{
|
|
811
810
|
type: 'reduce',
|
|
812
|
-
|
|
811
|
+
queryFields: fToQF([
|
|
813
812
|
'origin_code',
|
|
814
813
|
'destination_code',
|
|
815
814
|
'flight_count',
|
|
@@ -821,22 +820,22 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
821
820
|
type: 'reduce',
|
|
822
821
|
orderBy: [{field: 'dep_time', dir: 'asc'}],
|
|
823
822
|
limit: 5,
|
|
824
|
-
|
|
823
|
+
queryFields: fToQF([
|
|
825
824
|
'id2',
|
|
826
825
|
'dep_time',
|
|
827
826
|
'tail_num',
|
|
828
827
|
'flight_num',
|
|
829
828
|
'dep_delay',
|
|
830
|
-
],
|
|
829
|
+
]),
|
|
831
830
|
},
|
|
832
831
|
],
|
|
833
832
|
},
|
|
834
|
-
],
|
|
833
|
+
]),
|
|
835
834
|
orderBy: [{field: 'flight_count', dir: 'desc'}],
|
|
836
835
|
},
|
|
837
836
|
],
|
|
838
837
|
},
|
|
839
|
-
],
|
|
838
|
+
]),
|
|
840
839
|
},
|
|
841
840
|
],
|
|
842
841
|
},
|
|
@@ -863,7 +862,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
863
862
|
type: 'reduce',
|
|
864
863
|
filterList: [fStringEq('carrier', 'UA')],
|
|
865
864
|
limit: 2,
|
|
866
|
-
|
|
865
|
+
queryFields: fToQF([
|
|
867
866
|
{
|
|
868
867
|
type: 'timestamp',
|
|
869
868
|
name: 'dep_time',
|
|
@@ -879,7 +878,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
879
878
|
{
|
|
880
879
|
type: 'reduce',
|
|
881
880
|
limit: 10,
|
|
882
|
-
|
|
881
|
+
queryFields: fToQF([
|
|
883
882
|
'tail_num',
|
|
884
883
|
'flight_count',
|
|
885
884
|
{
|
|
@@ -889,23 +888,23 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
889
888
|
{
|
|
890
889
|
type: 'reduce',
|
|
891
890
|
orderBy: [{field: 'dep_time', dir: 'asc'}],
|
|
892
|
-
|
|
891
|
+
queryFields: fToQF([
|
|
893
892
|
'id2',
|
|
894
893
|
'dep_time',
|
|
895
894
|
'origin_code',
|
|
896
895
|
'destination_code',
|
|
897
896
|
'flight_num',
|
|
898
897
|
'dep_delay',
|
|
899
|
-
],
|
|
898
|
+
]),
|
|
900
899
|
},
|
|
901
900
|
],
|
|
902
901
|
},
|
|
903
|
-
],
|
|
902
|
+
]),
|
|
904
903
|
orderBy: [{field: 'flight_count', dir: 'desc'}],
|
|
905
904
|
},
|
|
906
905
|
],
|
|
907
906
|
},
|
|
908
|
-
],
|
|
907
|
+
]),
|
|
909
908
|
},
|
|
910
909
|
],
|
|
911
910
|
},
|
|
@@ -916,7 +915,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
916
915
|
{
|
|
917
916
|
type: 'index',
|
|
918
917
|
weightMeasure: 'flight_count',
|
|
919
|
-
|
|
918
|
+
indexFields: fToIF([
|
|
920
919
|
'carrier',
|
|
921
920
|
'origin_code',
|
|
922
921
|
'destination_code',
|
|
@@ -934,7 +933,7 @@ export const FLIGHTS_EXPLORE: StructDef = {
|
|
|
934
933
|
'aircraft.aircraft_model_code',
|
|
935
934
|
'aircraft.aircraft_models.manufacturer',
|
|
936
935
|
'aircraft.aircraft_models.model',
|
|
937
|
-
],
|
|
936
|
+
]),
|
|
938
937
|
},
|
|
939
938
|
],
|
|
940
939
|
},
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import {StructDef} from '@malloydata/malloy';
|
|
25
|
+
import {fToQF} from '../util';
|
|
25
26
|
|
|
26
27
|
// will it build?
|
|
27
28
|
|
|
@@ -71,7 +72,7 @@ export const medicareModel: StructDef = {
|
|
|
71
72
|
type: 'number',
|
|
72
73
|
name: 'provider_count',
|
|
73
74
|
expressionType: 'aggregate',
|
|
74
|
-
e: ['COUNT(DISTINCT ', {type: 'field', path: 'provider_id'}, ')'],
|
|
75
|
+
e: ['COUNT(DISTINCT ', {type: 'field', path: ['provider_id']}, ')'],
|
|
75
76
|
},
|
|
76
77
|
{
|
|
77
78
|
type: 'number',
|
|
@@ -81,7 +82,7 @@ export const medicareModel: StructDef = {
|
|
|
81
82
|
{
|
|
82
83
|
type: 'aggregate',
|
|
83
84
|
function: 'sum',
|
|
84
|
-
e: [{type: 'field', path: 'discharges'}],
|
|
85
|
+
e: [{type: 'field', path: ['discharges']}],
|
|
85
86
|
},
|
|
86
87
|
],
|
|
87
88
|
},
|
|
@@ -91,7 +92,7 @@ export const medicareModel: StructDef = {
|
|
|
91
92
|
name: 'discharges_by_state',
|
|
92
93
|
pipeline: [
|
|
93
94
|
{
|
|
94
|
-
|
|
95
|
+
queryFields: fToQF(['provider_state', 'total_discharges']),
|
|
95
96
|
orderBy: [{dir: 'desc', field: 2}],
|
|
96
97
|
type: 'reduce',
|
|
97
98
|
},
|
|
@@ -102,7 +103,7 @@ export const medicareModel: StructDef = {
|
|
|
102
103
|
name: 'discharges_by_city',
|
|
103
104
|
pipeline: [
|
|
104
105
|
{
|
|
105
|
-
|
|
106
|
+
queryFields: fToQF(['provider_city', 'total_discharges']),
|
|
106
107
|
orderBy: [{dir: 'desc', field: 2}],
|
|
107
108
|
type: 'reduce',
|
|
108
109
|
},
|
|
@@ -113,12 +114,12 @@ export const medicareModel: StructDef = {
|
|
|
113
114
|
name: 'bigturtle_state',
|
|
114
115
|
pipeline: [
|
|
115
116
|
{
|
|
116
|
-
|
|
117
|
+
queryFields: fToQF([
|
|
117
118
|
'provider_state',
|
|
118
119
|
'total_discharges',
|
|
119
120
|
'discharges_by_city',
|
|
120
121
|
'discharges_by_zip',
|
|
121
|
-
],
|
|
122
|
+
]),
|
|
122
123
|
orderBy: [{dir: 'desc', field: 1}],
|
|
123
124
|
type: 'reduce',
|
|
124
125
|
},
|
|
@@ -129,7 +130,7 @@ export const medicareModel: StructDef = {
|
|
|
129
130
|
name: 'discharges_by_zip',
|
|
130
131
|
pipeline: [
|
|
131
132
|
{
|
|
132
|
-
|
|
133
|
+
queryFields: fToQF(['provider_zipcode', 'total_discharges']),
|
|
133
134
|
orderBy: [{dir: 'desc', field: 2}],
|
|
134
135
|
type: 'reduce',
|
|
135
136
|
},
|
|
@@ -140,7 +141,11 @@ export const medicareModel: StructDef = {
|
|
|
140
141
|
name: 'turtle_city_zip',
|
|
141
142
|
pipeline: [
|
|
142
143
|
{
|
|
143
|
-
|
|
144
|
+
queryFields: fToQF([
|
|
145
|
+
'provider_city',
|
|
146
|
+
'total_discharges',
|
|
147
|
+
'discharges_by_zip',
|
|
148
|
+
]),
|
|
144
149
|
orderBy: [{dir: 'desc', field: 1}],
|
|
145
150
|
type: 'reduce',
|
|
146
151
|
},
|
|
@@ -151,7 +156,11 @@ export const medicareModel: StructDef = {
|
|
|
151
156
|
name: 'triple_turtle',
|
|
152
157
|
pipeline: [
|
|
153
158
|
{
|
|
154
|
-
|
|
159
|
+
queryFields: fToQF([
|
|
160
|
+
'provider_state',
|
|
161
|
+
'total_discharges',
|
|
162
|
+
'turtle_city_zip',
|
|
163
|
+
]),
|
|
155
164
|
orderBy: [{dir: 'desc', field: 1}],
|
|
156
165
|
type: 'reduce',
|
|
157
166
|
},
|
|
@@ -162,7 +171,7 @@ export const medicareModel: StructDef = {
|
|
|
162
171
|
name: 'rollup_by_location',
|
|
163
172
|
pipeline: [
|
|
164
173
|
{
|
|
165
|
-
|
|
174
|
+
queryFields: fToQF([
|
|
166
175
|
'provider_state',
|
|
167
176
|
'total_discharges',
|
|
168
177
|
{
|
|
@@ -170,7 +179,7 @@ export const medicareModel: StructDef = {
|
|
|
170
179
|
name: 'turtle_city_zip',
|
|
171
180
|
pipeline: [
|
|
172
181
|
{
|
|
173
|
-
|
|
182
|
+
queryFields: fToQF([
|
|
174
183
|
'provider_city',
|
|
175
184
|
'total_discharges',
|
|
176
185
|
{
|
|
@@ -178,19 +187,22 @@ export const medicareModel: StructDef = {
|
|
|
178
187
|
name: 'discharges_by_zip',
|
|
179
188
|
pipeline: [
|
|
180
189
|
{
|
|
181
|
-
|
|
190
|
+
queryFields: fToQF([
|
|
191
|
+
'provider_zipcode',
|
|
192
|
+
'total_discharges',
|
|
193
|
+
]),
|
|
182
194
|
orderBy: [{dir: 'desc', field: 2}],
|
|
183
195
|
type: 'reduce',
|
|
184
196
|
},
|
|
185
197
|
],
|
|
186
198
|
},
|
|
187
|
-
],
|
|
199
|
+
]),
|
|
188
200
|
orderBy: [{dir: 'desc', field: 1}],
|
|
189
201
|
type: 'reduce',
|
|
190
202
|
},
|
|
191
203
|
],
|
|
192
204
|
},
|
|
193
|
-
],
|
|
205
|
+
]),
|
|
194
206
|
orderBy: [{dir: 'desc', field: 1}],
|
|
195
207
|
type: 'reduce',
|
|
196
208
|
},
|
|
@@ -217,15 +229,19 @@ export const medicareStateFacts: StructDef = {
|
|
|
217
229
|
structRef: 'medicare_test',
|
|
218
230
|
pipeline: [
|
|
219
231
|
{
|
|
220
|
-
|
|
232
|
+
queryFields: fToQF([
|
|
221
233
|
'provider_state',
|
|
222
234
|
{
|
|
223
235
|
type: 'number',
|
|
224
236
|
name: 'num_providers',
|
|
225
237
|
expressionType: 'aggregate',
|
|
226
|
-
e: [
|
|
238
|
+
e: [
|
|
239
|
+
'COUNT(DISTINCT ',
|
|
240
|
+
{type: 'field', path: ['provider_id']},
|
|
241
|
+
')',
|
|
242
|
+
],
|
|
227
243
|
},
|
|
228
|
-
],
|
|
244
|
+
]),
|
|
229
245
|
type: 'reduce',
|
|
230
246
|
},
|
|
231
247
|
],
|