@malloydata/malloy 0.0.240-dev250311202829 → 0.0.240-dev250311214430
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/core.d.ts +1 -0
- package/dist/api/core.js +2 -1
- package/dist/lang/malloy-parse-info.d.ts +2 -10
- package/dist/lang/malloy-to-ast.d.ts +1 -0
- package/dist/lang/malloy-to-ast.js +9 -6
- package/dist/lang/malloy-to-stable-query.d.ts +76 -0
- package/dist/lang/malloy-to-stable-query.js +660 -0
- package/dist/lang/parse-log.d.ts +1 -0
- package/dist/lang/parse-malloy.d.ts +2 -9
- package/dist/lang/parse-malloy.js +7 -112
- package/dist/lang/parse-tree-walkers/model-annotation-walker.js +1 -1
- package/dist/lang/run-malloy-parser.d.ts +3 -0
- package/dist/lang/run-malloy-parser.js +53 -0
- package/dist/lang/syntax-errors/malloy-parser-error-listener.d.ts +4 -3
- package/dist/lang/syntax-errors/malloy-parser-error-listener.js +8 -4
- package/dist/lang/utils.d.ts +27 -1
- package/dist/lang/utils.js +78 -1
- package/package.json +3 -3
- package/dist/api/asynchronous.spec.d.ts +0 -1
- package/dist/api/asynchronous.spec.js +0 -240
- package/dist/api/sessioned.spec.d.ts +0 -1
- package/dist/api/sessioned.spec.js +0 -476
- package/dist/api/stateless.spec.d.ts +0 -1
- package/dist/api/stateless.spec.js +0 -400
- package/dist/lang/test/annotation.spec.d.ts +0 -14
- package/dist/lang/test/annotation.spec.js +0 -809
- package/dist/lang/test/composite-field-usage.spec.d.ts +0 -1
- package/dist/lang/test/composite-field-usage.spec.js +0 -261
- package/dist/lang/test/document-help-context-walker.spec.d.ts +0 -1
- package/dist/lang/test/document-help-context-walker.spec.js +0 -55
- package/dist/lang/test/document-symbol-walker.spec.d.ts +0 -1
- package/dist/lang/test/document-symbol-walker.spec.js +0 -209
- package/dist/lang/test/expressions.spec.d.ts +0 -1
- package/dist/lang/test/expressions.spec.js +0 -1181
- package/dist/lang/test/field-symbols.spec.d.ts +0 -1
- package/dist/lang/test/field-symbols.spec.js +0 -194
- package/dist/lang/test/find-table-path-walker.spec.d.ts +0 -1
- package/dist/lang/test/find-table-path-walker.spec.js +0 -50
- package/dist/lang/test/imports.spec.d.ts +0 -1
- package/dist/lang/test/imports.spec.js +0 -283
- package/dist/lang/test/lenses.spec.d.ts +0 -1
- package/dist/lang/test/lenses.spec.js +0 -384
- package/dist/lang/test/literals.spec.d.ts +0 -1
- package/dist/lang/test/literals.spec.js +0 -267
- package/dist/lang/test/locations.spec.d.ts +0 -1
- package/dist/lang/test/locations.spec.js +0 -679
- package/dist/lang/test/model-annotation-walker.spec.d.ts +0 -1
- package/dist/lang/test/model-annotation-walker.spec.js +0 -46
- package/dist/lang/test/model_serialization.spec.d.ts +0 -5
- package/dist/lang/test/model_serialization.spec.js +0 -116
- package/dist/lang/test/parameters.spec.d.ts +0 -1
- package/dist/lang/test/parameters.spec.js +0 -619
- package/dist/lang/test/parse.spec.d.ts +0 -1
- package/dist/lang/test/parse.spec.js +0 -893
- package/dist/lang/test/pretranslate.spec.d.ts +0 -1
- package/dist/lang/test/pretranslate.spec.js +0 -80
- package/dist/lang/test/query.spec.d.ts +0 -1
- package/dist/lang/test/query.spec.js +0 -1149
- package/dist/lang/test/source.spec.d.ts +0 -1
- package/dist/lang/test/source.spec.js +0 -570
- package/dist/lang/test/sql-block.spec.d.ts +0 -1
- package/dist/lang/test/sql-block.spec.js +0 -145
- package/dist/lang/test/syntax-errors.spec.d.ts +0 -1
- package/dist/lang/test/syntax-errors.spec.js +0 -142
- package/dist/model/utils.spec.d.ts +0 -1
- package/dist/model/utils.spec.js +0 -38
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import './parse-expects';
|
|
@@ -1,570 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* eslint-disable no-console */
|
|
3
|
-
/*
|
|
4
|
-
* Copyright 2023 Google LLC
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
-
* a copy of this software and associated documentation files
|
|
8
|
-
* (the "Software"), to deal in the Software without restriction,
|
|
9
|
-
* including without limitation the rights to use, copy, modify, merge,
|
|
10
|
-
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
11
|
-
* and to permit persons to whom the Software is furnished to do so,
|
|
12
|
-
* subject to the following conditions:
|
|
13
|
-
*
|
|
14
|
-
* The above copyright notice and this permission notice shall be
|
|
15
|
-
* included in all copies or substantial portions of the Software.
|
|
16
|
-
*
|
|
17
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
19
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
20
|
-
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
21
|
-
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
22
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
23
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const test_translator_1 = require("./test-translator");
|
|
27
|
-
require("./parse-expects");
|
|
28
|
-
describe('source:', () => {
|
|
29
|
-
test('table', () => {
|
|
30
|
-
expect("source: testA is _db_.table('aTable')").toTranslate();
|
|
31
|
-
});
|
|
32
|
-
test('shorcut fitlered table', () => {
|
|
33
|
-
expect("source: xA is _db_.table('aTable') extend { where: astr ~ 'a%' }").toTranslate();
|
|
34
|
-
});
|
|
35
|
-
test('fitlered table', () => {
|
|
36
|
-
expect("source: testA is _db_.table('aTable') extend { where: astr ~ 'a%' }").toTranslate();
|
|
37
|
-
});
|
|
38
|
-
test('ref source with no refinement', () => {
|
|
39
|
-
expect('source: testA is a').toTranslate();
|
|
40
|
-
});
|
|
41
|
-
test('source from query', () => {
|
|
42
|
-
expect('source: testA is a->{group_by: astr}').toTranslate();
|
|
43
|
-
});
|
|
44
|
-
test('refine source', () => {
|
|
45
|
-
expect('source: aa is a extend { dimension: a is astr }').toTranslate();
|
|
46
|
-
});
|
|
47
|
-
test('source refinement preserves original', () => {
|
|
48
|
-
const x = new test_translator_1.TestTranslator('source: na is a extend { dimension: one is 1 }');
|
|
49
|
-
expect(x).toTranslate();
|
|
50
|
-
const a = x.getSourceDef('a');
|
|
51
|
-
if (a) {
|
|
52
|
-
const aFields = a.fields.map(f => f.as || f.name);
|
|
53
|
-
expect(aFields).toContain('astr');
|
|
54
|
-
expect(aFields).not.toContain('one');
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
describe('source properties', () => {
|
|
58
|
-
test('single dimension', () => {
|
|
59
|
-
expect('source: aa is a extend { dimension: x is 1 }').toTranslate();
|
|
60
|
-
});
|
|
61
|
-
test('field def with null value', () => {
|
|
62
|
-
expect((0, test_translator_1.markSource) `source: aa is a extend { dimension: x is ${'null'} }`).toLog((0, test_translator_1.warningMessage)('null value defaults to type number, use "null::TYPE" to specify correct type'));
|
|
63
|
-
});
|
|
64
|
-
test('multiple dimensions', () => {
|
|
65
|
-
expect(`
|
|
66
|
-
source: aa is a extend {
|
|
67
|
-
dimension:
|
|
68
|
-
x is 1
|
|
69
|
-
y is 2
|
|
70
|
-
}
|
|
71
|
-
`).toTranslate();
|
|
72
|
-
});
|
|
73
|
-
test('single declare ok b4 m4', () => {
|
|
74
|
-
expect('##! -m4warnings\nsource: aa is a extend { declare: x is 1 }').toTranslate();
|
|
75
|
-
});
|
|
76
|
-
test('multiple declare ok b4 m4', () => {
|
|
77
|
-
expect(`
|
|
78
|
-
##! -m4warnings
|
|
79
|
-
source: aa is a extend {
|
|
80
|
-
declare:
|
|
81
|
-
x is 1
|
|
82
|
-
y is 2
|
|
83
|
-
}
|
|
84
|
-
`).toTranslate();
|
|
85
|
-
});
|
|
86
|
-
test('single measure', () => {
|
|
87
|
-
expect('source: aa is a extend { measure: x is count() }').toTranslate();
|
|
88
|
-
});
|
|
89
|
-
test('multiple measures', () => {
|
|
90
|
-
expect(`
|
|
91
|
-
source: aa is a extend {
|
|
92
|
-
measure:
|
|
93
|
-
x is count()
|
|
94
|
-
y is x * x
|
|
95
|
-
}
|
|
96
|
-
`).toTranslate();
|
|
97
|
-
});
|
|
98
|
-
test('single where', () => {
|
|
99
|
-
expect('source: aa is a extend { where: ai > 10 }').toTranslate();
|
|
100
|
-
});
|
|
101
|
-
test('multiple where', () => {
|
|
102
|
-
expect(`
|
|
103
|
-
source: aa is a extend {
|
|
104
|
-
where:
|
|
105
|
-
ai > 10,
|
|
106
|
-
af < 1000
|
|
107
|
-
}
|
|
108
|
-
`).toTranslate();
|
|
109
|
-
});
|
|
110
|
-
test('where clause can use the join namespace in source refined query', () => {
|
|
111
|
-
expect(`
|
|
112
|
-
source: flights is _db_.table('malloytest.flights') extend {
|
|
113
|
-
view: boo is {
|
|
114
|
-
extend: { join_one: carriers is _db_.table('malloytest.carriers') on carrier = carriers.code }
|
|
115
|
-
where: carriers.code = 'WN' | 'AA'
|
|
116
|
-
group_by: carriers.nickname
|
|
117
|
-
aggregate: flight_count is count()
|
|
118
|
-
}
|
|
119
|
-
}`).toTranslate();
|
|
120
|
-
});
|
|
121
|
-
describe('joins', () => {
|
|
122
|
-
test('with', () => {
|
|
123
|
-
expect('source: x is a extend { join_one: b with astr }').toTranslate();
|
|
124
|
-
});
|
|
125
|
-
test('with', () => {
|
|
126
|
-
expect((0, test_translator_1.model) `source: x is a extend { join_one: y is b with astr }`).toTranslate();
|
|
127
|
-
});
|
|
128
|
-
test('with dotted ref', () => {
|
|
129
|
-
expect((0, test_translator_1.model) `source: x is ab extend { join_one: xz is a with b.astr }`).toTranslate();
|
|
130
|
-
});
|
|
131
|
-
test('one on', () => {
|
|
132
|
-
expect((0, test_translator_1.model) `source: x is a extend { join_one: b on astr = b.astr }`).toTranslate();
|
|
133
|
-
});
|
|
134
|
-
test('one is on', () => {
|
|
135
|
-
expect('source: x is a extend { join_one: y is b on astr = y.astr }').toTranslate();
|
|
136
|
-
});
|
|
137
|
-
test('many on', () => {
|
|
138
|
-
expect('source: nab is a extend { join_many: b on astr = b.astr }').toTranslate();
|
|
139
|
-
});
|
|
140
|
-
test('many with', () => {
|
|
141
|
-
expect((0, test_translator_1.model) `source: nab is a extend { ${'join_many: b with astr'} }`).toLog((0, test_translator_1.errorMessage)('Foreign key join not legal in join_many:'));
|
|
142
|
-
});
|
|
143
|
-
test('many is on', () => {
|
|
144
|
-
expect('source: y is a extend { join_many: x is b on astr = x.astr }').toTranslate();
|
|
145
|
-
});
|
|
146
|
-
test('cross', () => {
|
|
147
|
-
expect('source: nab is a extend { join_cross: b }').toTranslate();
|
|
148
|
-
});
|
|
149
|
-
test('cross is', () => {
|
|
150
|
-
expect('source: nab is a extend { join_cross: xb is b }').toTranslate();
|
|
151
|
-
});
|
|
152
|
-
test('cross on', () => {
|
|
153
|
-
expect('source: nab is a extend { join_cross: b on true}').toTranslate();
|
|
154
|
-
});
|
|
155
|
-
test('multiple joins', () => {
|
|
156
|
-
expect(`
|
|
157
|
-
source: nab is a extend {
|
|
158
|
-
join_one:
|
|
159
|
-
b with astr,
|
|
160
|
-
br is b with astr
|
|
161
|
-
}
|
|
162
|
-
`).toTranslate();
|
|
163
|
-
});
|
|
164
|
-
test('with requires primary key', () => {
|
|
165
|
-
expect((0, test_translator_1.markSource) `
|
|
166
|
-
source: nb is b extend {
|
|
167
|
-
join_one: ${'bb is _db_.table("aTable") with astr'}
|
|
168
|
-
}
|
|
169
|
-
`).toLog((0, test_translator_1.errorMessage)('join_one: Cannot use with unless source has a primary key'));
|
|
170
|
-
});
|
|
171
|
-
test('can join a query without a rename', () => {
|
|
172
|
-
expect(`
|
|
173
|
-
query: aq is a -> {select: *}
|
|
174
|
-
source: aqs is a extend {
|
|
175
|
-
join_one: aq on ai = aq.ai
|
|
176
|
-
}
|
|
177
|
-
`).toTranslate();
|
|
178
|
-
});
|
|
179
|
-
test('can with join a single column query', () => {
|
|
180
|
-
expect(`
|
|
181
|
-
source: awith is a extend {
|
|
182
|
-
join_one: has_primary_key is a -> { group_by: one_val is astr } with astr
|
|
183
|
-
}
|
|
184
|
-
`).toTranslate();
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
describe('access modifiers and include', () => {
|
|
188
|
-
test('private not accessible in query', () => {
|
|
189
|
-
expect((0, test_translator_1.markSource) `
|
|
190
|
-
##! experimental.access_modifiers
|
|
191
|
-
source: c is a include { *; private: ai }
|
|
192
|
-
run: c -> { select: ${'ai'} }
|
|
193
|
-
`).toLog((0, test_translator_1.errorMessage)("'ai' is private"));
|
|
194
|
-
});
|
|
195
|
-
test('internal not accessible in query', () => {
|
|
196
|
-
expect((0, test_translator_1.markSource) `
|
|
197
|
-
##! experimental.access_modifiers
|
|
198
|
-
source: c is a include { *; internal: ai }
|
|
199
|
-
run: c -> { select: ${'ai'} }
|
|
200
|
-
`).toLog((0, test_translator_1.errorMessage)("'ai' is internal"));
|
|
201
|
-
});
|
|
202
|
-
test('internal is accessible in source extension', () => {
|
|
203
|
-
expect((0, test_translator_1.markSource) `
|
|
204
|
-
##! experimental.access_modifiers
|
|
205
|
-
source: c is a include { *; internal: ai }
|
|
206
|
-
source: d is c extend {
|
|
207
|
-
dimension: ai2 is ai
|
|
208
|
-
}
|
|
209
|
-
`).toTranslate();
|
|
210
|
-
});
|
|
211
|
-
test('private is inaccessible in source extension', () => {
|
|
212
|
-
expect((0, test_translator_1.markSource) `
|
|
213
|
-
##! experimental.access_modifiers
|
|
214
|
-
source: c is a include {
|
|
215
|
-
public: *
|
|
216
|
-
private: ai
|
|
217
|
-
}
|
|
218
|
-
source: d is c extend {
|
|
219
|
-
dimension: ai2 is ai
|
|
220
|
-
}
|
|
221
|
-
`).toLog((0, test_translator_1.errorMessage)("'ai' is private"));
|
|
222
|
-
});
|
|
223
|
-
test('internal is inaccessible in joining source on', () => {
|
|
224
|
-
expect((0, test_translator_1.markSource) `
|
|
225
|
-
##! experimental.access_modifiers
|
|
226
|
-
source: c is a include {
|
|
227
|
-
public: *
|
|
228
|
-
internal: ai
|
|
229
|
-
}
|
|
230
|
-
source: d is a extend {
|
|
231
|
-
join_one: c on ai = ${'c.ai'}
|
|
232
|
-
}
|
|
233
|
-
`).toLog((0, test_translator_1.errorMessage)("'ai' is internal"));
|
|
234
|
-
});
|
|
235
|
-
test('internal at definition time', () => {
|
|
236
|
-
expect((0, test_translator_1.markSource) `
|
|
237
|
-
##! experimental.access_modifiers
|
|
238
|
-
source: c is a extend {
|
|
239
|
-
internal dimension: x is 1
|
|
240
|
-
}
|
|
241
|
-
run: c -> x
|
|
242
|
-
`).toLog((0, test_translator_1.errorMessage)("'x' is internal"));
|
|
243
|
-
});
|
|
244
|
-
test('internal is inaccessible in joining source field', () => {
|
|
245
|
-
expect((0, test_translator_1.markSource) `
|
|
246
|
-
##! experimental.access_modifiers
|
|
247
|
-
source: c is a include {
|
|
248
|
-
public: *
|
|
249
|
-
internal: ai
|
|
250
|
-
}
|
|
251
|
-
source: d is a extend {
|
|
252
|
-
join_one: c on true
|
|
253
|
-
dimension: cai is ${'c.ai'}
|
|
254
|
-
}
|
|
255
|
-
`).toLog((0, test_translator_1.errorMessage)("'ai' is internal"));
|
|
256
|
-
});
|
|
257
|
-
test('internal is inaccessible in view reference', () => {
|
|
258
|
-
expect((0, test_translator_1.markSource) `
|
|
259
|
-
##! experimental.access_modifiers
|
|
260
|
-
source: c is a extend {
|
|
261
|
-
view: v is { group_by: ai }
|
|
262
|
-
} include { *; internal: v }
|
|
263
|
-
run: c -> ${'v'}
|
|
264
|
-
`).toLog((0, test_translator_1.errorMessage)("'v' is internal"));
|
|
265
|
-
});
|
|
266
|
-
test('private field used in view is accessible outside via view', () => {
|
|
267
|
-
expect((0, test_translator_1.markSource) `
|
|
268
|
-
##! experimental.access_modifiers
|
|
269
|
-
source: c is a extend {
|
|
270
|
-
view: v is { group_by: ai }
|
|
271
|
-
} include { *; private: ai }
|
|
272
|
-
run: c -> v
|
|
273
|
-
`).toTranslate();
|
|
274
|
-
});
|
|
275
|
-
test('use internal field in query in extension', () => {
|
|
276
|
-
expect((0, test_translator_1.markSource) `
|
|
277
|
-
##! experimental.access_modifiers
|
|
278
|
-
source: c is a include {
|
|
279
|
-
internal: ai
|
|
280
|
-
}
|
|
281
|
-
source: d is c extend {
|
|
282
|
-
view: v is { group_by: ai }
|
|
283
|
-
}
|
|
284
|
-
`).toTranslate();
|
|
285
|
-
});
|
|
286
|
-
test('cannot expand access from private', () => {
|
|
287
|
-
expect((0, test_translator_1.markSource) `
|
|
288
|
-
##! experimental.access_modifiers
|
|
289
|
-
source: c is a include {
|
|
290
|
-
public: *
|
|
291
|
-
private: ai
|
|
292
|
-
}
|
|
293
|
-
source: d is c include {
|
|
294
|
-
internal: ${'ai'}
|
|
295
|
-
}
|
|
296
|
-
`).toLog((0, test_translator_1.errorMessage)('Cannot expand access of `ai` from private to internal'));
|
|
297
|
-
});
|
|
298
|
-
test('can expand access from internal explicitly', () => {
|
|
299
|
-
expect((0, test_translator_1.markSource) `
|
|
300
|
-
##! experimental.access_modifiers
|
|
301
|
-
source: c is a include {
|
|
302
|
-
internal: *
|
|
303
|
-
}
|
|
304
|
-
source: d is c include {
|
|
305
|
-
public: ai
|
|
306
|
-
}
|
|
307
|
-
run: d -> { group_by: ai }
|
|
308
|
-
`).toTranslate();
|
|
309
|
-
});
|
|
310
|
-
test('can expand access from internal with star', () => {
|
|
311
|
-
expect((0, test_translator_1.markSource) `
|
|
312
|
-
##! experimental.access_modifiers
|
|
313
|
-
source: c is a include {
|
|
314
|
-
internal: *
|
|
315
|
-
}
|
|
316
|
-
source: d is c include {
|
|
317
|
-
public: *
|
|
318
|
-
}
|
|
319
|
-
run: d -> { group_by: ai }
|
|
320
|
-
`).toTranslate();
|
|
321
|
-
});
|
|
322
|
-
test('star does not expand access', () => {
|
|
323
|
-
expect((0, test_translator_1.markSource) `
|
|
324
|
-
##! experimental.access_modifiers
|
|
325
|
-
source: c is a extend {
|
|
326
|
-
private dimension: x is 1
|
|
327
|
-
}
|
|
328
|
-
source: d is c include {
|
|
329
|
-
public: *
|
|
330
|
-
}
|
|
331
|
-
source: e is d extend {
|
|
332
|
-
dimension: y is ${'x'}
|
|
333
|
-
}
|
|
334
|
-
`).toLog((0, test_translator_1.errorMessage)("'x' is private"));
|
|
335
|
-
});
|
|
336
|
-
test('access modifier *', () => {
|
|
337
|
-
expect((0, test_translator_1.markSource) `
|
|
338
|
-
##! experimental.access_modifiers
|
|
339
|
-
source: c is a include {
|
|
340
|
-
private: *
|
|
341
|
-
}
|
|
342
|
-
run: c -> { group_by: ai }
|
|
343
|
-
`).toLog((0, test_translator_1.errorMessage)("'ai' is private"));
|
|
344
|
-
});
|
|
345
|
-
test('private things can be used in immediate extension', () => {
|
|
346
|
-
expect((0, test_translator_1.markSource) `
|
|
347
|
-
##! experimental.access_modifiers
|
|
348
|
-
source: c is a include {
|
|
349
|
-
private: *
|
|
350
|
-
} extend {
|
|
351
|
-
dimension: ai2 is ai
|
|
352
|
-
}
|
|
353
|
-
`).toTranslate();
|
|
354
|
-
});
|
|
355
|
-
test('private things cannot be used in later extension', () => {
|
|
356
|
-
expect((0, test_translator_1.markSource) `
|
|
357
|
-
##! experimental.access_modifiers
|
|
358
|
-
source: c is (a include {
|
|
359
|
-
private: *
|
|
360
|
-
}) extend {
|
|
361
|
-
dimension: ai2 is ai
|
|
362
|
-
}
|
|
363
|
-
`).toLog((0, test_translator_1.errorMessage)("'ai' is private"));
|
|
364
|
-
});
|
|
365
|
-
test('access modifier * except', () => {
|
|
366
|
-
expect((0, test_translator_1.markSource) `
|
|
367
|
-
##! experimental.access_modifiers
|
|
368
|
-
source: c is a include {
|
|
369
|
-
ai;
|
|
370
|
-
private: *
|
|
371
|
-
}
|
|
372
|
-
run: c -> { group_by: ai, abool }
|
|
373
|
-
`).toLog((0, test_translator_1.errorMessage)("'abool' is private"));
|
|
374
|
-
});
|
|
375
|
-
test('access modifier * nonconflicting use', () => {
|
|
376
|
-
expect((0, test_translator_1.markSource) `
|
|
377
|
-
##! experimental.access_modifiers
|
|
378
|
-
source: c is a include {
|
|
379
|
-
internal: ai
|
|
380
|
-
private: *
|
|
381
|
-
}
|
|
382
|
-
run: c -> { group_by: ai }
|
|
383
|
-
source: d is c extend {
|
|
384
|
-
dimension: x is abool
|
|
385
|
-
}
|
|
386
|
-
`).toLog((0, test_translator_1.errorMessage)("'ai' is internal"), (0, test_translator_1.errorMessage)("'abool' is private"));
|
|
387
|
-
});
|
|
388
|
-
test('cannot override in same source', () => {
|
|
389
|
-
return expect((0, test_translator_1.markSource) `
|
|
390
|
-
##! experimental.access_modifiers
|
|
391
|
-
source: c is a include {
|
|
392
|
-
public: ai
|
|
393
|
-
private: ${'ai'}
|
|
394
|
-
}
|
|
395
|
-
`).toLog((0, test_translator_1.errorMessage)('Field `ai` already referenced in include list'));
|
|
396
|
-
});
|
|
397
|
-
test('rename in include', () => {
|
|
398
|
-
return expect((0, test_translator_1.markSource) `
|
|
399
|
-
##! experimental.access_modifiers
|
|
400
|
-
source: c is a include {
|
|
401
|
-
public: ai2 is ai
|
|
402
|
-
}
|
|
403
|
-
run: c -> { group_by: ai2 }
|
|
404
|
-
run: c -> { group_by: ${'ai'} }
|
|
405
|
-
`).toLog((0, test_translator_1.errorMessage)("'ai' is not defined"));
|
|
406
|
-
});
|
|
407
|
-
test('commas optional in include', () => {
|
|
408
|
-
return expect((0, test_translator_1.markSource) `
|
|
409
|
-
##! experimental.access_modifiers
|
|
410
|
-
source: c is a include {
|
|
411
|
-
ai
|
|
412
|
-
astr
|
|
413
|
-
abool
|
|
414
|
-
private:
|
|
415
|
-
af
|
|
416
|
-
aweird
|
|
417
|
-
}
|
|
418
|
-
run: c -> { group_by: astr }
|
|
419
|
-
run: c -> { group_by: ${'af'} }
|
|
420
|
-
`).toLog((0, test_translator_1.errorMessage)("'af' is private"));
|
|
421
|
-
});
|
|
422
|
-
test('include and except list', () => {
|
|
423
|
-
return expect((0, test_translator_1.markSource) `
|
|
424
|
-
##! experimental.access_modifiers
|
|
425
|
-
source: c is a include {
|
|
426
|
-
ai
|
|
427
|
-
except: astr
|
|
428
|
-
}
|
|
429
|
-
`).toLog((0, test_translator_1.errorMessage)('Cannot exclude specific fields if specific fields are already included'));
|
|
430
|
-
});
|
|
431
|
-
test('except and include list', () => {
|
|
432
|
-
return expect((0, test_translator_1.markSource) `
|
|
433
|
-
##! experimental.access_modifiers
|
|
434
|
-
source: c is a include {
|
|
435
|
-
except: astr
|
|
436
|
-
public: ai
|
|
437
|
-
}
|
|
438
|
-
`).toLog((0, test_translator_1.errorMessage)('Cannot include specific fields if specific fields are already excluded'));
|
|
439
|
-
});
|
|
440
|
-
// TODO test conflict with `rename:` and `except:` and `accept:`
|
|
441
|
-
});
|
|
442
|
-
test('primary_key', () => {
|
|
443
|
-
expect('source: c is a extend { primary_key: ai }').toTranslate();
|
|
444
|
-
});
|
|
445
|
-
test('rename', () => {
|
|
446
|
-
expect('source: c is a extend { rename: nn is ai }').toTranslate();
|
|
447
|
-
});
|
|
448
|
-
test('accept single', () => {
|
|
449
|
-
const onlyAstr = new test_translator_1.TestTranslator('source: c is a extend { accept: astr }');
|
|
450
|
-
expect(onlyAstr).toTranslate();
|
|
451
|
-
const c = onlyAstr.getSourceDef('c');
|
|
452
|
-
if (c) {
|
|
453
|
-
expect(c.fields.length).toBe(1);
|
|
454
|
-
}
|
|
455
|
-
});
|
|
456
|
-
test('accept multi', () => {
|
|
457
|
-
expect('source: c is a extend { accept: astr, af }').toTranslate();
|
|
458
|
-
});
|
|
459
|
-
test('except single', () => {
|
|
460
|
-
const noAstr = new test_translator_1.TestTranslator('source: c is a extend { except: astr }');
|
|
461
|
-
expect(noAstr).toTranslate();
|
|
462
|
-
const c = noAstr.getSourceDef('c');
|
|
463
|
-
if (c) {
|
|
464
|
-
const foundAstr = c.fields.find(f => f.name === 'astr');
|
|
465
|
-
expect(foundAstr).toBeUndefined();
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
test('except multi', () => {
|
|
469
|
-
expect('source: c is a extend { except: astr, af }').toTranslate();
|
|
470
|
-
});
|
|
471
|
-
test('turtle in a source can be called view', () => {
|
|
472
|
-
expect('source: c is a extend {view: q is { group_by: astr } }').toTranslate();
|
|
473
|
-
});
|
|
474
|
-
test('turtle in source can be called query with m4 warning', () => {
|
|
475
|
-
expect(`##! m4warnings=warn
|
|
476
|
-
source: c is a extend {query: q is { group_by: astr } }
|
|
477
|
-
`).toLog((0, test_translator_1.warningMessage)('Use view: inside of a source instead of query:'));
|
|
478
|
-
});
|
|
479
|
-
test('refined explore-query', () => {
|
|
480
|
-
expect(`
|
|
481
|
-
source: abNew is ab extend {
|
|
482
|
-
view: for1 is aturtle + { where: ai = 1 }
|
|
483
|
-
}
|
|
484
|
-
`).toTranslate();
|
|
485
|
-
});
|
|
486
|
-
test('chained explore-query', () => {
|
|
487
|
-
expect(`
|
|
488
|
-
source: c is a extend {
|
|
489
|
-
view: chain is {
|
|
490
|
-
group_by: astr
|
|
491
|
-
} -> {
|
|
492
|
-
top: 10; order_by: astr
|
|
493
|
-
select: *
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
`).toTranslate();
|
|
497
|
-
});
|
|
498
|
-
test('chained explore-query with refinement two steps', () => {
|
|
499
|
-
expect(`
|
|
500
|
-
source: c is a extend {
|
|
501
|
-
view: base is {
|
|
502
|
-
group_by: astr
|
|
503
|
-
} + {
|
|
504
|
-
group_by: ai
|
|
505
|
-
}
|
|
506
|
-
view: chain2 is base -> {
|
|
507
|
-
top: 10; order_by: astr
|
|
508
|
-
select: *
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
`).toTranslate();
|
|
512
|
-
});
|
|
513
|
-
test('pipelined explore-query with refinement', () => {
|
|
514
|
-
expect(`
|
|
515
|
-
source: c is a extend {
|
|
516
|
-
view: base is {
|
|
517
|
-
group_by: astr
|
|
518
|
-
}
|
|
519
|
-
view: chain is base + {
|
|
520
|
-
group_by: ai
|
|
521
|
-
} -> {
|
|
522
|
-
top: 10; order_by: astr
|
|
523
|
-
select: *
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
`).toTranslate();
|
|
527
|
-
});
|
|
528
|
-
test('pipelined explore-query with view chain', () => {
|
|
529
|
-
expect(`
|
|
530
|
-
source: c is a extend {
|
|
531
|
-
view: chain is {
|
|
532
|
-
group_by: astr
|
|
533
|
-
} + {
|
|
534
|
-
group_by: ai
|
|
535
|
-
} -> {
|
|
536
|
-
top: 10; order_by: astr
|
|
537
|
-
select: *
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
`).toTranslate();
|
|
541
|
-
});
|
|
542
|
-
test('multiple explore-query', () => {
|
|
543
|
-
expect(`
|
|
544
|
-
source: abNew is ab extend {
|
|
545
|
-
view:
|
|
546
|
-
q1 is { group_by: astr },
|
|
547
|
-
q2 is { group_by: ai }
|
|
548
|
-
}
|
|
549
|
-
`).toTranslate();
|
|
550
|
-
});
|
|
551
|
-
});
|
|
552
|
-
test('dates do not become timestamps', () => {
|
|
553
|
-
const dateThing = (0, test_translator_1.model) `source: hasDate is a -> { select: ad }`;
|
|
554
|
-
expect(dateThing).toTranslate();
|
|
555
|
-
const hasDate = dateThing.translator.getSourceDef('hasDate');
|
|
556
|
-
expect(hasDate).toBeDefined();
|
|
557
|
-
const ad = (0, test_translator_1.getFieldDef)(hasDate, 'ad');
|
|
558
|
-
expect(ad).toMatchObject({ name: 'ad', type: 'date' });
|
|
559
|
-
});
|
|
560
|
-
describe('composite sources', () => {
|
|
561
|
-
test('basic composite source', () => {
|
|
562
|
-
expect(`
|
|
563
|
-
##! experimental.composite_sources
|
|
564
|
-
source: x is compose(a, a extend { dimension: foo is 1 })
|
|
565
|
-
run: x -> { select: foo }
|
|
566
|
-
`).toTranslate();
|
|
567
|
-
});
|
|
568
|
-
});
|
|
569
|
-
});
|
|
570
|
-
//# sourceMappingURL=source.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import './parse-expects';
|