@malloydata/malloy-tests 0.0.127-dev240306172007 → 0.0.127-dev240308180053
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/nomodel.spec.js +34 -34
- 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 +22 -22
- 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/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/nomodel.spec.ts +66 -60
- package/src/databases/all/orderby.spec.ts +7 -7
- package/src/databases/all/time.spec.ts +40 -37
- 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
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
import {RuntimeList, allDatabases} from '../../runtimes';
|
|
26
26
|
import '../../util/db-jest-matchers';
|
|
27
|
-
import {databasesFromEnvironmentOr, mkSqlEqWith,
|
|
27
|
+
import {databasesFromEnvironmentOr, mkSqlEqWith, onlyIf} from '../../util';
|
|
28
28
|
import {fail} from 'assert';
|
|
29
29
|
|
|
30
30
|
const runtimes = new RuntimeList(databasesFromEnvironmentOr(allDatabases));
|
|
@@ -119,13 +119,16 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
119
119
|
});
|
|
120
120
|
|
|
121
121
|
// filtered turtle expressions
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
test(
|
|
123
|
+
'model: filtered turtle',
|
|
124
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
125
|
+
await expect(`
|
|
124
126
|
run: aircraft->{
|
|
125
127
|
nest: b is by_manufacturer + { where: aircraft_models.manufacturer ?~'B%'}
|
|
126
128
|
}
|
|
127
129
|
`).malloyResultMatches(expressionModel, {'b.manufacturer': 'BEECH'});
|
|
128
|
-
|
|
130
|
+
})
|
|
131
|
+
);
|
|
129
132
|
|
|
130
133
|
// having.
|
|
131
134
|
it('model: simple having', async () => {
|
|
@@ -139,8 +142,10 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
139
142
|
`).malloyResultMatches(expressionModel, {aircraft_count: 91});
|
|
140
143
|
});
|
|
141
144
|
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
test(
|
|
146
|
+
'model: having in a nest',
|
|
147
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
148
|
+
await expect(`
|
|
144
149
|
run: aircraft->{
|
|
145
150
|
top: 10
|
|
146
151
|
order_by: 1
|
|
@@ -155,10 +160,13 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
155
160
|
}
|
|
156
161
|
}
|
|
157
162
|
`).malloyResultMatches(expressionModel, {'by_state.state': 'VA'});
|
|
158
|
-
|
|
163
|
+
})
|
|
164
|
+
);
|
|
159
165
|
|
|
160
|
-
|
|
161
|
-
|
|
166
|
+
test(
|
|
167
|
+
'model: turtle having on main',
|
|
168
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
169
|
+
await expect(`
|
|
162
170
|
run: aircraft->{
|
|
163
171
|
order_by: 2 asc
|
|
164
172
|
having: aircraft_count ? >500
|
|
@@ -178,14 +186,15 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
178
186
|
}
|
|
179
187
|
}
|
|
180
188
|
`).malloyResultMatches(expressionModel, {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
189
|
+
'by_state.by_city.city': 'ALBUQUERQUE',
|
|
190
|
+
});
|
|
191
|
+
})
|
|
192
|
+
);
|
|
184
193
|
|
|
185
194
|
// bigquery doesn't like to partition by floats,
|
|
186
|
-
|
|
195
|
+
test(
|
|
187
196
|
'model: having float group by partition',
|
|
188
|
-
async () => {
|
|
197
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
189
198
|
await expect(`${modelText(databaseName)}
|
|
190
199
|
run: aircraft_models->{
|
|
191
200
|
order_by: 1
|
|
@@ -198,7 +207,7 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
198
207
|
aggregate: aircraft_model_count
|
|
199
208
|
}
|
|
200
209
|
}`).malloyResultMatches(runtime, {aircraft_model_count: 448});
|
|
201
|
-
}
|
|
210
|
+
})
|
|
202
211
|
);
|
|
203
212
|
|
|
204
213
|
it('model: aggregate functions distinct min max', async () => {
|
|
@@ -232,9 +241,9 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
232
241
|
|
|
233
242
|
// TODO not sure why this test needs to be skipped on postgres, feels like an oversight
|
|
234
243
|
// NOTE: unless underlying type is stored as a timestamp snowflake does not support extraction
|
|
235
|
-
|
|
244
|
+
test(
|
|
236
245
|
'model: dates named',
|
|
237
|
-
async () => {
|
|
246
|
+
onlyIf(!['postgres', 'snowflake'].includes(databaseName), async () => {
|
|
238
247
|
await expect(`
|
|
239
248
|
run: ${databaseName}.table('malloytest.alltypes')->{
|
|
240
249
|
group_by:
|
|
@@ -261,7 +270,7 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
261
270
|
t_timestamp_month: new Date('2020-03-01'),
|
|
262
271
|
t_timestamp_year: new Date('2020-01-01'),
|
|
263
272
|
});
|
|
264
|
-
}
|
|
273
|
+
})
|
|
265
274
|
);
|
|
266
275
|
|
|
267
276
|
it('named query metadata undefined', async () => {
|
|
@@ -316,21 +325,24 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
316
325
|
`).malloyResultMatches(expressionModel, {a: 312});
|
|
317
326
|
});
|
|
318
327
|
|
|
319
|
-
|
|
328
|
+
test(
|
|
320
329
|
'sql safe cast',
|
|
321
|
-
|
|
322
|
-
|
|
330
|
+
onlyIf(
|
|
331
|
+
!['postgres', 'snowflake'].includes(runtime.connection.name),
|
|
332
|
+
async () => {
|
|
333
|
+
await expect(`
|
|
323
334
|
run: ${databaseName}.sql('SELECT 1') -> { select:
|
|
324
335
|
bad_date is '123':::date
|
|
325
336
|
bad_number is 'abc':::number
|
|
326
337
|
good_number is "312":::"integer"
|
|
327
338
|
}
|
|
328
339
|
`).malloyResultMatches(expressionModel, {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
340
|
+
bad_date: null,
|
|
341
|
+
bad_number: null,
|
|
342
|
+
good_number: 312,
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
)
|
|
334
346
|
);
|
|
335
347
|
|
|
336
348
|
it('many_field.sum() has correct locality', async () => {
|
|
@@ -540,9 +552,9 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
540
552
|
});
|
|
541
553
|
});
|
|
542
554
|
|
|
543
|
-
|
|
555
|
+
test(
|
|
544
556
|
'query with aliasname used twice',
|
|
545
|
-
async () => {
|
|
557
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
546
558
|
await expect(`
|
|
547
559
|
run: aircraft->{
|
|
548
560
|
group_by: first is substr(city,1,1)
|
|
@@ -562,7 +574,7 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
562
574
|
order_by: 2 desc, 1
|
|
563
575
|
}
|
|
564
576
|
`).malloyResultMatches(expressionModel, {first_three: 'SAB'});
|
|
565
|
-
}
|
|
577
|
+
})
|
|
566
578
|
);
|
|
567
579
|
|
|
568
580
|
it('joined filtered sources', async () => {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
/* eslint-disable no-console */
|
|
25
25
|
|
|
26
26
|
import {RuntimeList, allDatabases} from '../../runtimes';
|
|
27
|
-
import {databasesFromEnvironmentOr,
|
|
27
|
+
import {databasesFromEnvironmentOr, onlyIf} from '../../util';
|
|
28
28
|
import '../../util/db-jest-matchers';
|
|
29
29
|
|
|
30
30
|
const runtimes = new RuntimeList(databasesFromEnvironmentOr(allDatabases));
|
|
@@ -194,9 +194,9 @@ describe('join expression tests', () => {
|
|
|
194
194
|
`).malloyResultMatches(joinModel, {f_sum2: 60462});
|
|
195
195
|
});
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
test(
|
|
198
198
|
`model: unnest is left join - ${database}`,
|
|
199
|
-
async () => {
|
|
199
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
200
200
|
await expect(`
|
|
201
201
|
// produce a table with 4 rows that has a nested element
|
|
202
202
|
query: a_states is ${database}.table('malloytest.state_facts')-> {
|
|
@@ -220,7 +220,7 @@ describe('join expression tests', () => {
|
|
|
220
220
|
limit: 5
|
|
221
221
|
}
|
|
222
222
|
`).malloyResultMatches(joinModel, [{}, {}, {}, {}, {}]);
|
|
223
|
-
}
|
|
223
|
+
})
|
|
224
224
|
);
|
|
225
225
|
|
|
226
226
|
// not sure how to solve this one yet, just check for > 4 rows
|
|
@@ -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
|
-
|
|
529
|
+
test(
|
|
530
530
|
`number as null- ${databaseName}`,
|
|
531
|
-
async () => {
|
|
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,12 +840,12 @@ 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
|
-
async () => {
|
|
848
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
849
849
|
await expect(`
|
|
850
850
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
851
851
|
view: fun is {
|
|
@@ -853,12 +853,12 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
853
853
|
} -> { select: t1 is t+1 }
|
|
854
854
|
} -> { nest: fun }
|
|
855
855
|
`).malloyResultMatches(runtime, {'fun.t1': 52});
|
|
856
|
-
}
|
|
856
|
+
})
|
|
857
857
|
);
|
|
858
858
|
|
|
859
|
-
|
|
859
|
+
test(
|
|
860
860
|
`Multi value to udf - ${databaseName}`,
|
|
861
|
-
async () => {
|
|
861
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
862
862
|
await expect(`
|
|
863
863
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
864
864
|
view: fun is {
|
|
@@ -869,12 +869,12 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
869
869
|
nest: fun
|
|
870
870
|
}
|
|
871
871
|
`).malloyResultMatches(runtime, {'fun.t1': 52});
|
|
872
|
-
}
|
|
872
|
+
})
|
|
873
873
|
);
|
|
874
874
|
|
|
875
|
-
|
|
875
|
+
test(
|
|
876
876
|
`Multi value to udf group by - ${databaseName}`,
|
|
877
|
-
async () => {
|
|
877
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
878
878
|
await expect(`
|
|
879
879
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
880
880
|
view: fun is {
|
|
@@ -885,7 +885,7 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
885
885
|
nest: fun
|
|
886
886
|
}
|
|
887
887
|
`).malloyResultMatches(runtime, {'fun.t1': 52});
|
|
888
|
-
}
|
|
888
|
+
})
|
|
889
889
|
);
|
|
890
890
|
|
|
891
891
|
const sql1234 = `${databaseName}.sql('SELECT 1 as ${q`a`}, 2 as ${q`b`} UNION ALL SELECT 3, 4')`;
|
|
@@ -978,9 +978,9 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
978
978
|
`).malloyResultMatches(runtime, {x: 30});
|
|
979
979
|
});
|
|
980
980
|
|
|
981
|
-
|
|
981
|
+
test(
|
|
982
982
|
`array unnest - ${databaseName}`,
|
|
983
|
-
async () => {
|
|
983
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
984
984
|
const splitFN = getSplitFunction(databaseName);
|
|
985
985
|
await expect(`
|
|
986
986
|
run: ${databaseName}.sql("""
|
|
@@ -994,13 +994,13 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
994
994
|
aggregate: c is count()
|
|
995
995
|
}
|
|
996
996
|
`).malloyResultMatches(runtime, {c: 145});
|
|
997
|
-
}
|
|
997
|
+
})
|
|
998
998
|
);
|
|
999
999
|
|
|
1000
1000
|
// make sure we can count the total number of elements when fanning out.
|
|
1001
|
-
|
|
1001
|
+
test(
|
|
1002
1002
|
`array unnest x 2 - ${databaseName}`,
|
|
1003
|
-
async () => {
|
|
1003
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
1004
1004
|
const splitFN = getSplitFunction(databaseName);
|
|
1005
1005
|
await expect(`
|
|
1006
1006
|
run: ${databaseName}.sql("""
|
|
@@ -1016,13 +1016,15 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
1016
1016
|
c is words.count()
|
|
1017
1017
|
a is abreak.count()
|
|
1018
1018
|
}`).malloyResultMatches(runtime, {b: 3552, c: 4586, a: 6601});
|
|
1019
|
-
}
|
|
1019
|
+
})
|
|
1020
1020
|
);
|
|
1021
1021
|
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1022
|
+
test(
|
|
1023
|
+
`nest null - ${databaseName}`,
|
|
1024
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
1025
|
+
const result = await runtime
|
|
1026
|
+
.loadQuery(
|
|
1027
|
+
`
|
|
1026
1028
|
run: ${databaseName}.table('malloytest.airports') -> {
|
|
1027
1029
|
where: faa_region = null
|
|
1028
1030
|
group_by: faa_region
|
|
@@ -1040,18 +1042,19 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
1040
1042
|
}
|
|
1041
1043
|
}
|
|
1042
1044
|
`
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
+
)
|
|
1046
|
+
.run();
|
|
1045
1047
|
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1048
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1049
|
+
const d: any = result.data.toObject();
|
|
1050
|
+
expect(d[0]['by_state']).not.toBe(null);
|
|
1051
|
+
expect(d[0]['by_state1']).not.toBe(null);
|
|
1052
|
+
})
|
|
1053
|
+
);
|
|
1051
1054
|
|
|
1052
|
-
|
|
1055
|
+
test(
|
|
1053
1056
|
`number as null- ${databaseName}`,
|
|
1054
|
-
async () => {
|
|
1057
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
1055
1058
|
const result = await runtime
|
|
1056
1059
|
.loadQuery(
|
|
1057
1060
|
`
|
|
@@ -1068,7 +1071,7 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
1068
1071
|
)
|
|
1069
1072
|
.run();
|
|
1070
1073
|
expect(result.data.path(0, 'ugly', 0, 'foo').value).toBe(null);
|
|
1071
|
-
}
|
|
1074
|
+
})
|
|
1072
1075
|
);
|
|
1073
1076
|
|
|
1074
1077
|
it(`removes surpuflous order_by - solo aggregates - ${databaseName}`, async () => {
|
|
@@ -1168,8 +1171,10 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
1168
1171
|
`).malloyResultMatches(runtime, {back});
|
|
1169
1172
|
});
|
|
1170
1173
|
|
|
1171
|
-
|
|
1172
|
-
|
|
1174
|
+
test(
|
|
1175
|
+
'spaces in names',
|
|
1176
|
+
onlyIf(runtime.supportsNesting, async () => {
|
|
1177
|
+
await expect(`
|
|
1173
1178
|
source: \`space race\` is ${databaseName}.table('malloytest.state_facts') extend {
|
|
1174
1179
|
join_one: \`j space\` is ${databaseName}.table('malloytest.state_facts') on \`j space\`.state=state
|
|
1175
1180
|
view: \`q u e r y\` is {
|
|
@@ -1188,6 +1193,7 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
1188
1193
|
}
|
|
1189
1194
|
run: \`space race\` -> \`q u e r y\`
|
|
1190
1195
|
`).malloyResultMatches(runtime, {'c o u n t': 24});
|
|
1191
|
-
|
|
1196
|
+
})
|
|
1197
|
+
);
|
|
1192
1198
|
});
|
|
1193
1199
|
});
|
|
@@ -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,8 +27,8 @@ 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
|
|
|
@@ -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
|
|