@malloydata/malloy-tests 0.0.95-dev231019211822 → 0.0.95

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.
Files changed (84) hide show
  1. package/README.md +213 -1
  2. package/dist/api.spec.d.ts +1 -1
  3. package/dist/api.spec.js +6 -13
  4. package/dist/api.spec.js.map +1 -1
  5. package/dist/databases/all/db_index.spec.js +21 -41
  6. package/dist/databases/all/db_index.spec.js.map +1 -1
  7. package/dist/databases/all/expr.spec.js +262 -339
  8. package/dist/databases/all/expr.spec.js.map +1 -1
  9. package/dist/databases/all/functions.spec.js +37 -35
  10. package/dist/databases/all/functions.spec.js.map +1 -1
  11. package/dist/databases/all/join.spec.js +125 -169
  12. package/dist/databases/all/join.spec.js.map +1 -1
  13. package/dist/databases/all/nomodel.spec.js +335 -594
  14. package/dist/databases/all/nomodel.spec.js.map +1 -1
  15. package/dist/databases/all/orderby.spec.js +82 -128
  16. package/dist/databases/all/orderby.spec.js.map +1 -1
  17. package/dist/databases/all/sql_expressions.spec.js +27 -43
  18. package/dist/databases/all/sql_expressions.spec.js.map +1 -1
  19. package/dist/databases/all/time.spec.js +63 -103
  20. package/dist/databases/all/time.spec.js.map +1 -1
  21. package/dist/databases/bigquery/double_truncation.spec.js +1 -1
  22. package/dist/databases/bigquery/handexpr.spec.js +12 -12
  23. package/dist/databases/bigquery/injestion_time_partitioning.spec.js +22 -22
  24. package/dist/databases/bigquery/joined_filters.spec.js +3 -3
  25. package/dist/databases/bigquery/json.spec.d.ts +1 -1
  26. package/dist/databases/bigquery/json.spec.js +25 -45
  27. package/dist/databases/bigquery/json.spec.js.map +1 -1
  28. package/dist/databases/bigquery/malloy_query.spec.d.ts +1 -1
  29. package/dist/databases/bigquery/malloy_query.spec.js +47 -48
  30. package/dist/databases/bigquery/malloy_query.spec.js.map +1 -1
  31. package/dist/databases/bigquery/time.spec.js +9 -13
  32. package/dist/databases/bigquery/time.spec.js.map +1 -1
  33. package/dist/databases/bigquery/wildcard_table_names.spec.js +19 -19
  34. package/dist/databases/bigquery-duckdb/nested_source_table.spec.js +53 -87
  35. package/dist/databases/bigquery-duckdb/nested_source_table.spec.js.map +1 -1
  36. package/dist/databases/bigquery-postgres/multi_connection.spec.js +5 -20
  37. package/dist/databases/bigquery-postgres/multi_connection.spec.js.map +1 -1
  38. package/dist/databases/bigquery-postgres/streaming.spec.js +6 -6
  39. package/dist/databases/bigquery-postgres/streaming.spec.js.map +1 -1
  40. package/dist/databases/duckdb/duckdb.spec.js +24 -33
  41. package/dist/databases/duckdb/duckdb.spec.js.map +1 -1
  42. package/dist/databases/postgres/postgres.spec.js +46 -67
  43. package/dist/databases/postgres/postgres.spec.js.map +1 -1
  44. package/dist/jestMatcher.spec.d.ts +1 -0
  45. package/dist/jestMatcher.spec.js +81 -0
  46. package/dist/jestMatcher.spec.js.map +1 -0
  47. package/dist/render/render.spec.js +10 -12
  48. package/dist/render/render.spec.js.map +1 -1
  49. package/dist/tags.spec.js +22 -2
  50. package/dist/tags.spec.js.map +1 -1
  51. package/dist/util/db-jest-matchers.d.ts +17 -6
  52. package/dist/util/db-jest-matchers.js +81 -20
  53. package/dist/util/db-jest-matchers.js.map +1 -1
  54. package/dist/util/index.d.ts +1 -2
  55. package/dist/util/index.js +11 -13
  56. package/dist/util/index.js.map +1 -1
  57. package/package.json +6 -6
  58. package/src/api.spec.ts +7 -16
  59. package/src/databases/all/db_index.spec.ts +22 -48
  60. package/src/databases/all/expr.spec.ts +273 -431
  61. package/src/databases/all/functions.spec.ts +37 -35
  62. package/src/databases/all/join.spec.ts +130 -196
  63. package/src/databases/all/nomodel.spec.ts +333 -689
  64. package/src/databases/all/orderby.spec.ts +87 -161
  65. package/src/databases/all/sql_expressions.spec.ts +29 -49
  66. package/src/databases/all/time.spec.ts +73 -130
  67. package/src/databases/bigquery/double_truncation.spec.ts +1 -1
  68. package/src/databases/bigquery/handexpr.spec.ts +12 -12
  69. package/src/databases/bigquery/injestion_time_partitioning.spec.ts +22 -22
  70. package/src/databases/bigquery/joined_filters.spec.ts +3 -3
  71. package/src/databases/bigquery/json.spec.ts +25 -49
  72. package/src/databases/bigquery/malloy_query.spec.ts +47 -54
  73. package/src/databases/bigquery/time.spec.ts +13 -17
  74. package/src/databases/bigquery/wildcard_table_names.spec.ts +19 -19
  75. package/src/databases/bigquery-duckdb/nested_source_table.spec.ts +56 -98
  76. package/src/databases/bigquery-postgres/multi_connection.spec.ts +5 -23
  77. package/src/databases/bigquery-postgres/streaming.spec.ts +12 -6
  78. package/src/databases/duckdb/duckdb.spec.ts +31 -43
  79. package/src/databases/postgres/postgres.spec.ts +54 -84
  80. package/src/jestMatcher.spec.ts +88 -0
  81. package/src/render/render.spec.ts +10 -12
  82. package/src/tags.spec.ts +22 -2
  83. package/src/util/db-jest-matchers.ts +106 -32
  84. package/src/util/index.ts +16 -14
