@malloydata/malloy-tests 0.0.138-dev240404193102 → 0.0.138-dev240404233606
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/jest.setup.ts +28 -0
- package/package.json +8 -8
- package/src/databases/all/db_index.spec.ts +4 -6
- package/src/databases/all/expr.spec.ts +27 -36
- package/src/databases/all/join.spec.ts +4 -4
- package/src/databases/all/nomodel.spec.ts +79 -99
- package/src/databases/all/orderby.spec.ts +7 -7
- package/src/databases/all/time.spec.ts +22 -30
- package/src/render/render.spec.ts +52 -55
- package/src/util/index.ts +0 -11
- package/tsconfig.json +2 -2
- package/types/jest.d.ts +8 -0
- package/dist/bin/ping_db.d.ts +0 -1
- package/dist/bin/ping_db.js +0 -44
- package/dist/bin/ping_db.js.map +0 -1
- package/dist/src/api.spec.d.ts +0 -1
- package/dist/src/api.spec.js +0 -113
- package/dist/src/api.spec.js.map +0 -1
- package/dist/src/databases/all/db_index.spec.d.ts +0 -1
- package/dist/src/databases/all/db_index.spec.js +0 -126
- package/dist/src/databases/all/db_index.spec.js.map +0 -1
- package/dist/src/databases/all/expr.spec.d.ts +0 -1
- package/dist/src/databases/all/expr.spec.js +0 -717
- package/dist/src/databases/all/expr.spec.js.map +0 -1
- package/dist/src/databases/all/functions.spec.d.ts +0 -1
- package/dist/src/databases/all/functions.spec.js +0 -1180
- package/dist/src/databases/all/functions.spec.js.map +0 -1
- package/dist/src/databases/all/join.spec.d.ts +0 -1
- package/dist/src/databases/all/join.spec.js +0 -255
- package/dist/src/databases/all/join.spec.js.map +0 -1
- package/dist/src/databases/all/lenses.spec.d.ts +0 -1
- package/dist/src/databases/all/lenses.spec.js +0 -374
- package/dist/src/databases/all/lenses.spec.js.map +0 -1
- package/dist/src/databases/all/nomodel.spec.d.ts +0 -1
- package/dist/src/databases/all/nomodel.spec.js +0 -1071
- package/dist/src/databases/all/nomodel.spec.js.map +0 -1
- package/dist/src/databases/all/orderby.spec.d.ts +0 -1
- package/dist/src/databases/all/orderby.spec.js +0 -170
- package/dist/src/databases/all/orderby.spec.js.map +0 -1
- package/dist/src/databases/all/problems.spec.d.ts +0 -1
- package/dist/src/databases/all/problems.spec.js +0 -106
- package/dist/src/databases/all/problems.spec.js.map +0 -1
- package/dist/src/databases/all/sql_expressions.spec.d.ts +0 -1
- package/dist/src/databases/all/sql_expressions.spec.js +0 -73
- package/dist/src/databases/all/sql_expressions.spec.js.map +0 -1
- package/dist/src/databases/all/time.spec.d.ts +0 -1
- package/dist/src/databases/all/time.spec.js +0 -602
- package/dist/src/databases/all/time.spec.js.map +0 -1
- package/dist/src/databases/bigquery/double_truncation.spec.d.ts +0 -1
- package/dist/src/databases/bigquery/double_truncation.spec.js +0 -50
- package/dist/src/databases/bigquery/double_truncation.spec.js.map +0 -1
- package/dist/src/databases/bigquery/handexpr.spec.d.ts +0 -1
- package/dist/src/databases/bigquery/handexpr.spec.js +0 -723
- package/dist/src/databases/bigquery/handexpr.spec.js.map +0 -1
- package/dist/src/databases/bigquery/injestion_time_partitioning.spec.d.ts +0 -1
- package/dist/src/databases/bigquery/injestion_time_partitioning.spec.js +0 -235
- package/dist/src/databases/bigquery/injestion_time_partitioning.spec.js.map +0 -1
- package/dist/src/databases/bigquery/joined_filters.spec.d.ts +0 -1
- package/dist/src/databases/bigquery/joined_filters.spec.js +0 -72
- package/dist/src/databases/bigquery/joined_filters.spec.js.map +0 -1
- package/dist/src/databases/bigquery/json.spec.d.ts +0 -1
- package/dist/src/databases/bigquery/json.spec.js +0 -66
- package/dist/src/databases/bigquery/json.spec.js.map +0 -1
- package/dist/src/databases/bigquery/malloy_query.spec.d.ts +0 -1
- package/dist/src/databases/bigquery/malloy_query.spec.js +0 -840
- package/dist/src/databases/bigquery/malloy_query.spec.js.map +0 -1
- package/dist/src/databases/bigquery/performance.skipped.spec.d.ts +0 -1
- package/dist/src/databases/bigquery/performance.skipped.spec.js +0 -70
- package/dist/src/databases/bigquery/performance.skipped.spec.js.map +0 -1
- package/dist/src/databases/bigquery/time.spec.d.ts +0 -1
- package/dist/src/databases/bigquery/time.spec.js +0 -52
- package/dist/src/databases/bigquery/time.spec.js.map +0 -1
- package/dist/src/databases/bigquery/wildcard_table_names.spec.d.ts +0 -1
- package/dist/src/databases/bigquery/wildcard_table_names.spec.js +0 -212
- package/dist/src/databases/bigquery/wildcard_table_names.spec.js.map +0 -1
- package/dist/src/databases/bigquery-duckdb/nested_source_table.spec.d.ts +0 -1
- package/dist/src/databases/bigquery-duckdb/nested_source_table.spec.js +0 -213
- package/dist/src/databases/bigquery-duckdb/nested_source_table.spec.js.map +0 -1
- package/dist/src/databases/duckdb/duckdb.spec.d.ts +0 -1
- package/dist/src/databases/duckdb/duckdb.spec.js +0 -124
- package/dist/src/databases/duckdb/duckdb.spec.js.map +0 -1
- package/dist/src/databases/duckdb/streaming.spec.d.ts +0 -1
- package/dist/src/databases/duckdb/streaming.spec.js +0 -142
- package/dist/src/databases/duckdb/streaming.spec.js.map +0 -1
- package/dist/src/databases/multi-connection/multi_connection.spec.d.ts +0 -1
- package/dist/src/databases/multi-connection/multi_connection.spec.js +0 -120
- package/dist/src/databases/multi-connection/multi_connection.spec.js.map +0 -1
- package/dist/src/databases/postgres/postgres.spec.d.ts +0 -1
- package/dist/src/databases/postgres/postgres.spec.js +0 -140
- package/dist/src/databases/postgres/postgres.spec.js.map +0 -1
- package/dist/src/databases/shared/test_list.d.ts +0 -3
- package/dist/src/databases/shared/test_list.js +0 -5
- package/dist/src/databases/shared/test_list.js.map +0 -1
- package/dist/src/databases/streaming/streaming.spec.d.ts +0 -1
- package/dist/src/databases/streaming/streaming.spec.js +0 -93
- package/dist/src/databases/streaming/streaming.spec.js.map +0 -1
- package/dist/src/dependencies.spec.d.ts +0 -1
- package/dist/src/dependencies.spec.js +0 -63
- package/dist/src/dependencies.spec.js.map +0 -1
- package/dist/src/index.d.ts +0 -4
- package/dist/src/index.js +0 -49
- package/dist/src/index.js.map +0 -1
- package/dist/src/jestMatcher.spec.d.ts +0 -1
- package/dist/src/jestMatcher.spec.js +0 -81
- package/dist/src/jestMatcher.spec.js.map +0 -1
- package/dist/src/model/sql_source.spec.d.ts +0 -1
- package/dist/src/model/sql_source.spec.js +0 -47
- package/dist/src/model/sql_source.spec.js.map +0 -1
- package/dist/src/models/faa_model.d.ts +0 -5
- package/dist/src/models/faa_model.js +0 -997
- package/dist/src/models/faa_model.js.map +0 -1
- package/dist/src/models/medicare_model.d.ts +0 -4
- package/dist/src/models/medicare_model.js +0 -259
- package/dist/src/models/medicare_model.js.map +0 -1
- package/dist/src/render/drill.spec.d.ts +0 -1
- package/dist/src/render/drill.spec.js +0 -107
- package/dist/src/render/drill.spec.js.map +0 -1
- package/dist/src/render/render.spec.d.ts +0 -1
- package/dist/src/render/render.spec.js +0 -548
- package/dist/src/render/render.spec.js.map +0 -1
- package/dist/src/runtimes.d.ts +0 -35
- package/dist/src/runtimes.js +0 -181
- package/dist/src/runtimes.js.map +0 -1
- package/dist/src/tags.spec.d.ts +0 -8
- package/dist/src/tags.spec.js +0 -490
- package/dist/src/tags.spec.js.map +0 -1
- package/dist/src/util/db-jest-matchers.d.ts +0 -30
- package/dist/src/util/db-jest-matchers.js +0 -157
- package/dist/src/util/db-jest-matchers.js.map +0 -1
- package/dist/src/util/index.d.ts +0 -15
- package/dist/src/util/index.js +0 -182
- package/dist/src/util/index.js.map +0 -1
- package/jest.setup.js +0 -8
package/jest.setup.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {JSDOM, VirtualConsole} from 'jsdom';
|
|
2
|
+
const {window} = new JSDOM('', {
|
|
3
|
+
virtualConsole: new VirtualConsole().sendTo(console, {omitJSDOMErrors: true}),
|
|
4
|
+
});
|
|
5
|
+
global.document = window.document;
|
|
6
|
+
global.HTMLElement = window.HTMLElement;
|
|
7
|
+
global.customElements = window.customElements;
|
|
8
|
+
global.CSSStyleSheet = window.CSSStyleSheet;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A replacement for [test()] that mimics [test.skip()]
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const testSkip: jest.It = Object.assign(
|
|
15
|
+
(name: string, fn?: jest.ProvidesCallback, timeout?: number) =>
|
|
16
|
+
test.skip(name, fn, timeout),
|
|
17
|
+
{
|
|
18
|
+
...test,
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
test.when = (condition: boolean): jest.It => {
|
|
23
|
+
if (condition) {
|
|
24
|
+
return test;
|
|
25
|
+
} else {
|
|
26
|
+
return testSkip;
|
|
27
|
+
}
|
|
28
|
+
};
|
package/package.json
CHANGED
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@jest/globals": "^29.4.3",
|
|
24
|
-
"@malloydata/db-bigquery": "^0.0.138-
|
|
25
|
-
"@malloydata/db-duckdb": "^0.0.138-
|
|
26
|
-
"@malloydata/db-postgres": "^0.0.138-
|
|
27
|
-
"@malloydata/db-snowflake": "^0.0.138-
|
|
28
|
-
"@malloydata/db-trino": "^0.0.138-
|
|
29
|
-
"@malloydata/malloy": "^0.0.138-
|
|
30
|
-
"@malloydata/render": "^0.0.138-
|
|
24
|
+
"@malloydata/db-bigquery": "^0.0.138-dev240404233606",
|
|
25
|
+
"@malloydata/db-duckdb": "^0.0.138-dev240404233606",
|
|
26
|
+
"@malloydata/db-postgres": "^0.0.138-dev240404233606",
|
|
27
|
+
"@malloydata/db-snowflake": "^0.0.138-dev240404233606",
|
|
28
|
+
"@malloydata/db-trino": "^0.0.138-dev240404233606",
|
|
29
|
+
"@malloydata/malloy": "^0.0.138-dev240404233606",
|
|
30
|
+
"@malloydata/render": "^0.0.138-dev240404233606",
|
|
31
31
|
"jsdom": "^22.1.0",
|
|
32
32
|
"luxon": "^2.4.0",
|
|
33
33
|
"madge": "^6.0.0"
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"@types/jsdom": "^21.1.1",
|
|
37
37
|
"@types/luxon": "^2.4.0"
|
|
38
38
|
},
|
|
39
|
-
"version": "0.0.138-
|
|
39
|
+
"version": "0.0.138-dev240404233606"
|
|
40
40
|
}
|
|
@@ -22,10 +22,8 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
-
|
|
27
25
|
import {RuntimeList, allDatabases} from '../../runtimes';
|
|
28
|
-
import {databasesFromEnvironmentOr
|
|
26
|
+
import {databasesFromEnvironmentOr} from '../../util';
|
|
29
27
|
import '../../util/db-jest-matchers';
|
|
30
28
|
|
|
31
29
|
const runtimes = new RuntimeList(databasesFromEnvironmentOr(allDatabases));
|
|
@@ -96,16 +94,16 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
96
94
|
});
|
|
97
95
|
|
|
98
96
|
// bigquery doesn't support row count based sampling.
|
|
99
|
-
test(
|
|
97
|
+
test.when(databaseName !== 'bigquery')(
|
|
100
98
|
`index rows count - ${databaseName}`,
|
|
101
|
-
|
|
99
|
+
async () => {
|
|
102
100
|
await expect(`
|
|
103
101
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
104
102
|
dimension: one is 'one'
|
|
105
103
|
} -> {index:one, state; sample: 10 }
|
|
106
104
|
-> {select: fieldName, weight, fieldValue; order_by: 2 desc; where: fieldName = 'one'}
|
|
107
105
|
`).malloyResultMatches(runtime, {fieldName: 'one', weight: 10});
|
|
108
|
-
}
|
|
106
|
+
}
|
|
109
107
|
);
|
|
110
108
|
|
|
111
109
|
it(`index rows count - ${databaseName}`, async () => {
|
|
@@ -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} from '../../util';
|
|
28
28
|
import {fail} from 'assert';
|
|
29
29
|
|
|
30
30
|
const runtimes = new RuntimeList(databasesFromEnvironmentOr(allDatabases));
|
|
@@ -186,16 +186,13 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
186
186
|
});
|
|
187
187
|
|
|
188
188
|
// filtered turtle expressions
|
|
189
|
-
test(
|
|
190
|
-
|
|
191
|
-
onlyIf(runtime.supportsNesting, async () => {
|
|
192
|
-
await expect(`
|
|
189
|
+
test.when(runtime.supportsNesting)('model: filtered turtle', async () => {
|
|
190
|
+
await expect(`
|
|
193
191
|
run: aircraft->{
|
|
194
192
|
nest: b is by_manufacturer + { where: aircraft_models.manufacturer ?~'B%'}
|
|
195
193
|
}
|
|
196
194
|
`).malloyResultMatches(expressionModel, {'b.manufacturer': 'BEECH'});
|
|
197
|
-
|
|
198
|
-
);
|
|
195
|
+
});
|
|
199
196
|
|
|
200
197
|
// having.
|
|
201
198
|
it('model: simple having', async () => {
|
|
@@ -210,10 +207,8 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
210
207
|
`).malloyResultMatches(expressionModel, {aircraft_count: 91});
|
|
211
208
|
});
|
|
212
209
|
|
|
213
|
-
test(
|
|
214
|
-
|
|
215
|
-
onlyIf(runtime.supportsNesting, async () => {
|
|
216
|
-
await expect(`
|
|
210
|
+
test.when(runtime.supportsNesting)('model: having in a nest', async () => {
|
|
211
|
+
await expect(`
|
|
217
212
|
run: aircraft->{
|
|
218
213
|
top: 10
|
|
219
214
|
order_by: 1
|
|
@@ -228,12 +223,11 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
228
223
|
}
|
|
229
224
|
}
|
|
230
225
|
`).malloyResultMatches(expressionModel, {'by_state.state': 'VA'});
|
|
231
|
-
|
|
232
|
-
);
|
|
226
|
+
});
|
|
233
227
|
|
|
234
|
-
test(
|
|
228
|
+
test.when(runtime.supportsNesting)(
|
|
235
229
|
'model: turtle having on main',
|
|
236
|
-
|
|
230
|
+
async () => {
|
|
237
231
|
await expect(`
|
|
238
232
|
run: aircraft->{
|
|
239
233
|
order_by: 2 asc
|
|
@@ -256,13 +250,13 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
256
250
|
`).malloyResultMatches(expressionModel, {
|
|
257
251
|
'by_state.by_city.city': 'ALBUQUERQUE',
|
|
258
252
|
});
|
|
259
|
-
}
|
|
253
|
+
}
|
|
260
254
|
);
|
|
261
255
|
|
|
262
256
|
// bigquery doesn't like to partition by floats,
|
|
263
|
-
test(
|
|
257
|
+
test.when(runtime.supportsNesting)(
|
|
264
258
|
'model: having float group by partition',
|
|
265
|
-
|
|
259
|
+
async () => {
|
|
266
260
|
await expect(`${modelText(databaseName)}
|
|
267
261
|
run: aircraft_models->{
|
|
268
262
|
order_by: 1
|
|
@@ -275,7 +269,7 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
275
269
|
aggregate: aircraft_model_count
|
|
276
270
|
}
|
|
277
271
|
}`).malloyResultMatches(runtime, {aircraft_model_count: 448});
|
|
278
|
-
}
|
|
272
|
+
}
|
|
279
273
|
);
|
|
280
274
|
|
|
281
275
|
it('model: aggregate functions distinct min max', async () => {
|
|
@@ -309,9 +303,9 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
309
303
|
|
|
310
304
|
// TODO not sure why this test needs to be skipped on postgres, feels like an oversight
|
|
311
305
|
// NOTE: unless underlying type is stored as a timestamp snowflake does not support extraction
|
|
312
|
-
test(
|
|
306
|
+
test.when(!['postgres', 'snowflake'].includes(databaseName))(
|
|
313
307
|
'model: dates named',
|
|
314
|
-
|
|
308
|
+
async () => {
|
|
315
309
|
await expect(`
|
|
316
310
|
run: ${databaseName}.table('malloytest.alltypes')->{
|
|
317
311
|
group_by:
|
|
@@ -338,7 +332,7 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
338
332
|
t_timestamp_month: new Date('2020-03-01'),
|
|
339
333
|
t_timestamp_year: new Date('2020-01-01'),
|
|
340
334
|
});
|
|
341
|
-
}
|
|
335
|
+
}
|
|
342
336
|
);
|
|
343
337
|
|
|
344
338
|
it('named query metadata undefined', async () => {
|
|
@@ -393,24 +387,21 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
393
387
|
`).malloyResultMatches(expressionModel, {a: 312});
|
|
394
388
|
});
|
|
395
389
|
|
|
396
|
-
test(
|
|
390
|
+
test.when(!['postgres', 'snowflake'].includes(runtime.connection.name))(
|
|
397
391
|
'sql safe cast',
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
async () => {
|
|
401
|
-
await expect(`
|
|
392
|
+
async () => {
|
|
393
|
+
await expect(`
|
|
402
394
|
run: ${databaseName}.sql('SELECT 1 as one') -> { select:
|
|
403
395
|
bad_date is '123':::date
|
|
404
396
|
bad_number is 'abc':::number
|
|
405
397
|
good_number is "312":::"integer"
|
|
406
398
|
}
|
|
407
399
|
`).malloyResultMatches(expressionModel, {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
)
|
|
400
|
+
bad_date: null,
|
|
401
|
+
bad_number: null,
|
|
402
|
+
good_number: 312,
|
|
403
|
+
});
|
|
404
|
+
}
|
|
414
405
|
);
|
|
415
406
|
|
|
416
407
|
it('many_field.sum() has correct locality', async () => {
|
|
@@ -620,9 +611,9 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
620
611
|
});
|
|
621
612
|
});
|
|
622
613
|
|
|
623
|
-
test(
|
|
614
|
+
test.when(runtime.supportsNesting)(
|
|
624
615
|
'query with aliasname used twice',
|
|
625
|
-
|
|
616
|
+
async () => {
|
|
626
617
|
await expect(`
|
|
627
618
|
run: aircraft->{
|
|
628
619
|
group_by: first is substr(city,1,1)
|
|
@@ -642,7 +633,7 @@ describe.each(runtimes.runtimeList)('%s', (databaseName, runtime) => {
|
|
|
642
633
|
order_by: 2 desc, 1
|
|
643
634
|
}
|
|
644
635
|
`).malloyResultMatches(expressionModel, {first_three: 'SAB'});
|
|
645
|
-
}
|
|
636
|
+
}
|
|
646
637
|
);
|
|
647
638
|
|
|
648
639
|
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} 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
|
-
test(
|
|
197
|
+
test.when(runtime.supportsNesting)(
|
|
198
198
|
`model: unnest is left join - ${database}`,
|
|
199
|
-
|
|
199
|
+
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} from '../../util';
|
|
29
29
|
import '../../util/db-jest-matchers';
|
|
30
30
|
|
|
31
31
|
const runtimes = new RuntimeList(databasesFromEnvironmentOr(allDatabases));
|
|
@@ -530,9 +530,9 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
530
530
|
});
|
|
531
531
|
});
|
|
532
532
|
|
|
533
|
-
test(
|
|
534
|
-
|
|
535
|
-
|
|
533
|
+
test.when(runtime.supportsNesting)(
|
|
534
|
+
'number as null 2 - ${databaseName}',
|
|
535
|
+
async () => {
|
|
536
536
|
// a cross join produces a Many to Many result.
|
|
537
537
|
// symmetric aggregate are needed on both sides of the join
|
|
538
538
|
// Check the row count and that sums on each side work properly.
|
|
@@ -545,7 +545,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
547
|
`).malloyResultMatches(runtime, {'ugly.foo': null});
|
|
548
|
-
}
|
|
548
|
+
}
|
|
549
549
|
);
|
|
550
550
|
|
|
551
551
|
// average should only include non-null values in the denominator
|
|
@@ -590,9 +590,9 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
590
590
|
}`).malloyResultMatches(runtime, {births_per_100k: 9742});
|
|
591
591
|
});
|
|
592
592
|
|
|
593
|
-
test(
|
|
594
|
-
|
|
595
|
-
|
|
593
|
+
test.when(runtime.supportsNesting)(
|
|
594
|
+
'ungrouped top level with nested - ${databaseName}',
|
|
595
|
+
async () => {
|
|
596
596
|
await expect(`
|
|
597
597
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
598
598
|
measure: total_births is births.sum()
|
|
@@ -606,7 +606,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
606
606
|
}
|
|
607
607
|
limit: 1000
|
|
608
608
|
}`).malloyResultMatches(runtime, {births_per_100k: 9742});
|
|
609
|
-
}
|
|
609
|
+
}
|
|
610
610
|
);
|
|
611
611
|
|
|
612
612
|
it(`ungrouped - eliminate rows - ${databaseName}`, async () => {
|
|
@@ -624,9 +624,9 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
624
624
|
]);
|
|
625
625
|
});
|
|
626
626
|
|
|
627
|
-
test(
|
|
628
|
-
|
|
629
|
-
|
|
627
|
+
test.when(runtime.supportsNesting)(
|
|
628
|
+
'ungrouped nested with no grouping above - ${databaseName}',
|
|
629
|
+
async () => {
|
|
630
630
|
await expect(`
|
|
631
631
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
632
632
|
measure: total_births is births.sum()
|
|
@@ -638,12 +638,12 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
638
638
|
aggregate: births_per_100k
|
|
639
639
|
}
|
|
640
640
|
}`).malloyResultMatches(runtime, {'by_name.births_per_100k': 66703});
|
|
641
|
-
}
|
|
641
|
+
}
|
|
642
642
|
);
|
|
643
643
|
|
|
644
|
-
test(
|
|
645
|
-
|
|
646
|
-
|
|
644
|
+
test.when(runtime.supportsNesting)(
|
|
645
|
+
'ungrouped - partial grouping - ${databaseName}',
|
|
646
|
+
async () => {
|
|
647
647
|
await expect(`
|
|
648
648
|
run: ${databaseName}.table('malloytest.airports') extend {
|
|
649
649
|
measure: c is count()
|
|
@@ -672,12 +672,12 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
672
672
|
'fac_type.all_of_this_type': 1782,
|
|
673
673
|
'fac_type.all_top': 2421,
|
|
674
674
|
});
|
|
675
|
-
}
|
|
675
|
+
}
|
|
676
676
|
);
|
|
677
677
|
|
|
678
|
-
test(
|
|
679
|
-
|
|
680
|
-
|
|
678
|
+
test.when(runtime.supportsNesting)(
|
|
679
|
+
'ungrouped - all nested - ${databaseName}',
|
|
680
|
+
async () => {
|
|
681
681
|
await expect(`
|
|
682
682
|
run: ${databaseName}.table('malloytest.airports') extend {
|
|
683
683
|
measure: c is count()
|
|
@@ -701,12 +701,12 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
701
701
|
'fac_type.all_': 1845,
|
|
702
702
|
'fac_type.all_major': 1819,
|
|
703
703
|
});
|
|
704
|
-
}
|
|
704
|
+
}
|
|
705
705
|
);
|
|
706
706
|
|
|
707
|
-
test(
|
|
708
|
-
|
|
709
|
-
|
|
707
|
+
test.when(runtime.supportsNesting)(
|
|
708
|
+
'ungrouped nested - ${databaseName}',
|
|
709
|
+
async () => {
|
|
710
710
|
await expect(`
|
|
711
711
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
712
712
|
measure: total_births is births.sum()
|
|
@@ -719,12 +719,12 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
719
719
|
}
|
|
720
720
|
}
|
|
721
721
|
`).malloyResultMatches(runtime, {'by_state.births_per_100k': 36593});
|
|
722
|
-
}
|
|
722
|
+
}
|
|
723
723
|
);
|
|
724
724
|
|
|
725
|
-
test(
|
|
726
|
-
|
|
727
|
-
|
|
725
|
+
test.when(runtime.supportsNesting)(
|
|
726
|
+
'ungrouped nested expression - ${databaseName}',
|
|
727
|
+
async () => {
|
|
728
728
|
await expect(`
|
|
729
729
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
730
730
|
measure: total_births is births.sum()
|
|
@@ -737,12 +737,12 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
737
737
|
}
|
|
738
738
|
}
|
|
739
739
|
`).malloyResultMatches(runtime, {'by_state.births_per_100k': 36593});
|
|
740
|
-
}
|
|
740
|
+
}
|
|
741
741
|
);
|
|
742
742
|
|
|
743
|
-
test(
|
|
744
|
-
|
|
745
|
-
|
|
743
|
+
test.when(runtime.supportsNesting)(
|
|
744
|
+
'ungrouped nested group by float - ${databaseName}',
|
|
745
|
+
async () => {
|
|
746
746
|
await expect(`
|
|
747
747
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
748
748
|
measure: total_births is births.sum()
|
|
@@ -755,7 +755,7 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
757
|
`).malloyResultMatches(runtime, {'by_state.ug': 62742230});
|
|
758
|
-
}
|
|
758
|
+
}
|
|
759
759
|
);
|
|
760
760
|
|
|
761
761
|
it(`run simple sql - ${databaseName}`, async () => {
|
|
@@ -822,9 +822,9 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
822
822
|
});
|
|
823
823
|
});
|
|
824
824
|
|
|
825
|
-
test(
|
|
826
|
-
|
|
827
|
-
|
|
825
|
+
test.when(runtime.supportsNesting)(
|
|
826
|
+
'all with parameters - nest - ${databaseName}',
|
|
827
|
+
async () => {
|
|
828
828
|
await expect(`
|
|
829
829
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
830
830
|
measure: total_births is births.sum()
|
|
@@ -844,31 +844,28 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
844
844
|
'by_stuff.all_births': 119809719,
|
|
845
845
|
'by_stuff.all_name': 61091215,
|
|
846
846
|
});
|
|
847
|
-
}
|
|
847
|
+
}
|
|
848
848
|
);
|
|
849
849
|
|
|
850
|
-
test(
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
async () => {
|
|
855
|
-
await expect(`
|
|
850
|
+
test.when(
|
|
851
|
+
runtime.supportsNesting && runtime.dialect.supportsPipelinesInViews
|
|
852
|
+
)(`single value to udf - ${databaseName}`, async () => {
|
|
853
|
+
await expect(`
|
|
856
854
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
857
855
|
view: fun is {
|
|
858
856
|
aggregate: t is count()
|
|
859
857
|
} -> { select: t1 is t+1 }
|
|
860
858
|
} -> { nest: fun }
|
|
861
859
|
`).malloyResultMatches(runtime, {'fun.t1': 52});
|
|
862
|
-
|
|
863
|
-
)
|
|
864
|
-
);
|
|
860
|
+
});
|
|
865
861
|
|
|
866
|
-
test(
|
|
862
|
+
test.when(
|
|
863
|
+
runtime.supportsNesting && runtime.dialect.supportsPipelinesInViews
|
|
864
|
+
)(
|
|
867
865
|
`Multi value to udf - ${databaseName}`,
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
await expect(`
|
|
866
|
+
|
|
867
|
+
async () => {
|
|
868
|
+
await expect(`
|
|
872
869
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
873
870
|
view: fun is {
|
|
874
871
|
group_by: one is 1
|
|
@@ -878,16 +875,13 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
878
875
|
nest: fun
|
|
879
876
|
}
|
|
880
877
|
`).malloyResultMatches(runtime, {'fun.t1': 52});
|
|
881
|
-
|
|
882
|
-
)
|
|
878
|
+
}
|
|
883
879
|
);
|
|
884
880
|
|
|
885
|
-
test(
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
async () => {
|
|
890
|
-
await expect(`
|
|
881
|
+
test.when(
|
|
882
|
+
runtime.supportsNesting && runtime.dialect.supportsPipelinesInViews
|
|
883
|
+
)(`Multi value to udf group by - ${databaseName}`, async () => {
|
|
884
|
+
await expect(`
|
|
891
885
|
run: ${databaseName}.table('malloytest.state_facts') extend {
|
|
892
886
|
view: fun is {
|
|
893
887
|
group_by: one is 1
|
|
@@ -897,9 +891,7 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
897
891
|
nest: fun
|
|
898
892
|
}
|
|
899
893
|
`).malloyResultMatches(runtime, {'fun.t1': 52});
|
|
900
|
-
|
|
901
|
-
)
|
|
902
|
-
);
|
|
894
|
+
});
|
|
903
895
|
|
|
904
896
|
const sql1234 = `${databaseName}.sql('SELECT 1 as ${q`a`}, 2 as ${q`b`} UNION ALL SELECT 3, 4')`;
|
|
905
897
|
|
|
@@ -991,13 +983,11 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
991
983
|
`).malloyResultMatches(runtime, {x: 30});
|
|
992
984
|
});
|
|
993
985
|
|
|
994
|
-
test(
|
|
986
|
+
test.when(runtime.supportsNesting && runtime.dialect.supportsArraysInData)(
|
|
995
987
|
`array unnest - ${databaseName}`,
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
const splitFN = getSplitFunction(databaseName);
|
|
1000
|
-
await expect(`
|
|
988
|
+
async () => {
|
|
989
|
+
const splitFN = getSplitFunction(databaseName);
|
|
990
|
+
await expect(`
|
|
1001
991
|
run: ${databaseName}.sql("""
|
|
1002
992
|
SELECT
|
|
1003
993
|
${q`city`},
|
|
@@ -1009,18 +999,15 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
1009
999
|
aggregate: c is count()
|
|
1010
1000
|
}
|
|
1011
1001
|
`).malloyResultMatches(runtime, {c: 145});
|
|
1012
|
-
|
|
1013
|
-
)
|
|
1002
|
+
}
|
|
1014
1003
|
);
|
|
1015
1004
|
|
|
1016
1005
|
// make sure we can count the total number of elements when fanning out.
|
|
1017
|
-
test(
|
|
1006
|
+
test.when(runtime.supportsNesting && runtime.dialect.supportsArraysInData)(
|
|
1018
1007
|
`array unnest x 2 - ${databaseName}`,
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
const splitFN = getSplitFunction(databaseName);
|
|
1023
|
-
await expect(`
|
|
1008
|
+
async () => {
|
|
1009
|
+
const splitFN = getSplitFunction(databaseName);
|
|
1010
|
+
await expect(`
|
|
1024
1011
|
run: ${databaseName}.sql("""
|
|
1025
1012
|
SELECT
|
|
1026
1013
|
${q`city`},
|
|
@@ -1034,16 +1021,13 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
1034
1021
|
c is words.count()
|
|
1035
1022
|
a is abreak.count()
|
|
1036
1023
|
}`).malloyResultMatches(runtime, {b: 3552, c: 4586, a: 6601});
|
|
1037
|
-
|
|
1038
|
-
)
|
|
1024
|
+
}
|
|
1039
1025
|
);
|
|
1040
1026
|
|
|
1041
|
-
test(
|
|
1027
|
+
test.when(runtime.supportsNesting && runtime.dialect.readsNestedData)(
|
|
1042
1028
|
`can unnest from file - ${databaseName}`,
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
async () => {
|
|
1046
|
-
await expect(`
|
|
1029
|
+
async () => {
|
|
1030
|
+
await expect(`
|
|
1047
1031
|
source: ga_sample is ${databaseName}.table('malloytest.ga_sample')
|
|
1048
1032
|
|
|
1049
1033
|
run: ga_sample -> {
|
|
@@ -1057,13 +1041,12 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
1057
1041
|
p is hits.product.count()
|
|
1058
1042
|
}
|
|
1059
1043
|
`).malloyResultMatches(runtime, {h: 1192, c: 681, p: 1192});
|
|
1060
|
-
|
|
1061
|
-
)
|
|
1044
|
+
}
|
|
1062
1045
|
);
|
|
1063
1046
|
|
|
1064
|
-
test(
|
|
1065
|
-
|
|
1066
|
-
|
|
1047
|
+
test.when(runtime.supportsNesting)(
|
|
1048
|
+
'nest null - ${databaseName}',
|
|
1049
|
+
async () => {
|
|
1067
1050
|
const result = await runtime
|
|
1068
1051
|
.loadQuery(
|
|
1069
1052
|
`
|
|
@@ -1091,12 +1074,12 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
1091
1074
|
const d: any = result.data.toObject();
|
|
1092
1075
|
expect(d[0]['by_state']).not.toBe(null);
|
|
1093
1076
|
expect(d[0]['by_state1']).not.toBe(null);
|
|
1094
|
-
}
|
|
1077
|
+
}
|
|
1095
1078
|
);
|
|
1096
1079
|
|
|
1097
|
-
test(
|
|
1098
|
-
|
|
1099
|
-
|
|
1080
|
+
test.when(runtime.supportsNesting)(
|
|
1081
|
+
'number as null- ${databaseName}',
|
|
1082
|
+
async () => {
|
|
1100
1083
|
const result = await runtime
|
|
1101
1084
|
.loadQuery(
|
|
1102
1085
|
`
|
|
@@ -1113,7 +1096,7 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
1113
1096
|
)
|
|
1114
1097
|
.run();
|
|
1115
1098
|
expect(result.data.path(0, 'ugly', 0, 'foo').value).toBe(null);
|
|
1116
|
-
}
|
|
1099
|
+
}
|
|
1117
1100
|
);
|
|
1118
1101
|
|
|
1119
1102
|
it(`removes surpuflous order_by - solo aggregates - ${databaseName}`, async () => {
|
|
@@ -1213,10 +1196,8 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
1213
1196
|
`).malloyResultMatches(runtime, {back});
|
|
1214
1197
|
});
|
|
1215
1198
|
|
|
1216
|
-
test(
|
|
1217
|
-
|
|
1218
|
-
onlyIf(runtime.supportsNesting, async () => {
|
|
1219
|
-
await expect(`
|
|
1199
|
+
test.when(runtime.supportsNesting)('spaces in names', async () => {
|
|
1200
|
+
await expect(`
|
|
1220
1201
|
source: \`space race\` is ${databaseName}.table('malloytest.state_facts') extend {
|
|
1221
1202
|
join_one: \`j space\` is ${databaseName}.table('malloytest.state_facts') on \`j space\`.state=state
|
|
1222
1203
|
view: \`q u e r y\` is {
|
|
@@ -1235,7 +1216,6 @@ SELECT row_to_json(finalStage) as row FROM __stage0 AS finalStage`);
|
|
|
1235
1216
|
}
|
|
1236
1217
|
run: \`space race\` -> \`q u e r y\`
|
|
1237
1218
|
`).malloyResultMatches(runtime, {'c o u n t': 24});
|
|
1238
|
-
|
|
1239
|
-
);
|
|
1219
|
+
});
|
|
1240
1220
|
});
|
|
1241
1221
|
});
|