@malloydata/malloy-tests 0.0.127-dev240307031210 → 0.0.127-dev240309202055
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 +2 -2
- package/dist/databases/all/db_index.spec.js.map +1 -1
- package/dist/databases/all/expr.spec.js +14 -14
- package/dist/databases/all/expr.spec.js.map +1 -1
- package/dist/databases/all/join.spec.js +2 -2
- package/dist/databases/all/join.spec.js.map +1 -1
- package/dist/databases/all/lenses.spec.js +45 -44
- package/dist/databases/all/lenses.spec.js.map +1 -1
- package/dist/databases/all/nomodel.spec.js +36 -36
- package/dist/databases/all/nomodel.spec.js.map +1 -1
- package/dist/databases/all/orderby.spec.js +4 -4
- package/dist/databases/all/orderby.spec.js.map +1 -1
- package/dist/databases/all/time.spec.js +26 -24
- package/dist/databases/all/time.spec.js.map +1 -1
- package/dist/databases/bigquery-postgres/multi_connection.spec.js +4 -7
- package/dist/databases/bigquery-postgres/multi_connection.spec.js.map +1 -1
- package/dist/databases/bigquery-postgres/streaming.spec.js +3 -0
- package/dist/databases/bigquery-postgres/streaming.spec.js.map +1 -1
- package/dist/databases/duckdb/duckdb.spec.js +1 -1
- package/dist/databases/duckdb/duckdb.spec.js.map +1 -1
- package/dist/databases/duckdb/streaming.spec.js +3 -0
- package/dist/databases/duckdb/streaming.spec.js.map +1 -1
- package/dist/render/render.spec.js +28 -28
- package/dist/render/render.spec.js.map +1 -1
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.js +17 -6
- package/dist/util/index.js.map +1 -1
- package/package.json +10 -7
- package/snowflake/uploaddata.sql +5 -4
- package/src/databases/all/db_index.spec.ts +4 -4
- package/src/databases/all/expr.spec.ts +41 -29
- package/src/databases/all/join.spec.ts +4 -4
- package/src/databases/all/lenses.spec.ts +45 -44
- package/src/databases/all/nomodel.spec.ts +91 -70
- package/src/databases/all/orderby.spec.ts +7 -7
- package/src/databases/all/time.spec.ts +45 -41
- package/src/databases/bigquery-postgres/multi_connection.spec.ts +4 -6
- package/src/databases/bigquery-postgres/streaming.spec.ts +3 -0
- package/src/databases/duckdb/duckdb.spec.ts +1 -1
- package/src/databases/duckdb/streaming.spec.ts +3 -0
- package/src/render/render.spec.ts +162 -120
- package/src/util/index.ts +24 -4
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
26
|
|
|
27
27
|
import {RuntimeList, allDatabases} from '../../runtimes';
|
|
28
|
-
import {databasesFromEnvironmentOr,
|
|
28
|
+
import {databasesFromEnvironmentOr, onlyIf} from '../../util';
|
|
29
29
|
import '../../util/db-jest-matchers';
|
|
30
30
|
|
|
31
31
|
const runtimes = new RuntimeList(databasesFromEnvironmentOr(allDatabases));
|
|
@@ -526,9 +526,9 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
526
526
|
});
|
|
527
527
|
});
|
|
528
528
|
|
|
529
|
-
|
|
530
|
-
`number as null- ${databaseName}`,
|
|
531
|
-
async () => {
|
|
529
|
+
test(
|
|
530
|
+
`number as null 2 - ${databaseName}`,
|
|
531
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
532
532
|
// a cross join produces a Many to Many result.
|
|
533
533
|
// symmetric aggregate are needed on both sides of the join
|
|
534
534
|
// Check the row count and that sums on each side work properly.
|
|
@@ -541,7 +541,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
543
|
`).malloyResultMatches(runtime, {'ugly.foo': null});
|
|
544
|
-
}
|
|
544
|
+
})
|
|
545
545
|
);
|
|
546
546
|
|
|
547
547
|
// average should only include non-null values in the denominator
|
|
@@ -586,9 +586,9 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
586
586
|
}`).malloyResultMatches(runtime, {births_per_100k: 9742});
|
|
587
587
|
});
|
|
588
588
|
|
|
589
|
-
|
|
589
|
+
test(
|
|
590
590
|
`ungrouped top level with nested - ${databaseName}`,
|
|
591
|
-
async () => {
|
|
591
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
592
592
|
await expect(`
|
|
593
593
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
594
594
|
measure: total_births is births.sum()
|
|
@@ -602,7 +602,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
602
602
|
}
|
|
603
603
|
limit: 1000
|
|
604
604
|
}`).malloyResultMatches(runtime, {births_per_100k: 9742});
|
|
605
|
-
}
|
|
605
|
+
})
|
|
606
606
|
);
|
|
607
607
|
|
|
608
608
|
it(`ungrouped - eliminate rows - ${databaseName}`, async () => {
|
|
@@ -620,9 +620,9 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
620
620
|
]);
|
|
621
621
|
});
|
|
622
622
|
|
|
623
|
-
|
|
623
|
+
test(
|
|
624
624
|
`ungrouped nested with no grouping above - ${databaseName}`,
|
|
625
|
-
async () => {
|
|
625
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
626
626
|
await expect(`
|
|
627
627
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
628
628
|
measure: total_births is births.sum()
|
|
@@ -634,12 +634,12 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
634
634
|
aggregate: births_per_100k
|
|
635
635
|
}
|
|
636
636
|
}`).malloyResultMatches(runtime, {'by_name.births_per_100k': 66703});
|
|
637
|
-
}
|
|
637
|
+
})
|
|
638
638
|
);
|
|
639
639
|
|
|
640
|
-
|
|
640
|
+
test(
|
|
641
641
|
`ungrouped - partial grouping - ${databaseName}`,
|
|
642
|
-
async () => {
|
|
642
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
643
643
|
await expect(`
|
|
644
644
|
run: ${databaseName}.table('malloytest.airports') extend {
|
|
645
645
|
measure: c is count()
|
|
@@ -668,12 +668,12 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
668
668
|
'fac_type.all_of_this_type': 1782,
|
|
669
669
|
'fac_type.all_top': 2421,
|
|
670
670
|
});
|
|
671
|
-
}
|
|
671
|
+
})
|
|
672
672
|
);
|
|
673
673
|
|
|
674
|
-
|
|
674
|
+
test(
|
|
675
675
|
`ungrouped - all nested - ${databaseName}`,
|
|
676
|
-
async () => {
|
|
676
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
677
677
|
await expect(`
|
|
678
678
|
run: ${databaseName}.table('malloytest.airports') extend {
|
|
679
679
|
measure: c is count()
|
|
@@ -697,12 +697,12 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
697
697
|
'fac_type.all_': 1845,
|
|
698
698
|
'fac_type.all_major': 1819,
|
|
699
699
|
});
|
|
700
|
-
}
|
|
700
|
+
})
|
|
701
701
|
);
|
|
702
702
|
|
|
703
|
-
|
|
703
|
+
test(
|
|
704
704
|
`ungrouped nested - ${databaseName}`,
|
|
705
|
-
async () => {
|
|
705
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
706
706
|
await expect(`
|
|
707
707
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
708
708
|
measure: total_births is births.sum()
|
|
@@ -715,12 +715,12 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
715
715
|
}
|
|
716
716
|
}
|
|
717
717
|
`).malloyResultMatches(runtime, {'by_state.births_per_100k': 36593});
|
|
718
|
-
}
|
|
718
|
+
})
|
|
719
719
|
);
|
|
720
720
|
|
|
721
|
-
|
|
721
|
+
test(
|
|
722
722
|
`ungrouped nested expression - ${databaseName}`,
|
|
723
|
-
async () => {
|
|
723
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
724
724
|
await expect(`
|
|
725
725
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
726
726
|
measure: total_births is births.sum()
|
|
@@ -733,12 +733,12 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
733
733
|
}
|
|
734
734
|
}
|
|
735
735
|
`).malloyResultMatches(runtime, {'by_state.births_per_100k': 36593});
|
|
736
|
-
}
|
|
736
|
+
})
|
|
737
737
|
);
|
|
738
738
|
|
|
739
|
-
|
|
739
|
+
test(
|
|
740
740
|
`ungrouped nested group by float - ${databaseName}`,
|
|
741
|
-
async () => {
|
|
741
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
742
742
|
await expect(`
|
|
743
743
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
744
744
|
measure: total_births is births.sum()
|
|
@@ -751,7 +751,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
751
751
|
}
|
|
752
752
|
}
|
|
753
753
|
`).malloyResultMatches(runtime, {'by_state.ug': 62742230});
|
|
754
|
-
}
|
|
754
|
+
})
|
|
755
755
|
);
|
|
756
756
|
|
|
757
757
|
it(`run simple sql - ${databaseName}`, async () => {
|
|
@@ -818,9 +818,9 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
818
818
|
});
|
|
819
819
|
});
|
|
820
820
|
|
|
821
|
-
|
|
821
|
+
test(
|
|
822
822
|
`all with parameters - nest - ${databaseName}`,
|
|
823
|
-
async () => {
|
|
823
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
824
824
|
await expect(`
|
|
825
825
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
826
826
|
measure: total_births is births.sum()
|
|
@@ -840,26 +840,31 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
840
840
|
'by_stuff.all_births': 119809719,
|
|
841
841
|
'by_stuff.all_name': 61091215,
|
|
842
842
|
});
|
|
843
|
-
}
|
|
843
|
+
})
|
|
844
844
|
);
|
|
845
845
|
|
|
846
|
-
|
|
846
|
+
test(
|
|
847
847
|
`single value to udf - ${databaseName}`,
|
|
848
|
-
|
|
849
|
-
|
|
848
|
+
onlyIf(
|
|
849
|
+
runtime.supportsNesting && runtime.dialect.supportsPipelinesInViews,
|
|
850
|
+
async () => {
|
|
851
|
+
await expect(`
|
|
850
852
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
851
853
|
view: fun is {
|
|
852
854
|
aggregate: t is count()
|
|
853
855
|
} -> { select: t1 is t+1 }
|
|
854
856
|
} -> { nest: fun }
|
|
855
857
|
`).malloyResultMatches(runtime, {'fun.t1': 52});
|
|
856
|
-
|
|
858
|
+
}
|
|
859
|
+
)
|
|
857
860
|
);
|
|
858
861
|
|
|
859
|
-
|
|
862
|
+
test(
|
|
860
863
|
`Multi value to udf - ${databaseName}`,
|
|
861
|
-
|
|
862
|
-
|
|
864
|
+
onlyIf(
|
|
865
|
+
runtime.supportsNesting && runtime.dialect.supportsPipelinesInViews,
|
|
866
|
+
async () => {
|
|
867
|
+
await expect(`
|
|
863
868
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
864
869
|
view: fun is {
|
|
865
870
|
group_by: one is 1
|
|
@@ -869,13 +874,16 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
869
874
|
nest: fun
|
|
870
875
|
}
|
|
871
876
|
`).malloyResultMatches(runtime, {'fun.t1': 52});
|
|
872
|
-
|
|
877
|
+
}
|
|
878
|
+
)
|
|
873
879
|
);
|
|
874
880
|
|
|
875
|
-
|
|
881
|
+
test(
|
|
876
882
|
`Multi value to udf group by - ${databaseName}`,
|
|
877
|
-
|
|
878
|
-
|
|
883
|
+
onlyIf(
|
|
884
|
+
runtime.supportsNesting && runtime.dialect.supportsPipelinesInViews,
|
|
885
|
+
async () => {
|
|
886
|
+
await expect(`
|
|
879
887
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
880
888
|
view: fun is {
|
|
881
889
|
group_by: one is 1
|
|
@@ -885,7 +893,8 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
885
893
|
nest: fun
|
|
886
894
|
}
|
|
887
895
|
`).malloyResultMatches(runtime, {'fun.t1': 52});
|
|
888
|
-
|
|
896
|
+
}
|
|
897
|
+
)
|
|
889
898
|
);
|
|
890
899
|
|
|
891
900
|
const sql1234 = `${databaseName}.sql('SELECT 1 as ${q`a`}, 2 as ${q`b`} UNION ALL SELECT 3, 4')`;
|
|
@@ -978,11 +987,13 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
978
987
|
`).malloyResultMatches(runtime, {x: 30});
|
|
979
988
|
});
|
|
980
989
|
|
|
981
|
-
|
|
990
|
+
test(
|
|
982
991
|
`array unnest - ${databaseName}`,
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
992
|
+
onlyIf(
|
|
993
|
+
runtime.supportsNesting && runtime.dialect.supportsArraysInData,
|
|
994
|
+
async () => {
|
|
995
|
+
const splitFN = getSplitFunction(databaseName);
|
|
996
|
+
await expect(`
|
|
986
997
|
run: ${databaseName}.sql("""
|
|
987
998
|
SELECT
|
|
988
999
|
${q`city`},
|
|
@@ -994,15 +1005,18 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
994
1005
|
aggregate: c is count()
|
|
995
1006
|
}
|
|
996
1007
|
`).malloyResultMatches(runtime, {c: 145});
|
|
997
|
-
|
|
1008
|
+
}
|
|
1009
|
+
)
|
|
998
1010
|
);
|
|
999
1011
|
|
|
1000
1012
|
// make sure we can count the total number of elements when fanning out.
|
|
1001
|
-
|
|
1013
|
+
test(
|
|
1002
1014
|
`array unnest x 2 - ${databaseName}`,
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1015
|
+
onlyIf(
|
|
1016
|
+
runtime.supportsNesting && runtime.dialect.supportsArraysInData,
|
|
1017
|
+
async () => {
|
|
1018
|
+
const splitFN = getSplitFunction(databaseName);
|
|
1019
|
+
await expect(`
|
|
1006
1020
|
run: ${databaseName}.sql("""
|
|
1007
1021
|
SELECT
|
|
1008
1022
|
${q`city`},
|
|
@@ -1016,13 +1030,16 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
1016
1030
|
c is words.count()
|
|
1017
1031
|
a is abreak.count()
|
|
1018
1032
|
}`).malloyResultMatches(runtime, {b: 3552, c: 4586, a: 6601});
|
|
1019
|
-
|
|
1033
|
+
}
|
|
1034
|
+
)
|
|
1020
1035
|
);
|
|
1021
1036
|
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1037
|
+
test(
|
|
1038
|
+
`nest null - ${databaseName}`,
|
|
1039
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
1040
|
+
const result = await runtime
|
|
1041
|
+
.loadQuery(
|
|
1042
|
+
`
|
|
1026
1043
|
run: ${databaseName}.table('malloytest.airports') -> {
|
|
1027
1044
|
where: faa_region = null
|
|
1028
1045
|
group_by: faa_region
|
|
@@ -1040,18 +1057,19 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
1040
1057
|
}
|
|
1041
1058
|
}
|
|
1042
1059
|
`
|
|
1043
|
-
|
|
1044
|
-
|
|
1060
|
+
)
|
|
1061
|
+
.run();
|
|
1045
1062
|
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1063
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1064
|
+
const d: any = result.data.toObject();
|
|
1065
|
+
expect(d[0]['by_state']).not.toBe(null);
|
|
1066
|
+
expect(d[0]['by_state1']).not.toBe(null);
|
|
1067
|
+
})
|
|
1068
|
+
);
|
|
1051
1069
|
|
|
1052
|
-
|
|
1070
|
+
test(
|
|
1053
1071
|
`number as null- ${databaseName}`,
|
|
1054
|
-
async () => {
|
|
1072
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
1055
1073
|
const result = await runtime
|
|
1056
1074
|
.loadQuery(
|
|
1057
1075
|
`
|
|
@@ -1068,7 +1086,7 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
1068
1086
|
)
|
|
1069
1087
|
.run();
|
|
1070
1088
|
expect(result.data.path(0, 'ugly', 0, 'foo').value).toBe(null);
|
|
1071
|
-
}
|
|
1089
|
+
})
|
|
1072
1090
|
);
|
|
1073
1091
|
|
|
1074
1092
|
it(`removes surpuflous order_by - solo aggregates - ${databaseName}`, async () => {
|
|
@@ -1155,21 +1173,23 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
1155
1173
|
const back = '\\';
|
|
1156
1174
|
test('backslash quote', async () => {
|
|
1157
1175
|
await expect(`
|
|
1158
|
-
run: ${databaseName}.sql('SELECT 1') -> {
|
|
1176
|
+
run: ${databaseName}.sql('SELECT 1 as one') -> {
|
|
1159
1177
|
select: tick is '${back}${tick}'
|
|
1160
1178
|
}
|
|
1161
1179
|
`).malloyResultMatches(runtime, {tick});
|
|
1162
1180
|
});
|
|
1163
1181
|
test('backslash backslash', async () => {
|
|
1164
1182
|
await expect(`
|
|
1165
|
-
run: ${databaseName}.sql("SELECT 1") -> {
|
|
1183
|
+
run: ${databaseName}.sql("SELECT 1 as one") -> {
|
|
1166
1184
|
select: back is '${back}${back}'
|
|
1167
1185
|
}
|
|
1168
1186
|
`).malloyResultMatches(runtime, {back});
|
|
1169
1187
|
});
|
|
1170
1188
|
|
|
1171
|
-
|
|
1172
|
-
|
|
1189
|
+
test(
|
|
1190
|
+
'spaces in names',
|
|
1191
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
1192
|
+
await expect(`
|
|
1173
1193
|
source: \`space race\` is ${databaseName}.table('malloytest.state_facts') extend {
|
|
1174
1194
|
join_one: \`j space\` is ${databaseName}.table('malloytest.state_facts') on \`j space\`.state=state
|
|
1175
1195
|
view: \`q u e r y\` is {
|
|
@@ -1188,6 +1208,7 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
1188
1208
|
}
|
|
1189
1209
|
run: \`space race\` -> \`q u e r y\`
|
|
1190
1210
|
`).malloyResultMatches(runtime, {'c o u n t': 24});
|
|
1191
|
-
|
|
1211
|
+
})
|
|
1212
|
+
);
|
|
1192
1213
|
});
|
|
1193
1214
|
});
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import {RuntimeList, allDatabases} from '../../runtimes';
|
|
26
|
-
import {databasesFromEnvironmentOr,
|
|
26
|
+
import {databasesFromEnvironmentOr, onlyIf} from '../../util';
|
|
27
27
|
import '../../util/db-jest-matchers';
|
|
28
28
|
|
|
29
29
|
const runtimes = new RuntimeList(databasesFromEnvironmentOr(allDatabases));
|
|
@@ -87,9 +87,9 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
87
87
|
`).malloyResultMatches(orderByModel, {});
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
test(
|
|
91
91
|
`reserved words are quoted in turtles - ${databaseName}`,
|
|
92
|
-
async () => {
|
|
92
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
93
93
|
await expect(`
|
|
94
94
|
run: models->{
|
|
95
95
|
nest: withx is {
|
|
@@ -102,7 +102,7 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
102
102
|
fetch is withx.fetch
|
|
103
103
|
}
|
|
104
104
|
`).malloyResultMatches(orderByModel, {});
|
|
105
|
-
}
|
|
105
|
+
})
|
|
106
106
|
);
|
|
107
107
|
|
|
108
108
|
it.skip('reserved words in structure definitions', async () => {
|
|
@@ -142,9 +142,9 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
142
142
|
`).malloyResultMatches(orderByModel, {model_count: 102});
|
|
143
143
|
});
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
test(
|
|
146
146
|
`modeled having complex - ${databaseName}`,
|
|
147
|
-
async () => {
|
|
147
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
148
148
|
await expect(`
|
|
149
149
|
source: popular_names is models->{
|
|
150
150
|
having: model_count > 100
|
|
@@ -161,7 +161,7 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
161
161
|
select: manufacturer, model_count
|
|
162
162
|
}
|
|
163
163
|
`).malloyResultMatches(orderByModel, {model_count: 102});
|
|
164
|
-
}
|
|
164
|
+
})
|
|
165
165
|
);
|
|
166
166
|
|
|
167
167
|
it(`turtle references joined element - ${databaseName}`, async () => {
|
|
@@ -27,18 +27,18 @@ import '../../util/db-jest-matchers';
|
|
|
27
27
|
import {
|
|
28
28
|
databasesFromEnvironmentOr,
|
|
29
29
|
mkSqlEqWith,
|
|
30
|
+
onlyIf,
|
|
30
31
|
runQuery,
|
|
31
|
-
testIf,
|
|
32
32
|
} from '../../util';
|
|
33
33
|
import {DateTime as LuxonDateTime} from 'luxon';
|
|
34
34
|
|
|
35
35
|
const runtimes = new RuntimeList(databasesFromEnvironmentOr(allDatabases));
|
|
36
36
|
|
|
37
|
-
const timeSQL =
|
|
38
|
-
"SELECT DATE '2021-02-24' as t_date, TIMESTAMP '2021-02-24 03:05:06' as t_timestamp";
|
|
39
|
-
|
|
40
37
|
// MTOY todo look at this list for timezone problems, I know there are some
|
|
41
38
|
describe.each(runtimes.runtimeList)('%s date and time', (dbName, runtime) => {
|
|
39
|
+
const q = runtime.getQuoter();
|
|
40
|
+
|
|
41
|
+
const timeSQL = `SELECT DATE '2021-02-24' as ${q`t_date`}, TIMESTAMP '2021-02-24 03:05:06' as ${q`t_timestamp`} `;
|
|
42
42
|
const sqlEq = mkSqlEqWith(runtime, dbName, {sql: timeSQL});
|
|
43
43
|
|
|
44
44
|
describe('interval measurement', () => {
|
|
@@ -489,10 +489,10 @@ describe.each(runtimes.runtimeList)('%s date and time', (dbName, runtime) => {
|
|
|
489
489
|
).toBe('America/Los_Angeles');
|
|
490
490
|
});
|
|
491
491
|
|
|
492
|
-
// TODO don't need to run this on all connections, so
|
|
493
|
-
|
|
492
|
+
// TODO don't need to run this on all connections, so onlyIf not needed
|
|
493
|
+
test(
|
|
494
494
|
'timezone set in view inside source',
|
|
495
|
-
async () => {
|
|
495
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
496
496
|
expect(
|
|
497
497
|
(
|
|
498
498
|
await runQuery(
|
|
@@ -515,13 +515,13 @@ describe.each(runtimes.runtimeList)('%s date and time', (dbName, runtime) => {
|
|
|
515
515
|
{name: 'la_query', queryTimezone: 'America/Los_Angeles'},
|
|
516
516
|
],
|
|
517
517
|
});
|
|
518
|
-
}
|
|
518
|
+
})
|
|
519
519
|
);
|
|
520
520
|
|
|
521
|
-
// TODO don't need to run this on all connections, so
|
|
522
|
-
|
|
521
|
+
// TODO don't need to run this on all connections, so onlyIf not needed
|
|
522
|
+
test(
|
|
523
523
|
'timezone set in query using source',
|
|
524
|
-
async () => {
|
|
524
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
525
525
|
expect(
|
|
526
526
|
(
|
|
527
527
|
await runQuery(
|
|
@@ -539,37 +539,40 @@ describe.each(runtimes.runtimeList)('%s date and time', (dbName, runtime) => {
|
|
|
539
539
|
)
|
|
540
540
|
).resultExplore.queryTimezone
|
|
541
541
|
).toBe('America/Los_Angeles');
|
|
542
|
-
}
|
|
542
|
+
})
|
|
543
543
|
);
|
|
544
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
|
-
|
|
545
|
+
test(
|
|
546
|
+
'multiple timezones',
|
|
547
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
548
|
+
const theQuery = await runQuery(
|
|
549
|
+
runtime,
|
|
550
|
+
`run: ${dbName}.sql('SELECT 1') extend {
|
|
551
|
+
timezone: 'America/New_York'
|
|
552
|
+
dimension: ny_time is @2021-02-24 03:05:06
|
|
553
|
+
view: la_query is {
|
|
554
|
+
timezone: 'America/Los_Angeles'
|
|
555
|
+
select: la_time is @2021-02-24 03:05:06
|
|
556
|
+
}
|
|
557
|
+
view: mex_query is {
|
|
558
|
+
timezone: 'America/Mexico_City'
|
|
559
|
+
select: mex_time is @2021-02-24 03:05:06
|
|
560
|
+
}
|
|
561
|
+
} -> {
|
|
562
|
+
group_by: ny_time
|
|
563
|
+
nest: la_query, mex_query
|
|
564
|
+
}`
|
|
565
|
+
);
|
|
566
|
+
expect(theQuery.resultExplore.structDef).toMatchObject({
|
|
567
|
+
queryTimezone: 'America/New_York',
|
|
568
|
+
fields: [
|
|
569
|
+
{},
|
|
570
|
+
{name: 'la_query', queryTimezone: 'America/Los_Angeles'},
|
|
571
|
+
{name: 'mex_query', queryTimezone: 'America/Mexico_City'},
|
|
572
|
+
],
|
|
573
|
+
});
|
|
574
|
+
})
|
|
575
|
+
);
|
|
573
576
|
});
|
|
574
577
|
});
|
|
575
578
|
|
|
@@ -651,6 +654,7 @@ describe.each(runtimes.runtimeList)('%s: tz literals', (dbName, runtime) => {
|
|
|
651
654
|
});
|
|
652
655
|
|
|
653
656
|
describe.each(runtimes.runtimeList)('%s: query tz', (dbName, runtime) => {
|
|
657
|
+
const q = runtime.getQuoter();
|
|
654
658
|
test('literal timestamps', async () => {
|
|
655
659
|
const query = runtime.loadQuery(
|
|
656
660
|
`
|
|
@@ -705,7 +709,7 @@ describe.each(runtimes.runtimeList)('%s: query tz', (dbName, runtime) => {
|
|
|
705
709
|
|
|
706
710
|
test('cast date to timestamp', async () => {
|
|
707
711
|
await expect(
|
|
708
|
-
`run: ${dbName}.sql(" SELECT DATE '2020-02-20' AS mex_20") -> {
|
|
712
|
+
`run: ${dbName}.sql(""" SELECT DATE '2020-02-20' AS ${q`mex_20`} """) -> {
|
|
709
713
|
timezone: '${zone}'
|
|
710
714
|
select: mex_ts is mex_20::timestamp
|
|
711
715
|
}`
|
|
@@ -29,16 +29,14 @@ import {EmptyURLReader} from '@malloydata/malloy';
|
|
|
29
29
|
import {BigQueryTestConnection, PostgresTestConnection} from '../../runtimes';
|
|
30
30
|
import {describeIfDatabaseAvailable} from '../../util';
|
|
31
31
|
|
|
32
|
-
const
|
|
33
|
-
let [describe] = res;
|
|
34
|
-
const [, databases] = res;
|
|
32
|
+
const [, databases] = describeIfDatabaseAvailable(['bigquery', 'postgres']);
|
|
35
33
|
|
|
36
34
|
// *** NOTE ***
|
|
37
35
|
// this is a special case (for now): a test that REQUIRES two databases - bigquery AND postgres
|
|
38
|
-
describe =
|
|
36
|
+
const describe =
|
|
39
37
|
databases.filter(d => ['postgres', 'bigquery'].includes(d)).length >= 2
|
|
40
|
-
? describe
|
|
41
|
-
: describe.skip;
|
|
38
|
+
? globalThis.describe
|
|
39
|
+
: globalThis.describe.skip;
|
|
42
40
|
|
|
43
41
|
describe('Multi-connection', () => {
|
|
44
42
|
const bqConnection = new BigQueryTestConnection(
|
|
@@ -29,7 +29,7 @@ import {describeIfDatabaseAvailable} from '../../util';
|
|
|
29
29
|
// TODO identify which tests need to run on wasm and move them into their own file
|
|
30
30
|
const runtimes = ['duckdb', 'duckdb_wasm'];
|
|
31
31
|
|
|
32
|
-
const [
|
|
32
|
+
const [describe, databases] = describeIfDatabaseAvailable(runtimes);
|
|
33
33
|
const allDucks = new RuntimeList(databases);
|
|
34
34
|
|
|
35
35
|
describe.each(allDucks.runtimeList)('duckdb:%s', (dbName, runtime) => {
|