@malloydata/malloy-tests 0.0.88-dev231002231014 → 0.0.88-dev231002235732
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/api.spec.js +2 -2
- package/dist/api.spec.js.map +1 -1
- package/dist/databases/all/db_index.spec.js +3 -3
- package/dist/databases/all/expr.spec.js +9 -9
- package/dist/databases/all/expr.spec.js.map +1 -1
- package/dist/databases/all/functions.spec.js +3 -3
- package/dist/databases/all/join.spec.js +35 -37
- package/dist/databases/all/join.spec.js.map +1 -1
- package/dist/databases/all/nomodel.spec.js +19 -19
- package/dist/databases/all/nomodel.spec.js.map +1 -1
- package/dist/databases/all/orderby.spec.js +5 -5
- package/dist/databases/all/problems.spec.js +5 -5
- package/dist/databases/all/problems.spec.js.map +1 -1
- package/dist/databases/all/sql_expressions.spec.js +3 -3
- package/dist/databases/all/time.spec.js +10 -10
- package/dist/databases/bigquery/json.spec.js +1 -1
- package/dist/databases/bigquery/malloy_query.spec.js +7 -7
- package/dist/databases/bigquery/time.spec.js +1 -1
- package/dist/databases/bigquery-duckdb/nested_source_table.spec.js +4 -4
- package/dist/databases/bigquery-postgres/multi_connection.spec.js +4 -4
- package/dist/databases/bigquery-postgres/streaming.spec.js +3 -3
- package/dist/databases/bigquery-postgres/streaming.spec.js.map +1 -1
- package/dist/databases/duckdb/duckdb.spec.js +2 -2
- package/dist/databases/postgres/postgres.spec.js +7 -7
- package/dist/render/render.spec.js +12 -12
- package/dist/tags.spec.js +46 -46
- package/dist/tags.spec.js.map +1 -1
- package/dist/util/index.js +8 -8
- package/dist/util/index.js.map +1 -1
- package/package.json +6 -6
- package/src/api.spec.ts +2 -2
- package/src/databases/all/db_index.spec.ts +3 -3
- package/src/databases/all/expr.spec.ts +9 -9
- package/src/databases/all/functions.spec.ts +3 -3
- package/src/databases/all/join.spec.ts +35 -37
- package/src/databases/all/nomodel.spec.ts +19 -19
- package/src/databases/all/orderby.spec.ts +5 -5
- package/src/databases/all/problems.spec.ts +5 -5
- package/src/databases/all/sql_expressions.spec.ts +3 -3
- package/src/databases/all/time.spec.ts +10 -10
- package/src/databases/bigquery/json.spec.ts +1 -1
- package/src/databases/bigquery/malloy_query.spec.ts +7 -7
- package/src/databases/bigquery/time.spec.ts +1 -1
- package/src/databases/bigquery-duckdb/nested_source_table.spec.ts +4 -4
- package/src/databases/bigquery-postgres/multi_connection.spec.ts +4 -4
- package/src/databases/bigquery-postgres/streaming.spec.ts +3 -3
- package/src/databases/duckdb/duckdb.spec.ts +2 -2
- package/src/databases/postgres/postgres.spec.ts +7 -7
- package/src/render/render.spec.ts +12 -12
- package/src/tags.spec.ts +46 -46
- package/src/util/index.ts +8 -8
|
@@ -58,7 +58,7 @@ describe('Streaming tests', () => {
|
|
|
58
58
|
it(`basic stream test - ${databaseName}`, async () => {
|
|
59
59
|
const stream = runtime
|
|
60
60
|
.loadModel("source: airports is table('malloytest.airports') {}")
|
|
61
|
-
.loadQuery('query: airports -> {
|
|
61
|
+
.loadQuery('query: airports -> { select: code }')
|
|
62
62
|
.runStream({rowLimit: 10});
|
|
63
63
|
const rows: DataRecord[] = [];
|
|
64
64
|
for await (const row of stream) {
|
|
@@ -71,7 +71,7 @@ describe('Streaming tests', () => {
|
|
|
71
71
|
it(`stream to JSON - ${databaseName}`, async () => {
|
|
72
72
|
const stream = runtime
|
|
73
73
|
.loadModel("source: airports is table('malloytest.airports') {}")
|
|
74
|
-
.loadQuery('query: airports -> {
|
|
74
|
+
.loadQuery('query: airports -> { select: code }')
|
|
75
75
|
.runStream({rowLimit: 1});
|
|
76
76
|
const accummulator = new StringAccumulator();
|
|
77
77
|
const jsonWriter = new JSONWriter(accummulator);
|
|
@@ -89,7 +89,7 @@ describe('Streaming tests', () => {
|
|
|
89
89
|
it(`stream to CSV - ${databaseName}`, async () => {
|
|
90
90
|
const stream = runtime
|
|
91
91
|
.loadModel("source: airports is table('malloytest.airports') {}")
|
|
92
|
-
.loadQuery('query: airports -> {
|
|
92
|
+
.loadQuery('query: airports -> { select: code }')
|
|
93
93
|
.runStream({rowLimit: 1});
|
|
94
94
|
const accummulator = new StringAccumulator();
|
|
95
95
|
const csvWriter = new CSVWriter(accummulator);
|
|
@@ -84,7 +84,7 @@ describe.each(allDucks.runtimeList)('duckdb:%s', (dbName, runtime) => {
|
|
|
84
84
|
.loadQuery(
|
|
85
85
|
`
|
|
86
86
|
query: table('duckdb:test/data/duckdb/test.json') -> {
|
|
87
|
-
|
|
87
|
+
select: *
|
|
88
88
|
}
|
|
89
89
|
`
|
|
90
90
|
)
|
|
@@ -118,7 +118,7 @@ describe.each(allDucks.runtimeList)('duckdb:%s', (dbName, runtime) => {
|
|
|
118
118
|
SELECT TIMESTAMPTZ '2020-02-20 00:00:00 ${zone}' as t_tstz
|
|
119
119
|
"""}
|
|
120
120
|
query: from_sql(timeData) -> {
|
|
121
|
-
|
|
121
|
+
select: mex_220 is t_tstz::timestamp
|
|
122
122
|
}`,
|
|
123
123
|
{mex_220: zone_2020.toJSDate()}
|
|
124
124
|
);
|
|
@@ -64,7 +64,7 @@ describe('Postgres tests', () => {
|
|
|
64
64
|
SELECT 1 as n
|
|
65
65
|
"""}
|
|
66
66
|
|
|
67
|
-
query: from_sql(one) -> {
|
|
67
|
+
query: from_sql(one) -> { select: n }
|
|
68
68
|
`
|
|
69
69
|
)
|
|
70
70
|
.run();
|
|
@@ -79,7 +79,7 @@ describe('Postgres tests', () => {
|
|
|
79
79
|
SELECT 1 as "upperLower"
|
|
80
80
|
"""}
|
|
81
81
|
|
|
82
|
-
query: from_sql(one) -> {
|
|
82
|
+
query: from_sql(one) -> { select: upperLower }
|
|
83
83
|
`
|
|
84
84
|
)
|
|
85
85
|
.run();
|
|
@@ -95,7 +95,7 @@ describe('Postgres tests', () => {
|
|
|
95
95
|
"""}
|
|
96
96
|
|
|
97
97
|
query: from_sql(one) -> {
|
|
98
|
-
|
|
98
|
+
select:
|
|
99
99
|
select
|
|
100
100
|
create is select + 1
|
|
101
101
|
}
|
|
@@ -111,7 +111,7 @@ describe('Postgres tests', () => {
|
|
|
111
111
|
const result = await runtime
|
|
112
112
|
.loadQuery(
|
|
113
113
|
`
|
|
114
|
-
query: table('public.UpperTablePublic') -> {
|
|
114
|
+
query: table('public.UpperTablePublic') -> { select: one }
|
|
115
115
|
`
|
|
116
116
|
)
|
|
117
117
|
.run();
|
|
@@ -122,7 +122,7 @@ describe('Postgres tests', () => {
|
|
|
122
122
|
const result = await runtime
|
|
123
123
|
.loadQuery(
|
|
124
124
|
`
|
|
125
|
-
query: table('UpperSchema.UpperSchemaUpperTable') -> {
|
|
125
|
+
query: table('UpperSchema.UpperSchemaUpperTable') -> { select: one }
|
|
126
126
|
`
|
|
127
127
|
)
|
|
128
128
|
.run();
|
|
@@ -134,7 +134,7 @@ describe('Postgres tests', () => {
|
|
|
134
134
|
.loadQuery(
|
|
135
135
|
`
|
|
136
136
|
sql: badType is { select: """SELECT int4range(10, 20) as ranger""" }
|
|
137
|
-
query: from_sql(badType)->{
|
|
137
|
+
query: from_sql(badType)->{ select: *}
|
|
138
138
|
`
|
|
139
139
|
)
|
|
140
140
|
.run();
|
|
@@ -158,7 +158,7 @@ describe('Postgres tests', () => {
|
|
|
158
158
|
SELECT TIMESTAMPTZ '2020-02-20 00:00:00 ${zone}' as t_tstz
|
|
159
159
|
"""}
|
|
160
160
|
query: from_sql(timeData) -> {
|
|
161
|
-
|
|
161
|
+
select: mex_220 is t_tstz::timestamp
|
|
162
162
|
}`,
|
|
163
163
|
{mex_220: zone_2020.toJSDate()}
|
|
164
164
|
);
|
|
@@ -39,7 +39,7 @@ async function runUnsupportedRenderTest(
|
|
|
39
39
|
const src = `
|
|
40
40
|
query: q is
|
|
41
41
|
${connectionName}.sql("""SELECT ${expr} AS test""")
|
|
42
|
-
-> {
|
|
42
|
+
-> { select: * }
|
|
43
43
|
`;
|
|
44
44
|
const result = await runtime.loadModel(src).loadQueryByName('q').run();
|
|
45
45
|
// console.log("DATA", result.data.toObject());
|
|
@@ -221,11 +221,11 @@ describe('rendering results', () => {
|
|
|
221
221
|
nest: height_by_age
|
|
222
222
|
# line_chart
|
|
223
223
|
is {
|
|
224
|
-
|
|
224
|
+
select: monthy, height
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
nest: weight_by_age_bar_chart is {
|
|
228
|
-
|
|
228
|
+
select: monthy, wt
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
aggregate:
|
|
@@ -296,7 +296,7 @@ describe('rendering results', () => {
|
|
|
296
296
|
order_by: nm
|
|
297
297
|
nest: height_by_age
|
|
298
298
|
is {
|
|
299
|
-
|
|
299
|
+
select:
|
|
300
300
|
# hidden
|
|
301
301
|
monthy,
|
|
302
302
|
height
|
|
@@ -305,12 +305,12 @@ describe('rendering results', () => {
|
|
|
305
305
|
# hidden
|
|
306
306
|
nest: height_by_age_hidden
|
|
307
307
|
is {
|
|
308
|
-
|
|
308
|
+
select: monthy, height
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
# list
|
|
312
312
|
nest: monthy is {
|
|
313
|
-
|
|
313
|
+
select: price
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
aggregate:
|
|
@@ -419,7 +419,7 @@ describe('rendering results', () => {
|
|
|
419
419
|
const src = `
|
|
420
420
|
query: mex_query is duckdb.sql('SELECT 1') -> {
|
|
421
421
|
timezone: 'America/Mexico_City'
|
|
422
|
-
|
|
422
|
+
select: mex_time is @2021-02-24 03:05:06
|
|
423
423
|
}
|
|
424
424
|
`;
|
|
425
425
|
const result = await (
|
|
@@ -443,7 +443,7 @@ describe('rendering results', () => {
|
|
|
443
443
|
|
|
444
444
|
query:
|
|
445
445
|
data_trunc is timeDataTrunc -> {
|
|
446
|
-
|
|
446
|
+
select: yr is times.year, qt is times.quarter, mt is times.month, dy is times.day
|
|
447
447
|
}
|
|
448
448
|
`;
|
|
449
449
|
const result = await (
|
|
@@ -464,7 +464,7 @@ describe('rendering results', () => {
|
|
|
464
464
|
query: mex_query # bar_chart
|
|
465
465
|
is duckdb.sql('SELECT 1') -> {
|
|
466
466
|
timezone: 'America/Mexico_City'
|
|
467
|
-
|
|
467
|
+
select: mex_time is @2021-02-24 03:05:06
|
|
468
468
|
}
|
|
469
469
|
`;
|
|
470
470
|
const result = await (
|
|
@@ -507,7 +507,7 @@ describe('rendering results', () => {
|
|
|
507
507
|
test('value format tags works correctly', async () => {
|
|
508
508
|
const src = `
|
|
509
509
|
query: number_query is duckdb.sql('SELECT 12.345 as anumber') -> {
|
|
510
|
-
|
|
510
|
+
select:
|
|
511
511
|
anumber
|
|
512
512
|
# number= "#,##0.0000"
|
|
513
513
|
larger is anumber
|
|
@@ -531,7 +531,7 @@ describe('rendering results', () => {
|
|
|
531
531
|
test('data volume tags works correctly', async () => {
|
|
532
532
|
const src = `
|
|
533
533
|
query: bytes_query is duckdb.sql('SELECT 1') -> {
|
|
534
|
-
|
|
534
|
+
select:
|
|
535
535
|
# data_volume = bytes
|
|
536
536
|
usage_b is 3758
|
|
537
537
|
# data_volume = kb
|
|
@@ -560,7 +560,7 @@ describe('rendering results', () => {
|
|
|
560
560
|
test('duration tags works correctly', async () => {
|
|
561
561
|
const src = `
|
|
562
562
|
query: duration_query is duckdb.sql('SELECT 1') -> {
|
|
563
|
-
|
|
563
|
+
select:
|
|
564
564
|
# duration = nanoseconds
|
|
565
565
|
ns1 is 1
|
|
566
566
|
# duration = nanoseconds
|
package/src/tags.spec.ts
CHANGED
|
@@ -277,11 +277,11 @@ describe('tags in results', () => {
|
|
|
277
277
|
test('nameless query', async () => {
|
|
278
278
|
const loaded = runtime.loadQuery(
|
|
279
279
|
`
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
280
|
+
## modelDef=ok
|
|
281
|
+
source: one is duckdb.sql("SELECT 1 as one")
|
|
282
|
+
# b4query
|
|
283
|
+
run: # afterQuery import=$(modelDef)
|
|
284
|
+
one -> { select: * }`
|
|
285
285
|
);
|
|
286
286
|
const qTag = {b4query: {}, afterQuery: {}, import: {eq: 'ok'}};
|
|
287
287
|
const query = await loaded.getPreparedQuery();
|
|
@@ -294,17 +294,18 @@ describe('tags in results', () => {
|
|
|
294
294
|
test('named query', async () => {
|
|
295
295
|
const loaded = runtime.loadQuery(
|
|
296
296
|
`
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
297
|
+
## modelDef=ok
|
|
298
|
+
source: one is duckdb.sql("SELECT 1 as one")
|
|
299
|
+
# BQ
|
|
300
|
+
query: # AQ
|
|
301
|
+
# import=$(modelDef)
|
|
302
|
+
theName
|
|
303
|
+
# Bis
|
|
304
|
+
is
|
|
305
|
+
# Ais
|
|
306
|
+
one -> { select: * }
|
|
307
|
+
run: theName
|
|
308
|
+
`
|
|
308
309
|
);
|
|
309
310
|
const query = await loaded.getPreparedQuery();
|
|
310
311
|
expect(query).toBeDefined();
|
|
@@ -315,18 +316,18 @@ describe('tags in results', () => {
|
|
|
315
316
|
test('turtle query', async () => {
|
|
316
317
|
const loaded = runtime.loadQuery(
|
|
317
318
|
`
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
319
|
+
## modelDef=ok
|
|
320
|
+
source: one is duckdb.sql("SELECT 1 as one") extend {
|
|
321
|
+
# BQ import=$(modelDef)
|
|
322
|
+
view: # AQ
|
|
323
|
+
in_one
|
|
324
|
+
# Bis
|
|
325
|
+
is
|
|
326
|
+
# Ais
|
|
327
|
+
{ select: one }
|
|
328
|
+
}
|
|
329
|
+
run: one -> in_one
|
|
330
|
+
`
|
|
330
331
|
);
|
|
331
332
|
const query = await loaded.getPreparedQuery();
|
|
332
333
|
expect(query).toBeDefined();
|
|
@@ -338,9 +339,9 @@ describe('tags in results', () => {
|
|
|
338
339
|
const loaded = runtime.loadQuery(
|
|
339
340
|
`
|
|
340
341
|
## modelDef=ok
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
342
|
+
source: one is duckdb.sql("SELECT 1 as one")
|
|
343
|
+
run: one -> {
|
|
344
|
+
select:
|
|
344
345
|
# note1 import=$(modelDef)
|
|
345
346
|
one
|
|
346
347
|
}`
|
|
@@ -357,12 +358,12 @@ describe('tags in results', () => {
|
|
|
357
358
|
const loaded = runtime.loadQuery(
|
|
358
359
|
`
|
|
359
360
|
## modelDef=ok
|
|
360
|
-
|
|
361
|
-
source: malloy_one is
|
|
362
|
-
|
|
363
|
-
|
|
361
|
+
source: one is duckdb.sql("SELECT 1 as one")
|
|
362
|
+
source: malloy_one is one extend {
|
|
363
|
+
view: in_one is {
|
|
364
|
+
select: one
|
|
364
365
|
}
|
|
365
|
-
|
|
366
|
+
view: one_and_one is {
|
|
366
367
|
group_by: one
|
|
367
368
|
# note1
|
|
368
369
|
nest:
|
|
@@ -370,7 +371,7 @@ describe('tags in results', () => {
|
|
|
370
371
|
in_one
|
|
371
372
|
}
|
|
372
373
|
}
|
|
373
|
-
|
|
374
|
+
run: malloy_one -> one_and_one`
|
|
374
375
|
);
|
|
375
376
|
const result = await loaded.run();
|
|
376
377
|
const shape = result.resultExplore;
|
|
@@ -388,20 +389,20 @@ describe('tags in results', () => {
|
|
|
388
389
|
source: ages is duckdb.sql('SELECT 1 as one') extend {
|
|
389
390
|
# name
|
|
390
391
|
dimension: name is 'John'
|
|
391
|
-
|
|
392
|
+
view: height
|
|
392
393
|
# barchart
|
|
393
394
|
is {
|
|
394
|
-
|
|
395
|
+
select: heightd is 10
|
|
395
396
|
}
|
|
396
397
|
|
|
397
|
-
|
|
398
|
+
view: age
|
|
398
399
|
# barchart
|
|
399
400
|
is {
|
|
400
|
-
|
|
401
|
+
select: aged is 20
|
|
401
402
|
}
|
|
402
403
|
|
|
403
404
|
}
|
|
404
|
-
|
|
405
|
+
run: ages -> {
|
|
405
406
|
group_by: name
|
|
406
407
|
nest: height
|
|
407
408
|
nest: age
|
|
@@ -417,13 +418,12 @@ describe('tags in results', () => {
|
|
|
417
418
|
expect(age.tagParse().tag).tagsAre({barchart: {}});
|
|
418
419
|
expect(name.tagParse().tag).tagsAre({name: {}});
|
|
419
420
|
});
|
|
420
|
-
test('User
|
|
421
|
+
test('User defined scopes nest properly', async () => {
|
|
421
422
|
const loaded = runtime.loadQuery(
|
|
422
423
|
`
|
|
423
424
|
## scope=model
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
project:
|
|
425
|
+
run: duckdb.sql("SELECT 1 as one") -> {
|
|
426
|
+
select:
|
|
427
427
|
# valueFrom=$(scope)
|
|
428
428
|
one
|
|
429
429
|
}`
|
package/src/util/index.ts
CHANGED
|
@@ -120,7 +120,7 @@ export function mkSqlEqWith(runtime: Runtime, initV?: InitValues) {
|
|
|
120
120
|
query: basicTypes
|
|
121
121
|
-> {
|
|
122
122
|
declare: ${varName} is ${expr}
|
|
123
|
-
|
|
123
|
+
select: calc is pick ${whenPick} else ${elsePick}
|
|
124
124
|
}`;
|
|
125
125
|
} else if (typeof result === 'number') {
|
|
126
126
|
query = `${sourceDef}
|
|
@@ -128,7 +128,7 @@ export function mkSqlEqWith(runtime: Runtime, initV?: InitValues) {
|
|
|
128
128
|
-> {
|
|
129
129
|
declare: expect is ${result}
|
|
130
130
|
declare: got is ${expr}
|
|
131
|
-
|
|
131
|
+
select: calc is
|
|
132
132
|
pick '=' when expect = got
|
|
133
133
|
else concat('sqlEq failed', CHR(10), ' Expected: ${qExpr} == ${result}', CHR(10), ' Received: ', got::string)
|
|
134
134
|
}`;
|
|
@@ -139,10 +139,10 @@ export function mkSqlEqWith(runtime: Runtime, initV?: InitValues) {
|
|
|
139
139
|
query = `${sourceDef}
|
|
140
140
|
query: basicTypes
|
|
141
141
|
-> {
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
select: expect is ${qResult}
|
|
143
|
+
select: got is ${expr}
|
|
144
144
|
} -> {
|
|
145
|
-
|
|
145
|
+
select: calc is
|
|
146
146
|
pick '=' when expect = got
|
|
147
147
|
else concat('sqlEq failed', CHR(10), ' Expected: ${sqlSafe(
|
|
148
148
|
expr
|
|
@@ -153,10 +153,10 @@ export function mkSqlEqWith(runtime: Runtime, initV?: InitValues) {
|
|
|
153
153
|
query = `${sourceDef}
|
|
154
154
|
query: basicTypes
|
|
155
155
|
-> {
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
select: expect is ${result}
|
|
157
|
+
select: got is ${expr}
|
|
158
158
|
} -> {
|
|
159
|
-
|
|
159
|
+
select: calc is
|
|
160
160
|
pick '=' when expect = got
|
|
161
161
|
else concat('sqlEq failed', CHR(10), ' Expected: ${qExpr} == ${qResult}', CHR(10), ' Received: ', got::string)
|
|
162
162
|
}`;
|