@@ -25,27 +25,19 @@
25
25
 
26
26
  import {describeIfDatabaseAvailable} from '../../util';
27
27
  import {RuntimeList} from '../../runtimes';
28
+ import '../../util/db-jest-matchers';
28
29
 
29
30
  const [describe] = describeIfDatabaseAvailable(['bigquery']);
30
31
 
31
- const modelString = `
32
- sql: source_sql is {
33
- select: """
34
- SELECT *
35
- FROM UNNEST([
36
- STRUCT( JSON '{"class_name": "A", "class" : {"students" : [{"name" : "Jane"}]}}' as j, 1 as r),
37
- STRUCT( JSON '{"class_name": "B", "class" : {"students" : []}}', 2),
38
- STRUCT( JSON '{"class_name": "C", "class" : {"students" : [{"name" : "John"}, {"name": "Jamie"}]}}', 3)
39
- ]) AS t
40
- """
41
- connection: "bigquery"
42
- }
43
-
44
- source: s is from_sql(source_sql) {
45
-
46
- }
47
-
48
- `;
32
+ const tJson = `
33
+ bigquery.sql("""
34
+ SELECT *
35
+ FROM UNNEST([
36
+ STRUCT( JSON '{"class_name": "A", "class" : {"students" : [{"name" : "Jane"}]}}' as j, 1 as r),
37
+ STRUCT( JSON '{"class_name": "B", "class" : {"students" : []}}', 2),
38
+ STRUCT( JSON '{"class_name": "C", "class" : {"students" : [{"name" : "John"}, {"name": "Jamie"}]}}', 3)
39
+ ]) AS t
40
+ """)`;
49
41
 
