@malloydata/malloy-tests 0.0.262 → 0.0.263-dev250414184158
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/package.json
CHANGED
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@jest/globals": "^29.4.3",
|
|
24
|
-
"@malloydata/db-bigquery": "^0.0.
|
|
25
|
-
"@malloydata/db-duckdb": "^0.0.
|
|
26
|
-
"@malloydata/db-postgres": "^0.0.
|
|
27
|
-
"@malloydata/db-snowflake": "^0.0.
|
|
28
|
-
"@malloydata/db-trino": "^0.0.
|
|
29
|
-
"@malloydata/malloy": "^0.0.
|
|
30
|
-
"@malloydata/malloy-tag": "^0.0.
|
|
31
|
-
"@malloydata/render": "^0.0.
|
|
24
|
+
"@malloydata/db-bigquery": "^0.0.263-dev250414184158",
|
|
25
|
+
"@malloydata/db-duckdb": "^0.0.263-dev250414184158",
|
|
26
|
+
"@malloydata/db-postgres": "^0.0.263-dev250414184158",
|
|
27
|
+
"@malloydata/db-snowflake": "^0.0.263-dev250414184158",
|
|
28
|
+
"@malloydata/db-trino": "^0.0.263-dev250414184158",
|
|
29
|
+
"@malloydata/malloy": "^0.0.263-dev250414184158",
|
|
30
|
+
"@malloydata/malloy-tag": "^0.0.263-dev250414184158",
|
|
31
|
+
"@malloydata/render": "^0.0.263-dev250414184158",
|
|
32
32
|
"events": "^3.3.0",
|
|
33
33
|
"jsdom": "^22.1.0",
|
|
34
34
|
"luxon": "^2.4.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"@types/jsdom": "^21.1.1",
|
|
39
39
|
"@types/luxon": "^2.4.0"
|
|
40
40
|
},
|
|
41
|
-
"version": "0.0.
|
|
41
|
+
"version": "0.0.263-dev250414184158"
|
|
42
42
|
}
|
|
@@ -5,65 +5,73 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import '../../util/db-jest-matchers';
|
|
8
|
+
import {runtimeFor} from '../runtimes';
|
|
9
|
+
import '../util/db-jest-matchers';
|
|
11
10
|
|
|
12
|
-
const
|
|
11
|
+
const runtime = runtimeFor('duckdb');
|
|
13
12
|
|
|
14
13
|
afterAll(async () => {
|
|
15
|
-
await
|
|
14
|
+
await runtime.connection.close();
|
|
16
15
|
});
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
it(
|
|
17
|
+
describe('parameters', () => {
|
|
18
|
+
it('number param used in dimension', async () => {
|
|
20
19
|
await expect(`
|
|
21
20
|
##! experimental.parameters
|
|
22
|
-
source: state_facts(param::number) is
|
|
21
|
+
source: state_facts(param::number) is duckdb.table('malloytest.state_facts') extend {
|
|
23
22
|
dimension: param_plus_one is param + 1
|
|
24
23
|
}
|
|
25
24
|
run: state_facts(param is 1) -> { group_by: param_plus_one }
|
|
26
25
|
`).malloyResultMatches(runtime, {param_plus_one: 2});
|
|
27
26
|
});
|
|
28
|
-
it(
|
|
27
|
+
it('number param used in sql function', async () => {
|
|
29
28
|
await expect(`
|
|
30
29
|
##! experimental { parameters sql_functions }
|
|
31
|
-
source: state_facts(param::number) is
|
|
30
|
+
source: state_facts(param::number) is duckdb.table('malloytest.state_facts') extend {
|
|
32
31
|
dimension: param_plus_one is sql_number("\${param} + 1")
|
|
33
32
|
}
|
|
34
33
|
run: state_facts(param is 1) -> { group_by: param_plus_one }
|
|
35
34
|
`).malloyResultMatches(runtime, {param_plus_one: 2});
|
|
36
35
|
});
|
|
37
|
-
it.skip(
|
|
36
|
+
it.skip('string param used in group_by', async () => {
|
|
38
37
|
await expect(`
|
|
39
38
|
##! experimental.parameters
|
|
40
|
-
source: state_facts(param::string) is
|
|
39
|
+
source: state_facts(param::string) is duckdb.table('malloytest.state_facts') extend {
|
|
41
40
|
dimension: param_plus_one is param
|
|
42
41
|
}
|
|
43
42
|
run: state_facts(param is "foo") -> { group_by: param_val is param }
|
|
44
43
|
`).malloyResultMatches(runtime, {param_val: 'foo'});
|
|
45
44
|
});
|
|
46
|
-
it
|
|
45
|
+
it('can filter on filter expression param', async () => {
|
|
47
46
|
await expect(`
|
|
48
47
|
##! experimental.parameters
|
|
49
|
-
source: state_facts(filter
|
|
48
|
+
source: state_facts(param::filter<string>) is duckdb.table('malloytest.state_facts') extend {
|
|
49
|
+
where: state ~ param
|
|
50
|
+
}
|
|
51
|
+
run: state_facts(param is f'CA') -> { select: state }
|
|
52
|
+
`).malloyResultMatches(runtime, {state: 'CA'});
|
|
53
|
+
});
|
|
54
|
+
it.skip('reference field in source in argument', async () => {
|
|
55
|
+
await expect(`
|
|
56
|
+
##! experimental.parameters
|
|
57
|
+
source: state_facts(filter::boolean) is duckdb.table('malloytest.state_facts') extend {
|
|
50
58
|
where: filter
|
|
51
59
|
}
|
|
52
60
|
run: state_facts(filter is state = 'CA') -> { group_by: state }
|
|
53
61
|
`).malloyResultMatches(runtime, {state: 'CA'});
|
|
54
62
|
});
|
|
55
|
-
it(
|
|
63
|
+
it('can pass param into joined source correctly', async () => {
|
|
56
64
|
await expect(`
|
|
57
65
|
##! experimental.parameters
|
|
58
66
|
source: state_facts(
|
|
59
67
|
state_filter::string
|
|
60
|
-
) is
|
|
68
|
+
) is duckdb.table('malloytest.state_facts') extend {
|
|
61
69
|
where: state = state_filter
|
|
62
70
|
}
|
|
63
71
|
|
|
64
72
|
source: state_facts2(
|
|
65
73
|
state_filter::string
|
|
66
|
-
) is
|
|
74
|
+
) is duckdb.table('malloytest.state_facts') extend {
|
|
67
75
|
where: state = state_filter
|
|
68
76
|
|
|
69
77
|
join_many: state_facts is state_facts(state_filter) on 1 = 1
|
|
@@ -77,10 +85,10 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
77
85
|
}
|
|
78
86
|
`).malloyResultMatches(runtime, {s1: 'CA', s2: 'CA', c: 1});
|
|
79
87
|
});
|
|
80
|
-
it(
|
|
88
|
+
it('can pass param into extended source', async () => {
|
|
81
89
|
await expect(`
|
|
82
90
|
##! experimental.parameters
|
|
83
|
-
source: state_facts(param::number) is
|
|
91
|
+
source: state_facts(param::number) is duckdb.table('malloytest.state_facts') extend {
|
|
84
92
|
dimension: p is param
|
|
85
93
|
}
|
|
86
94
|
source: state_facts_ext(param::number) is state_facts(param)
|
|
@@ -92,11 +100,11 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
92
100
|
// changing rename/accept/except to modify a mapping layer between the underlying
|
|
93
101
|
// source and the created source, as well as a separate way to override the definition
|
|
94
102
|
// of a field deeply (without removing it or changing its type).
|
|
95
|
-
it.skip(
|
|
103
|
+
it.skip('can use dimension that uses field that is excepted', async () => {
|
|
96
104
|
await expect(
|
|
97
105
|
`
|
|
98
106
|
##! experimental.parameters
|
|
99
|
-
source: state_facts is
|
|
107
|
+
source: state_facts is duckdb.table('malloytest.state_facts') extend {
|
|
100
108
|
dimension: state_copy is state
|
|
101
109
|
}
|
|
102
110
|
source: state_facts_ext is state_facts extend {
|
|
@@ -111,11 +119,11 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
111
119
|
`
|
|
112
120
|
).malloyResultMatches(runtime, {state_copy: 'AK'});
|
|
113
121
|
});
|
|
114
|
-
it.skip(
|
|
122
|
+
it.skip('can shadow field that is excepted, using dimension that uses field that is excepted', async () => {
|
|
115
123
|
await expect(
|
|
116
124
|
`
|
|
117
125
|
##! experimental.parameters
|
|
118
|
-
source: state_facts is
|
|
126
|
+
source: state_facts is duckdb.table('malloytest.state_facts') extend {
|
|
119
127
|
dimension: state_copy is state
|
|
120
128
|
}
|
|
121
129
|
source: state_facts_hardcode_state(state::string) is state_facts extend {
|
|
@@ -134,11 +142,11 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
134
142
|
state_copy: 'AK',
|
|
135
143
|
});
|
|
136
144
|
});
|
|
137
|
-
it(
|
|
145
|
+
it('can shadow field that is excepted', async () => {
|
|
138
146
|
await expect(
|
|
139
147
|
`
|
|
140
148
|
##! experimental.parameters
|
|
141
|
-
source: state_facts is
|
|
149
|
+
source: state_facts is duckdb.table('malloytest.state_facts')
|
|
142
150
|
source: state_facts_hardcode_state(state::string) is state_facts extend {
|
|
143
151
|
except: state
|
|
144
152
|
dimension: hardcoded_state is state
|
|
@@ -150,33 +158,33 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
150
158
|
`
|
|
151
159
|
).malloyResultMatches(runtime, {hardcoded_state: 'NOT A STATE'});
|
|
152
160
|
});
|
|
153
|
-
it(
|
|
161
|
+
it('default value propagates', async () => {
|
|
154
162
|
await expect(
|
|
155
163
|
`
|
|
156
164
|
##! experimental.parameters
|
|
157
|
-
source: ab_new(param::number is 10) is
|
|
165
|
+
source: ab_new(param::number is 10) is duckdb.table('malloytest.state_facts') extend {
|
|
158
166
|
dimension: param_value is param
|
|
159
167
|
}
|
|
160
168
|
run: ab_new -> { group_by: param_value }
|
|
161
169
|
`
|
|
162
170
|
).malloyResultMatches(runtime, {param_value: 10});
|
|
163
171
|
});
|
|
164
|
-
it(
|
|
172
|
+
it('default value can be overridden', async () => {
|
|
165
173
|
await expect(
|
|
166
174
|
`
|
|
167
175
|
##! experimental.parameters
|
|
168
|
-
source: ab_new(param::number is 10) is
|
|
176
|
+
source: ab_new(param::number is 10) is duckdb.table('malloytest.state_facts') extend {
|
|
169
177
|
dimension: param_value is param
|
|
170
178
|
}
|
|
171
179
|
run: ab_new(param is 11) -> { group_by: param_value }
|
|
172
180
|
`
|
|
173
181
|
).malloyResultMatches(runtime, {param_value: 11});
|
|
174
182
|
});
|
|
175
|
-
it(
|
|
183
|
+
it('default value passed through extension propagates', async () => {
|
|
176
184
|
await expect(
|
|
177
185
|
`
|
|
178
186
|
##! experimental.parameters
|
|
179
|
-
source: ab_new(param::number is 10) is
|
|
187
|
+
source: ab_new(param::number is 10) is duckdb.table('malloytest.state_facts') extend {
|
|
180
188
|
dimension: param_value is param
|
|
181
189
|
}
|
|
182
190
|
source: ab_new_new(param::number is 11) is ab_new(param) extend {}
|
|
@@ -184,11 +192,11 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
184
192
|
`
|
|
185
193
|
).malloyResultMatches(runtime, {param_value: 11});
|
|
186
194
|
});
|
|
187
|
-
it(
|
|
195
|
+
it('use parameter in nested view', async () => {
|
|
188
196
|
await expect(
|
|
189
197
|
`
|
|
190
198
|
##! experimental.parameters
|
|
191
|
-
source: ab_new(param::number is 10) is
|
|
199
|
+
source: ab_new(param::number is 10) is duckdb.table('malloytest.state_facts') extend {
|
|
192
200
|
dimension: param_value_1 is param
|
|
193
201
|
view: v is {
|
|
194
202
|
group_by: param_value_1
|
|
@@ -208,18 +216,18 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
208
216
|
'n.param_value_3': 10,
|
|
209
217
|
});
|
|
210
218
|
});
|
|
211
|
-
it.skip(
|
|
219
|
+
it.skip('can pass param into joined source from query', async () => {
|
|
212
220
|
await expect(`
|
|
213
221
|
##! experimental.parameters
|
|
214
222
|
source: state_facts(
|
|
215
223
|
state_filter::string
|
|
216
|
-
) is
|
|
224
|
+
) is duckdb.table('malloytest.state_facts') extend {
|
|
217
225
|
where: state = state_filter
|
|
218
226
|
}
|
|
219
227
|
|
|
220
228
|
source: state_facts2(
|
|
221
229
|
state_filter::string
|
|
222
|
-
) is
|
|
230
|
+
) is duckdb.table('malloytest.state_facts') extend {
|
|
223
231
|
where: state = state_filter
|
|
224
232
|
|
|
225
233
|
join_many: state_facts is (state_facts(state_filter) -> { select: * }) on 1 = 1
|
|
@@ -233,12 +241,12 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
233
241
|
}
|
|
234
242
|
`).malloyResultMatches(runtime, {s1: 'CA', s2: 'CA', c: 1});
|
|
235
243
|
});
|
|
236
|
-
it.skip(
|
|
244
|
+
it.skip('can pass param into query definition', async () => {
|
|
237
245
|
await expect(`
|
|
238
246
|
##! experimental.parameters
|
|
239
247
|
source: state_facts(
|
|
240
248
|
state_filter::string
|
|
241
|
-
) is
|
|
249
|
+
) is duckdb.table('malloytest.state_facts') extend {
|
|
242
250
|
where: state = state_filter
|
|
243
251
|
}
|
|
244
252
|
|
|
@@ -249,14 +257,14 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
249
257
|
}
|
|
250
258
|
`).malloyResultMatches(runtime, {state: 'CA'});
|
|
251
259
|
});
|
|
252
|
-
it(
|
|
260
|
+
it('can use param in join on', async () => {
|
|
253
261
|
await expect(`
|
|
254
262
|
##! experimental.parameters
|
|
255
|
-
source: state_facts is
|
|
263
|
+
source: state_facts is duckdb.table('malloytest.state_facts')
|
|
256
264
|
|
|
257
265
|
source: state_facts2(
|
|
258
266
|
state_filter::string
|
|
259
|
-
) is
|
|
267
|
+
) is duckdb.table('malloytest.state_facts') extend {
|
|
260
268
|
where: state = state_filter
|
|
261
269
|
|
|
262
270
|
join_many: state_facts on state_facts.state = state_filter
|
|
@@ -270,16 +278,16 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
270
278
|
}
|
|
271
279
|
`).malloyResultMatches(runtime, {s1: 'CA', s2: 'CA', c: 1});
|
|
272
280
|
});
|
|
273
|
-
it(
|
|
281
|
+
it('can use param in join with', async () => {
|
|
274
282
|
await expect(`
|
|
275
283
|
##! experimental.parameters
|
|
276
|
-
source: state_facts is
|
|
284
|
+
source: state_facts is duckdb.table('malloytest.state_facts') extend {
|
|
277
285
|
primary_key: state
|
|
278
286
|
}
|
|
279
287
|
|
|
280
288
|
source: state_facts2(
|
|
281
289
|
state_filter::string
|
|
282
|
-
) is
|
|
290
|
+
) is duckdb.table('malloytest.state_facts') extend {
|
|
283
291
|
where: state = state_filter
|
|
284
292
|
|
|
285
293
|
join_one: state_facts with state_filter
|
|
@@ -293,10 +301,10 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
293
301
|
}
|
|
294
302
|
`).malloyResultMatches(runtime, {s1: 'CA', s2: 'CA', c: 1});
|
|
295
303
|
});
|
|
296
|
-
it(
|
|
304
|
+
it('source arguments in query propagate when turned into source', async () => {
|
|
297
305
|
await expect(`
|
|
298
306
|
##! experimental.parameters
|
|
299
|
-
source: ab_new(param::number) is
|
|
307
|
+
source: ab_new(param::number) is duckdb.table('malloytest.state_facts') extend {
|
|
300
308
|
dimension: param_value is param
|
|
301
309
|
}
|
|
302
310
|
query: foo is ab_new(param is 1) -> { select: param_value }
|
|
@@ -304,32 +312,32 @@ runtimes.runtimeMap.forEach((runtime, databaseName) => {
|
|
|
304
312
|
run: foo_ext -> { select: param_value }
|
|
305
313
|
`).malloyResultMatches(runtime, {param_value: 1});
|
|
306
314
|
});
|
|
307
|
-
it(
|
|
315
|
+
it('date parameters keep granularity when passing in', async () => {
|
|
308
316
|
await expect(`
|
|
309
317
|
##! experimental.parameters
|
|
310
|
-
source: state_facts(param::date) is
|
|
318
|
+
source: state_facts(param::date) is duckdb.table('malloytest.state_facts') extend {
|
|
311
319
|
dimension: date_value is day(param)
|
|
312
320
|
}
|
|
313
321
|
run: state_facts(param is @2024-04-11.month) -> { group_by: date_value }
|
|
314
322
|
`).malloyResultMatches(runtime, {date_value: 1});
|
|
315
323
|
});
|
|
316
|
-
it(
|
|
324
|
+
it('can use parameter in null check', async () => {
|
|
317
325
|
await expect(`
|
|
318
326
|
##! experimental.parameters
|
|
319
327
|
source: state_facts(
|
|
320
328
|
param::string is null,
|
|
321
329
|
state_filter::string is "CA"
|
|
322
|
-
) is
|
|
330
|
+
) is duckdb.table('malloytest.state_facts') extend {
|
|
323
331
|
where: param is null and state = state_filter
|
|
324
332
|
}
|
|
325
333
|
run: state_facts -> { group_by: state }
|
|
326
334
|
`).malloyResultMatches(runtime, {state: 'CA'});
|
|
327
335
|
});
|
|
328
|
-
it(
|
|
336
|
+
it('default value not passed through extension propagates', async () => {
|
|
329
337
|
await expect(
|
|
330
338
|
`
|
|
331
339
|
##! experimental.parameters
|
|
332
|
-
source: ab_new(param::number is 10) is
|
|
340
|
+
source: ab_new(param::number is 10) is duckdb.table('malloytest.state_facts') extend {
|
|
333
341
|
dimension: param_value is param
|
|
334
342
|
}
|
|
335
343
|
source: ab_new_new is ab_new extend {}
|