50
42
  describe('JSON tests', () => {
51
43
  const runtimes = new RuntimeList(['bigquery']);
@@ -57,39 +49,23 @@ describe('JSON tests', () => {
57
49
  runtimes.runtimeMap.forEach((runtime, databaseName) => {
58
50
  // Issue: #151
59
51
  it(`JSON Scalar - ${databaseName}`, async () => {
60
- //it(`model: do filters force dependant joins? - ${databaseName}`, async () => {
61
- const result = await runtime
62
- .loadQuery(
63
- `
64
- ${modelString}
65
-
66
- query: s-> {
67
- group_by: class_name is json_extract_scalar!(j, '$.class_name')
68
- order_by: 1 desc
69
- }
70
- `
71
- )
72
- .run();
73
- // console.log(result.data.toObject());
74
- expect(result.data.path(0, 'class_name').value).toBe('C');
52
+ await expect(`
53
+ run: ${tJson} -> {
54
+ group_by: class_name is json_extract_scalar!(j, '$.class_name')
55
+ order_by: 1 desc
56
+ }
57
+ `).malloyResultMatches(runtime, {class_name: 'C'});
75
58
  });
76
59
 
77
- it(`Return Json - ${databaseName}`, async () => {
78
- //it(`model: do filters force dependant joins? - ${databaseName}`, async () => {
79
- const result = await runtime
80
- .loadQuery(
81
- `
82
- ${modelString}
83
-
84
- query: s-> {
85
- select: j, r
86
- order_by: 2 desc
87
- }
88
- `
89
- )
90
- .run();
91
- // console.log(result.data.toObject());
92
- expect(result.data.path(0, 'j').value).toContain('Jamie');
60
+ it(`Returns JSON as value - ${databaseName}`, async () => {
61
+ await expect(`
62
+ run: ${tJson} -> {
63
+ select: j, r
64
+ order_by: 2 desc
65
+ }
66
+ `).malloyResultMatches(runtime, {
67
+ j: '{"class":{"students":[{"name":"John"},{"name":"Jamie"}]},"class_name":"C"}',
68
+ });
93
69
  });
94
70
  });
95
71
  });
@@ -27,6 +27,7 @@ import {Query} from '@malloydata/malloy';
27
27
  import {testModel} from '../../models/faa_model';
28
28
  import {BigQueryTestConnection, RuntimeList} from '../../runtimes';
29
29
  import {describeIfDatabaseAvailable, fStringEq} from '../../util';
30
+ import '../../util/db-jest-matchers';
30
31
 
31
32
  const runtimeList = new RuntimeList(['bigquery']);
32
33
  const runtime = runtimeList.runtimeMap.get('bigquery');
@@ -259,7 +260,7 @@ describe('BigQuery expression tests', () => {
259
260
  });
260
261
 
261
262
  it('flights_by_carrier', async () => {
262
- const sql = await compileQuery(faa, 'query: flights->flights_by_carrier');
263
+ const sql = await compileQuery(faa, 'run: flights->flights_by_carrier');
263
264
  await bqCompile(sql);
264
265
  });
265
266
 
@@ -424,50 +425,47 @@ describe('BigQuery expression tests', () => {
424
425
  });
425
426
 
426
427
  it('flights.flights_by_model', async () => {
427
- const sql = await compileQuery(faa, 'query: flights->flights_by_model');
428
+ const sql = await compileQuery(faa, 'run: flights->flights_by_model');
428
429
  await bqCompile(sql);
429
430
  });
430
431
 
431
432
  it('flights.aircraft_facts_test', async () => {
432
- const sql = await compileQuery(faa, 'query: flights->aircraft_facts_test');
433
+ const sql = await compileQuery(faa, 'run: flights->aircraft_facts_test');
433
434
  await bqCompile(sql);
434
435
  });
435
436
 
436
437
  it('flights.measures_first', async () => {
437
- const sql = await compileQuery(faa, 'query:flights->measures_first');
438
+ const sql = await compileQuery(faa, 'run:flights->measures_first');
438
439
  await bqCompile(sql);
439
440
  });
440
441
 
441
442
  it('flights.carriers_by_total_engines', async () => {
442
443
  const sql = await compileQuery(
443
444
  faa,
444
- 'query: flights->carriers_by_total_engines'
445
+ 'run: flights->carriers_by_total_engines'
445
446
  );
446
447
  await bqCompile(sql);
447
448
  });
448
449
 
449
450
  it('flights.first_turtle', async () => {
450
- const sql = await compileQuery(faa, 'query: flights->first_turtle');
451
+ const sql = await compileQuery(faa, 'run: flights->first_turtle');
451
452
  await bqCompile(sql);
452
453
  });
453
454
 
454
455
  it('flights.top_5_routes_carriers', async () => {
455
- const sql = await compileQuery(
456
- faa,
457
- 'query: flights->top_5_routes_carriers'
458
- );
456
+ const sql = await compileQuery(faa, 'run: flights->top_5_routes_carriers');
459
457
  await bqCompile(sql);
460
458
  });
461
459
 
462
460
  it('flights.new_york_airports', async () => {
463
- const sql = await compileQuery(faa, 'query: flights->new_york_airports');
461
+ const sql = await compileQuery(faa, 'run: flights->new_york_airports');
464
462
  await bqCompile(sql);
465
463
  });
466
464
 
467
465
  it('flights.flights_by_carrier_with_totals', async () => {
468
466
  const sql = await compileQuery(
469
467
  faa,
470
- 'query: flights->flights_by_carrier_with_totals'
468
+ 'run: flights->flights_by_carrier_with_totals'
471
469
  );
472
470
  await bqCompile(sql);
473
471
  });
@@ -517,7 +515,7 @@ describe('BigQuery expression tests', () => {
517
515
  });
518
516
 
519
517
  it('flights.search_index', async () => {
520
- const sql = await compileQuery(faa, 'query: flights->search_index');
518
+ const sql = await compileQuery(faa, 'run: flights->search_index');
521
519
  await bqCompile(sql);
522
520
  });
523
521
 
@@ -525,7 +523,7 @@ describe('BigQuery expression tests', () => {
525
523
  const result = await runQuery(
526
524
  faa,
527
525
  `
528
- query: table('malloytest.airports')->{
526
+ run: bigquery.table('malloytest.airports')->{
529
527
  where: faa_region ? ~'A%'
530
528
  order_by: 1
531
529
  group_by: faa_region
@@ -551,27 +549,24 @@ describe('BigQuery expression tests', () => {
551
549
  });
552
550
 
553
551
  it('flights.search_index', async () => {
554
- const sql = await compileQuery(faa, 'query: flights->search_index');
552
+ const sql = await compileQuery(faa, 'run: flights->search_index');
555
553
  await bqCompile(sql);
556
554
  });
557
555
 
558
556
  it('medicare_test.turtle_city_zip', async () => {
559
- const sql = await compileQuery(
560
- faa,
561
- 'query: medicare_test->turtle_city_zip'
562
- );
557
+ const sql = await compileQuery(faa, 'run: medicare_test->turtle_city_zip');
563
558
  await bqCompile(sql);
564
559
  });
565
560
 
566
561
  it('medicare_test.triple_turtle', async () => {
567
- const sql = await compileQuery(faa, 'query: medicare_test->triple_turtle');
562
+ const sql = await compileQuery(faa, 'run: medicare_test->triple_turtle');
568
563
  await bqCompile(sql);
569
564
  });
570
565
 
571
566
  it('medicare_test.rollup_by_location', async () => {
572
567
  const sql = await compileQuery(
573
568
  faa,
574
- 'query: medicare_test->rollup_by_location'
569
+ 'run: medicare_test->rollup_by_location'
575
570
  );
576
571
  await bqCompile(sql);
577
572
  });
@@ -579,7 +574,7 @@ describe('BigQuery expression tests', () => {
579
574
  it('flights.flights_routes_sessionized', async () => {
580
575
  const sql = await compileQuery(
581
576
  faa,
582
- 'query: flights->flights_routes_sessionized'
577
+ 'run: flights->flights_routes_sessionized'
583
578
  );
584
579
  await bqCompile(sql);
585
580
  });
@@ -587,7 +582,7 @@ describe('BigQuery expression tests', () => {
587
582
  it('flights.flights_aircraft_sessionized', async () => {
588
583
  const sql = await compileQuery(
589
584
  faa,
590
- 'query: flights->flights_aircraft_sessionized'
585
+ 'run: flights->flights_aircraft_sessionized'
591
586
  );
592
587
  await bqCompile(sql);
593
588
  });
@@ -595,7 +590,7 @@ describe('BigQuery expression tests', () => {
595
590
  it('flights.flights_by_manufacturer', async () => {
596
591
  const sql = await compileQuery(
597
592
  faa,
598
- 'query: flights->flights_by_manufacturer'
593
+ 'run: flights->flights_by_manufacturer'
599
594
  );
600
595
  await bqCompile(sql);
601
596
  });
@@ -603,7 +598,7 @@ describe('BigQuery expression tests', () => {
603
598
  it('flights.flights_by_carrier_2001_2002', async () => {
604
599
  const sql = await compileQuery(
605
600
  faa,
606
- 'query: flights->flights_by_carrier_2001_2002'
601
+ 'run: flights->flights_by_carrier_2001_2002'
607
602
  );
608
603
  await bqCompile(sql);
609
604
  });
@@ -612,7 +607,7 @@ describe('BigQuery expression tests', () => {
612
607
  const sql = await compileQuery(
613
608
  faa,
614
609
  `
615
- query: flights->{
610
+ run: flights->{
616
611
  group_by: mon is dep_time.month
617
612
  }
618
613
  `
@@ -624,7 +619,7 @@ describe('BigQuery expression tests', () => {
624
619
  const sql = await compileQuery(
625
620
  faa,
626
621
  `
627
- query: flights->{
622
+ run: flights->{
628
623
  aggregate: carrier_count is count(carrier)
629
624
  }
630
625
  `
@@ -690,27 +685,27 @@ describe('BigQuery expression tests', () => {
690
685
  });
691
686
 
692
687
  const airportModelText = `
693
- source: airports is table('malloy-data.malloytest.airports'){
688
+ source: airports is bigquery.table('malloy-data.malloytest.airports') extend {
694
689
  primary_key: code
695
690
  measure: airport_count is count()
696
691
 
697
- query: by_fac_type is {
692
+ view: by_fac_type is {
698
693
  group_by: fac_type
699
694
  aggregate: airport_count
700
695
  }
701
696
 
702
- query: by_state is {
697
+ view: by_state is {
703
698
  group_by: state
704
699
  aggregate: airport_count
705
700
  }
706
701
 
707
- query: by_county is {
702
+ view: by_county is {
708
703
  group_by: county
709
704
  aggregate: airport_count
710
705
  }
711
706
  }
712
707
 
713
- query: ca_airports is airports->by_fac_type{? state ? 'CA' | 'NY'}
708
+ query: ca_airports is airports->by_fac_type refine { where: state ? 'CA' | 'NY'}
714
709
  `;
715
710
 
716
711
  describe('airport_tests', () => {
@@ -723,7 +718,7 @@ describe('airport_tests', () => {
723
718
  const result = await runQuery(
724
719
  model,
725
720
  `
726
- query: airports->{
721
+ run: airports->{
727
722
  aggregate: a is count()
728
723
  }
729
724
  `
@@ -735,7 +730,7 @@ describe('airport_tests', () => {
735
730
  const result = await runQuery(
736
731
  model,
737
732
  `
738
- query: airports-> {
733
+ run: airports-> {
739
734
  nest: zero is {
740
735
  nest: by_faa_region_i is { where: county ~'I%' and state != NULL
741
736
  group_by: faa_region
@@ -775,7 +770,7 @@ describe('airport_tests', () => {
775
770
  const result = await runQuery(
776
771
  model,
777
772
  `
778
- query: airports -> {
773
+ run: airports -> {
779
774
  group_by: county
780
775
  nest: stuff is {
781
776
  select: elevation
@@ -796,7 +791,7 @@ describe('airport_tests', () => {
796
791
  const result = await runQuery(
797
792
  model,
798
793
  `
799
- query: airports->{
794
+ run: airports->{
800
795
  aggregate: airport_count
801
796
  nest: by_state is {
802
797
  group_by: state
@@ -823,14 +818,14 @@ describe('airport_tests', () => {
823
818
  const result = await runQuery(
824
819
  model,
825
820
  `
826
- source: my_airports is airports {
827
- query: pipe_turtle is {
821
+ source: my_airports is airports extend {
822
+ view: pipe_turtle is {
828
823
  aggregate: a is airport_count
829
824
  } -> {
830
825
  select: a
831
826
  }
832
827
  }
833
- query: my_airports->pipe_turtle
828
+ run: my_airports->pipe_turtle
834
829
  `
835
830
  );
836
831
  expect(result.data.value[0]['a']).toBe(19793);
@@ -840,7 +835,7 @@ describe('airport_tests', () => {
840
835
  const result = await runQuery(
841
836
  model,
842
837
  `
843
- query: table('malloytest.airports')->{
838
+ run: bigquery.table('malloytest.airports')->{
844
839
  aggregate: airport_count is count()
845
840
  nest: pipe_turtle is {
846
841
  group_by:
@@ -910,7 +905,7 @@ describe('airport_tests', () => {
910
905
  const result = await runQuery(
911
906
  model,
912
907
  `
913
- query: airports->{
908
+ run: airports->{
914
909
  group_by: lower_state is lower(state)
915
910
  order_by: 1 DESC
916
911
  limit: 10
@@ -924,7 +919,7 @@ describe('airport_tests', () => {
924
919
  const result = await runQuery(
925
920
  model,
926
921
  `
927
- query: airports->{
922
+ run: airports->{
928
923
  aggregate: half is airport_count/2.0
929
924
  }
930
925
  `
@@ -941,7 +936,7 @@ describe('sql injection tests', () => {
941
936
  const result = await runQuery(
942
937
  model,
943
938
  `
944
- query: table('malloytest.state_facts')->{ group_by: test is 'foo\\''
939
+ run: bigquery.table('malloytest.state_facts')->{ group_by: test is 'foo\\''
945
940
  }
946
941
  `
947
942
  );
@@ -952,7 +947,7 @@ describe('sql injection tests', () => {
952
947
  const result = await runQuery(
953
948
  model,
954
949
  `
955
- query: table('malloytest.state_facts')->{ aggregate: test is count() {? state ? 'foo\\'' } }
950
+ run: bigquery.table('malloytest.state_facts')->{ aggregate: test is count() { where: state ? 'foo\\'' } }
956
951
  `
957
952
  );
958
953
  expect(result.data.value[0]['test']).toBe(0);
@@ -962,7 +957,7 @@ describe('sql injection tests', () => {
962
957
  const result = await runQuery(
963
958
  model,
964
959
  `
965
- query: table('malloytest.state_facts')->{ group_by: test is 'foo\\\\\\''
960
+ run: bigquery.table('malloytest.state_facts')->{ group_by: test is 'foo\\\\\\''
966
961
  }
967
962
  `
968
963
  );
@@ -973,7 +968,7 @@ describe('sql injection tests', () => {
973
968
  const result = await runQuery(
974
969
  model,
975
970
  `
976
- query: table('malloytest.state_facts')->{ aggregate: test is count() {? state ? 'foo\\\\\\'' }}
971
+ run: bigquery.table('malloytest.state_facts')->{ aggregate: test is count() { where: state ? 'foo\\\\\\'' }}
977
972
  `
978
973
  );
979
974
  expect(result.data.value[0]['test']).toBe(0);
@@ -983,7 +978,7 @@ describe('sql injection tests', () => {
983
978
  const result = await runQuery(
984
979
  model,
985
980
  `
986
- query: table('malloytest.state_facts')->{ group_by: test is 'foo \\\\'--'
981
+ run: bigquery.table('malloytest.state_facts')->{ group_by: test is 'foo \\\\'--'
987
982
  }
988
983
  `
989
984
  );
@@ -996,7 +991,7 @@ describe('sql injection tests', () => {
996
991
  await runQuery(
997
992
  model,
998
993
  `
999
- query: table('malloytest.state_facts')->{ aggregate: test is count() {? state ? 'foo \\\\' THEN 0 else 1 END) as test--'
994
+ run: bigquery.table('malloytest.state_facts')->{ aggregate: test is count() { where: state ? 'foo \\\\' THEN 0 else 1 END) as test--'
1000
995
  }} `
1001
996
  );
1002
997
  } catch (e) {
@@ -1011,7 +1006,7 @@ describe('sql injection tests', () => {
1011
1006
  const result = await runQuery(
1012
1007
  model,
1013
1008
  `
1014
- query: flights->{ group_by: test is 'foo \\\\'--'
1009
+ run: flights->{ group_by: test is 'foo \\\\'--'
1015
1010
  }
1016
1011
  `
1017
1012
  );
@@ -1023,11 +1018,9 @@ describe('unsupported type tests', () => {
1023
1018
  it('can read unsupported types in schema', async () => {
1024
1019
  const result = await runtime
1025
1020
  .loadQuery(
1026
- `
1027
- sql: badType is {
1028
- select: """SELECT ST_GEOGFROMTEXT('LINESTRING(1 2, 3 4)') as geo"""
1029
- }
1030
- query: from_sql(badType)->{ select: *}
1021
+ `run:
1022
+ bigquery.sql("SELECT ST_GEOGFROMTEXT('LINESTRING(1 2, 3 4)') as geo")
1023
+ -> { select: geo }
1031
1024
  `
1032
1025
  )
1033
1026
  .run();
@@ -27,13 +27,14 @@ import '../../util/db-jest-matchers';
27
27
  import {describeIfDatabaseAvailable} from '../../util';
28
28
 
29
29
  const [describe, databases] = describeIfDatabaseAvailable(['bigquery']);
30
- describe('BigQuery double truncation', () => {
31
- const runtimes = new RuntimeList(databases);
32
- const runtime = runtimes.runtimeMap.get('bigquery');
30
+ const runtimes = new RuntimeList(databases);
33
31
 
34
- afterAll(async () => {
35
- await runtimes.closeAll();
36
- });
32
+ afterAll(async () => {
33
+ await runtimes.closeAll();
34
+ });
35
+
36
+ describe('time specific tests for standardsql', () => {
37
+ const runtime = runtimes.runtimeMap.get('bigquery');
37
38
 
38
39
  const utc_2020 = DateTime.fromObject({
39
40
  year: 2020,
@@ -44,16 +45,11 @@ describe('BigQuery double truncation', () => {
44
45
  second: 0,
45
46
  zone: 'UTC',
46
47
  });
47
- // TODO: this test is not working in this file.
48
- test.skip('can use unsupported types', async () => {
49
- await expect(runtime).queryMatches(
50
- `sql: timeData is { connection: "bigquery" select: """
51
- SELECT DATETIME '2020-02-20 00:00:00' as t_datetime
52
- """}
53
- query: from_sql(timeData) -> {
54
- select: mex_220 is t_datetime::timestamp
55
- }`,
56
- {mex_220: utc_2020.toJSDate()}
57
- );
48
+ test('can cast unsupported DATETIME to timestamp', async () => {
49
+ await expect(
50
+ `run: bigquery.sql("SELECT DATETIME '2020-02-20 00:00:00' as t_datetime") -> {
51
+ select: mex_220 is t_datetime::timestamp
52
+ }`
53
+ ).malloyResultMatches(runtime!, {mex_220: utc_2020.toJSDate()});
58
54
  });
59
55
  });
@@ -39,12 +39,12 @@ describe('Wildcard BigQuery Tables', () => {
39
39
  const result = await runtime
40
40
  .loadQuery(
41
41
  `
42
- source: aircraft is table('malloy-data.malloytest.wildcard_aircraft_*') {
42
+ source: aircraft is bigquery.table('malloy-data.malloytest.wildcard_aircraft_*') extend {
43
43
  primary_key: id
44
44
  measure: aircraft_count is count()
45
45
  }
46
46
 
47
- query: aircraft -> {
47
+ run: aircraft -> {
48
48
  aggregate: aircraft_count
49
49
  }
50
50
  `
@@ -61,13 +61,13 @@ describe('Wildcard BigQuery Tables', () => {
61
61
  const result = await runtime
62
62
  .loadQuery(
63
63
  `
64
- source: aircraft is table('malloy-data.malloytest.wildcard_aircraft_*') {
64
+ source: aircraft is bigquery.table('malloy-data.malloytest.wildcard_aircraft_*') extend {
65
65
  primary_key: id
66
66
  measure: aircraft_count is count()
67
67
  where: _TABLE_SUFFIX = '01'
68
68
  }
69
69
 
70
- query: aircraft -> {
70
+ run: aircraft -> {
71
71
  aggregate: aircraft_count
72
72
  }
73
73
  `
@@ -84,14 +84,14 @@ describe('Wildcard BigQuery Tables', () => {
84
84
  const result = await runtime
85
85
  .loadQuery(
86
86
  `
87
- source: aircraft is table('malloy-data.malloytest.wildcard_aircraft_*') {
87
+ source: aircraft is bigquery.table('malloy-data.malloytest.wildcard_aircraft_*') extend {
88
88
  primary_key: id
89
89
  }
90
90
 
91
- source: state_facts is table('malloy-data.malloytest.state_facts') {
91
+ source: state_facts is bigquery.table('malloy-data.malloytest.state_facts') extend {
92
92
  join_many: aircraft on state = aircraft.state
93
93
  }
94
- query: state_facts -> {
94
+ run: state_facts -> {
95
95
  group_by: aircraft.state
96
96
  aggregate: aircraft_count is aircraft.count()
97
97
  order_by: 1
@@ -120,15 +120,15 @@ describe('Wildcard BigQuery Tables', () => {
120
120
  const result = await runtime
121
121
  .loadQuery(
122
122
  `
123
- source: aircraft is table('malloy-data.malloytest.wildcard_aircraft_*') {
123
+ source: aircraft is bigquery.table('malloy-data.malloytest.wildcard_aircraft_*') extend {
124
124
  primary_key: id
125
125
  where: _TABLE_SUFFIX = '02'
126
126
  }
127
127
 
128
- source: state_facts is table('malloy-data.malloytest.state_facts') {
128
+ source: state_facts is bigquery.table('malloy-data.malloytest.state_facts') extend {
129
129
  join_many: aircraft on state = aircraft.state
130
130
  }
131
- query: state_facts -> {
131
+ run: state_facts -> {
132
132
  group_by: aircraft.state
133
133
  aggregate: aircraft_count is aircraft.count()
134
134
  order_by: 1
@@ -154,12 +154,12 @@ describe('Wildcard BigQuery Tables', () => {
154
154
  const result = await runtime
155
155
  .loadQuery(
156
156
  `
157
- source: aircraft is table('malloy-data.malloytest.wildcard_aircraft_*') {
158
- join_many: state_facts is table('malloy-data.malloytest.state_facts')
157
+ source: aircraft is bigquery.table('malloy-data.malloytest.wildcard_aircraft_*') extend {
158
+ join_many: state_facts is bigquery.table('malloy-data.malloytest.state_facts')
159
159
  on state_facts.state = state
160
160
  }
161
161
 
162
- query: aircraft -> {
162
+ run: aircraft -> {
163
163
  group_by: state_facts.state
164
164
  aggregate: aircraft_count is count()
165
165
  where: _TABLE_SUFFIX = '02'
@@ -180,15 +180,15 @@ describe('Wildcard BigQuery Tables', () => {
180
180
  const result = await runtime
181
181
  .loadQuery(
182
182
  `
183
- source: aircraft is table('malloy-data.malloytest.wildcard_aircraft_*') {
183
+ source: aircraft is bigquery.table('malloy-data.malloytest.wildcard_aircraft_*') extend {
184
184
  primary_key: id
185
185
  where: _TABLE_SUFFIX = '02'
186
186
  }
187
187
 
188
- source: state_facts is table('malloy-data.malloytest.state_facts') {
188
+ source: state_facts is bigquery.table('malloy-data.malloytest.state_facts') extend {
189
189
  join_many: aircraft on state = aircraft.state
190
190
  }
191
- query: state_facts -> {
191
+ run: state_facts -> {
192
192
  group_by: aircraft._TABLE_SUFFIX
193
193
  aggregate: aircraft_count is aircraft.count()
194
194
  order_by: 1
@@ -210,15 +210,15 @@ describe('Wildcard BigQuery Tables', () => {
210
210
  const result = await runtime
211
211
  .loadQuery(
212
212
  `
213
- source: aircraft is table('malloy-data.malloytest.wildcard_aircraft_*') {
213
+ source: aircraft is bigquery.table('malloy-data.malloytest.wildcard_aircraft_*') extend {
214
214
  primary_key: id
215
215
  where: _TABLE_SUFFIX = '02'
216
216
  }
217
217
 
218
- source: state_facts is table('malloy-data.malloytest.state_facts') {
218
+ source: state_facts is bigquery.table('malloy-data.malloytest.state_facts') extend {
219
219
  join_many: aircraft on state = aircraft.state
220
220
  }
221
- query: state_facts -> {
221
+ run: state_facts -> {
222
222
  group_by: aircraft._TABLE_SUFFIX
223
223
  aggregate: aircraft_count is aircraft.count()
224
224
  where: aircraft._TABLE_SUFFIX = '01'