@malloydata/malloy 0.0.88-dev231002231014 → 0.0.88-dev231003001139
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/dialect/dialect_map.js +1 -0
- package/dist/dialect/functions/util.d.ts +1 -0
- package/dist/lang/ast/elements/define-query.d.ts +3 -3
- package/dist/lang/ast/elements/define-query.js +9 -4
- package/dist/lang/ast/elements/define-source.d.ts +3 -3
- package/dist/lang/ast/elements/define-source.js +12 -4
- package/dist/lang/ast/elements/pipeline-desc.d.ts +1 -0
- package/dist/lang/ast/elements/pipeline-desc.js +3 -0
- package/dist/lang/ast/elements/source-query-nodes.d.ts +72 -0
- package/dist/lang/ast/elements/source-query-nodes.js +368 -0
- package/dist/lang/ast/elements/source-query.d.ts +11 -0
- package/dist/lang/ast/{query-elements/run-query.js → elements/source-query.js} +32 -21
- package/dist/lang/ast/index.d.ts +2 -2
- package/dist/lang/ast/index.js +2 -2
- package/dist/lang/ast/query-elements/anonymous-query.d.ts +3 -3
- package/dist/lang/ast/query-elements/anonymous-query.js +15 -8
- package/dist/lang/ast/query-elements/existing-query.js +1 -1
- package/dist/lang/ast/query-items/field-references.d.ts +4 -0
- package/dist/lang/ast/query-items/field-references.js +11 -1
- package/dist/lang/ast/query-items/typecheck_utils.js +5 -5
- package/dist/lang/ast/query-properties/joins.d.ts +7 -5
- package/dist/lang/ast/query-properties/joins.js +22 -8
- package/dist/lang/ast/sources/sql-source.js +5 -0
- package/dist/lang/ast/sql-elements/sql-string.d.ts +2 -2
- package/dist/lang/ast/sql-elements/sql-string.js +19 -9
- package/dist/lang/ast/types/malloy-element.d.ts +3 -1
- package/dist/lang/ast/types/malloy-element.js +16 -5
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +179 -184
- package/dist/lang/lib/Malloy/MalloyParser.js +3141 -2928
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +147 -199
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +88 -120
- package/dist/lang/malloy-to-ast.d.ts +16 -15
- package/dist/lang/malloy-to-ast.js +147 -141
- package/dist/lang/parse-tree-walkers/document-symbol-walker.js +1 -1
- package/dist/lang/parse-utils.js +2 -2
- package/dist/lang/test/annotation.spec.js +35 -46
- package/dist/lang/test/document-symbol-walker.spec.js +2 -2
- package/dist/lang/test/expressions.spec.js +16 -16
- package/dist/lang/test/imports.spec.js +10 -8
- package/dist/lang/test/literals.spec.js +4 -4
- package/dist/lang/test/locations.spec.js +82 -80
- package/dist/lang/test/parse-expects.js +5 -1
- package/dist/lang/test/parse.spec.js +173 -117
- package/dist/lang/test/query.spec.js +199 -203
- package/dist/lang/test/source.spec.js +54 -45
- package/dist/lang/test/sql-block.spec.js +19 -12
- package/dist/lang/test/test-translator.js +8 -5
- package/dist/malloy.js +2 -2
- package/dist/model/malloy_query.js +3 -0
- package/dist/model/malloy_types.d.ts +1 -0
- package/package.json +1 -2
- package/dist/lang/ast/query-elements/run-query.d.ts +0 -13
- package/dist/lang/ast/sources/named-source-or-query.d.ts +0 -10
- package/dist/lang/ast/sources/named-source-or-query.js +0 -71
|
@@ -32,13 +32,13 @@ describe('source locations', () => {
|
|
|
32
32
|
expect((0, test_translator_1.getExplore)(m.modelDef, 'na').location).toMatchObject(source.locations[0]);
|
|
33
33
|
});
|
|
34
34
|
test('refined source location', () => {
|
|
35
|
-
const source = (0, test_translator_1.markSource) `source: ${'na is a {}'}`;
|
|
35
|
+
const source = (0, test_translator_1.markSource) `source: ${'na is a extend {}'}`;
|
|
36
36
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
37
37
|
expect(m).toParse();
|
|
38
38
|
expect((0, test_translator_1.getExplore)(m.modelDef, 'na').location).toMatchObject(source.locations[0]);
|
|
39
39
|
});
|
|
40
40
|
test('location of defined dimension', () => {
|
|
41
|
-
const source = (0, test_translator_1.markSource) `source: na is a { dimension: ${'x is 1'} }`;
|
|
41
|
+
const source = (0, test_translator_1.markSource) `source: na is a extend { dimension: ${'x is 1'} }`;
|
|
42
42
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
43
43
|
expect(m).toTranslate();
|
|
44
44
|
const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
|
|
@@ -46,25 +46,25 @@ describe('source locations', () => {
|
|
|
46
46
|
expect(x.location).toMatchObject(source.locations[0]);
|
|
47
47
|
});
|
|
48
48
|
test('location of defined measure', () => {
|
|
49
|
-
const source = (0, test_translator_1.markSource) `source: na is a { measure: ${'x is count()'} }`;
|
|
49
|
+
const source = (0, test_translator_1.markSource) `source: na is a extend { measure: ${'x is count()'} }`;
|
|
50
50
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
51
51
|
expect(m).toTranslate();
|
|
52
52
|
const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
|
|
53
53
|
const x = (0, test_translator_1.getFieldDef)(na, 'x');
|
|
54
54
|
expect(x.location).toMatchObject(source.locations[0]);
|
|
55
55
|
});
|
|
56
|
-
test('location of defined
|
|
57
|
-
const source = (0, test_translator_1.markSource) `source: na is a {
|
|
56
|
+
test('location of defined view', () => {
|
|
57
|
+
const source = (0, test_translator_1.markSource) `source: na is a extend { view: ${'x is { group_by: y is 1 }'} }`;
|
|
58
58
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
59
59
|
expect(m).toTranslate();
|
|
60
60
|
const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
|
|
61
61
|
const x = (0, test_translator_1.getFieldDef)(na, 'x');
|
|
62
62
|
expect(x.location).toMatchObject(source.locations[0]);
|
|
63
63
|
});
|
|
64
|
-
test('location of defined field inside a
|
|
64
|
+
test('location of defined field inside a view', () => {
|
|
65
65
|
const source = (0, test_translator_1.markSource) `
|
|
66
|
-
source: na is a {
|
|
67
|
-
|
|
66
|
+
source: na is a extend {
|
|
67
|
+
view: x is {
|
|
68
68
|
group_by: ${'y is 1'}
|
|
69
69
|
}
|
|
70
70
|
}`;
|
|
@@ -75,11 +75,11 @@ describe('source locations', () => {
|
|
|
75
75
|
const y = (0, test_translator_1.getFieldDef)(x.pipeline[0], 'y');
|
|
76
76
|
expect(y.location).toMatchObject(source.locations[0]);
|
|
77
77
|
});
|
|
78
|
-
test('location of filtered field inside a
|
|
78
|
+
test('location of filtered field inside a view', () => {
|
|
79
79
|
const source = (0, test_translator_1.markSource) `
|
|
80
|
-
source: na is a {
|
|
80
|
+
source: na is a extend {
|
|
81
81
|
measure: y is count()
|
|
82
|
-
|
|
82
|
+
view: x is {
|
|
83
83
|
aggregate: ${'z is y { where: true }'}
|
|
84
84
|
}
|
|
85
85
|
}`;
|
|
@@ -91,15 +91,15 @@ describe('source locations', () => {
|
|
|
91
91
|
expect(z.location).toMatchObject(source.locations[0]);
|
|
92
92
|
});
|
|
93
93
|
test('location of field inherited from table', () => {
|
|
94
|
-
const source = (0, test_translator_1.markSource) `source: na is ${"table('aTable')"}`;
|
|
94
|
+
const source = (0, test_translator_1.markSource) `source: na is ${"_db_.table('aTable')"}`;
|
|
95
95
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
96
96
|
expect(m).toTranslate();
|
|
97
97
|
const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
|
|
98
98
|
const abool = (0, test_translator_1.getFieldDef)(na, 'abool');
|
|
99
99
|
expect(abool.location).toMatchObject(source.locations[0]);
|
|
100
100
|
});
|
|
101
|
-
test('location of field inherited from sql block', () => {
|
|
102
|
-
const source = (0, test_translator_1.markSource)
|
|
101
|
+
test('pre m4 location of field inherited from sql block', () => {
|
|
102
|
+
const source = (0, test_translator_1.markSource) `##! -m4warnings
|
|
103
103
|
sql: s is { select: ${'"""SELECT 1 as one """'} }
|
|
104
104
|
source: na is from_sql(s)
|
|
105
105
|
`;
|
|
@@ -117,10 +117,11 @@ describe('source locations', () => {
|
|
|
117
117
|
expect(one.location).isLocationIn(source.locations[0], source.code);
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
|
-
test('location of fields inherited from a query', () => {
|
|
120
|
+
test('pre m4 location of fields inherited from a query', () => {
|
|
121
121
|
const source = (0, test_translator_1.markSource) `
|
|
122
|
+
##! -m4warnings
|
|
122
123
|
source: na is from(
|
|
123
|
-
${"table('aTable')"} -> {
|
|
124
|
+
${"_db_.table('aTable')"} -> {
|
|
124
125
|
group_by:
|
|
125
126
|
abool
|
|
126
127
|
${'y is 1'}
|
|
@@ -136,7 +137,7 @@ describe('source locations', () => {
|
|
|
136
137
|
expect(y.location).toMatchObject(source.locations[1]);
|
|
137
138
|
});
|
|
138
139
|
test('location of named query', () => {
|
|
139
|
-
const source = (0, test_translator_1.markSource) `query: ${'q is a -> {
|
|
140
|
+
const source = (0, test_translator_1.markSource) `query: ${'q is a -> { select: * }'}`;
|
|
140
141
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
141
142
|
expect(m).toTranslate();
|
|
142
143
|
const q = (0, test_translator_1.getExplore)(m.modelDef, 'q');
|
|
@@ -150,8 +151,8 @@ describe('source locations', () => {
|
|
|
150
151
|
const a = (0, test_translator_1.getFieldDef)(q.pipeline[0], 'b');
|
|
151
152
|
expect(a.location).toMatchObject(source.locations[0]);
|
|
152
153
|
});
|
|
153
|
-
test('location of named SQL block', () => {
|
|
154
|
-
const source = (0, test_translator_1.markSource)
|
|
154
|
+
test('pre m4 location of named SQL block', () => {
|
|
155
|
+
const source = (0, test_translator_1.markSource) `##! -m4warnings\n${'sql: s is { select: """SELECT 1 as one""" }'}`;
|
|
155
156
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
156
157
|
expect(m).toParse();
|
|
157
158
|
const compileSql = m.translate().compileSQL;
|
|
@@ -167,7 +168,7 @@ describe('source locations', () => {
|
|
|
167
168
|
});
|
|
168
169
|
test('location of renamed field', () => {
|
|
169
170
|
const source = (0, test_translator_1.markSource) `
|
|
170
|
-
source: na is a {
|
|
171
|
+
source: na is a extend {
|
|
171
172
|
rename: ${'bbool is abool'}
|
|
172
173
|
}
|
|
173
174
|
`;
|
|
@@ -179,8 +180,8 @@ describe('source locations', () => {
|
|
|
179
180
|
});
|
|
180
181
|
test('location of join on', () => {
|
|
181
182
|
const source = (0, test_translator_1.markSource) `
|
|
182
|
-
source: na is a {
|
|
183
|
-
join_one: ${'x is a { primary_key: abool } on abool'}
|
|
183
|
+
source: na is a extend {
|
|
184
|
+
join_one: ${'x is a extend { primary_key: abool } on abool'}
|
|
184
185
|
}
|
|
185
186
|
`;
|
|
186
187
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
@@ -191,8 +192,8 @@ describe('source locations', () => {
|
|
|
191
192
|
});
|
|
192
193
|
test('location of join with', () => {
|
|
193
194
|
const source = (0, test_translator_1.markSource) `
|
|
194
|
-
source: na is a {
|
|
195
|
-
join_one: ${'x is a { primary_key: astr } with astr'}
|
|
195
|
+
source: na is a extend {
|
|
196
|
+
join_one: ${'x is a extend { primary_key: astr } with astr'}
|
|
196
197
|
}
|
|
197
198
|
`;
|
|
198
199
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
@@ -203,8 +204,8 @@ describe('source locations', () => {
|
|
|
203
204
|
});
|
|
204
205
|
test('location of field in join', () => {
|
|
205
206
|
const source = (0, test_translator_1.markSource) `
|
|
206
|
-
source: na is a {
|
|
207
|
-
join_one: x is a {
|
|
207
|
+
source: na is a extend {
|
|
208
|
+
join_one: x is a extend {
|
|
208
209
|
primary_key: abool
|
|
209
210
|
dimension: ${'y is 1'}
|
|
210
211
|
} on abool
|
|
@@ -226,26 +227,26 @@ describe('source locations', () => {
|
|
|
226
227
|
// expect(errList[0].at?.range.end).toEqual({ line: 2, character: 11 });
|
|
227
228
|
// });
|
|
228
229
|
test('undefined query location', () => {
|
|
229
|
-
expect((0, test_translator_1.model) `
|
|
230
|
+
expect((0, test_translator_1.model) `run: ${'xyz'}`).translationToFailWith("Reference to undefined object 'xyz'");
|
|
230
231
|
});
|
|
231
232
|
test('undefined field reference', () => {
|
|
232
|
-
expect((0, test_translator_1.model) `
|
|
233
|
+
expect((0, test_translator_1.model) `run: a -> { group_by: ${'xyz'} }`).translationToFailWith("'xyz' is not defined");
|
|
233
234
|
});
|
|
234
235
|
test('bad query', () => {
|
|
235
|
-
expect((0, test_translator_1.model) `
|
|
236
|
+
expect((0, test_translator_1.model) `run: a -> { group_by: astr; ${'select: *'} }`).translationToFailWith(/Not legal in grouping query/);
|
|
236
237
|
});
|
|
237
238
|
test.skip('undefined field reference in top', () => {
|
|
238
|
-
expect((0, test_translator_1.model) `
|
|
239
|
+
expect((0, test_translator_1.model) `run: a -> { group_by: one is 1; top: 1 by ${'xyz'} }`).translationToFailWith("'xyz' is not defined");
|
|
239
240
|
});
|
|
240
241
|
test.skip('undefined field reference in order_by', () => {
|
|
241
|
-
expect((0, test_translator_1.model) `
|
|
242
|
+
expect((0, test_translator_1.model) `run: a -> { group_by: one is 1; order_by: ${'xyz'} }`).translationToFailWith("'xyz' is not defined");
|
|
242
243
|
});
|
|
243
244
|
});
|
|
244
245
|
describe('source references', () => {
|
|
245
246
|
test('reference to explore', () => {
|
|
246
247
|
const source = (0, test_translator_1.markSource) `
|
|
247
248
|
source: ${'na is a'}
|
|
248
|
-
|
|
249
|
+
run: ${'na'} -> { select: * }
|
|
249
250
|
`;
|
|
250
251
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
251
252
|
expect(m).toTranslate();
|
|
@@ -260,10 +261,10 @@ describe('source references', () => {
|
|
|
260
261
|
});
|
|
261
262
|
test('reference to query in query', () => {
|
|
262
263
|
const source = (0, test_translator_1.markSource) `
|
|
263
|
-
source: t is a {
|
|
264
|
-
|
|
264
|
+
source: t is a extend {
|
|
265
|
+
view: ${'q is { select: * }'}
|
|
265
266
|
}
|
|
266
|
-
|
|
267
|
+
run: t -> ${'q'}
|
|
267
268
|
`;
|
|
268
269
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
269
270
|
expect(m).toTranslate();
|
|
@@ -278,8 +279,8 @@ describe('source references', () => {
|
|
|
278
279
|
});
|
|
279
280
|
test('reference to query in query (version 2)', () => {
|
|
280
281
|
const source = (0, test_translator_1.markSource) `
|
|
281
|
-
source: na is a {
|
|
282
|
-
|
|
282
|
+
source: na is a extend { view: ${'x is { group_by: y is 1 }'} }
|
|
283
|
+
run: na -> ${'x'}
|
|
283
284
|
`;
|
|
284
285
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
285
286
|
expect(m).toTranslate();
|
|
@@ -292,8 +293,9 @@ describe('source references', () => {
|
|
|
292
293
|
},
|
|
293
294
|
});
|
|
294
295
|
});
|
|
295
|
-
test('reference to sql block', () => {
|
|
296
|
+
test('pre m4 reference to sql block', () => {
|
|
296
297
|
const source = (0, test_translator_1.markSource) `
|
|
298
|
+
##! -m4warnings
|
|
297
299
|
${'sql: s is {select:"""SELECT 1 as one"""}'}
|
|
298
300
|
source: na is from_sql(${'s'})
|
|
299
301
|
`;
|
|
@@ -318,14 +320,15 @@ describe('source references', () => {
|
|
|
318
320
|
});
|
|
319
321
|
}
|
|
320
322
|
});
|
|
321
|
-
test('reference to query in from', () => {
|
|
322
|
-
const source = (0, test_translator_1.
|
|
323
|
-
|
|
323
|
+
test('pre m4 reference to query in from', () => {
|
|
324
|
+
const source = (0, test_translator_1.model) `
|
|
325
|
+
##! -m4warnings
|
|
326
|
+
query: ${'q is a -> { select: * }'}
|
|
324
327
|
source: na is from(-> ${'q'})
|
|
325
328
|
`;
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
expect(
|
|
329
|
+
expect(source).toTranslate();
|
|
330
|
+
const mt = source.translator;
|
|
331
|
+
expect(mt.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
329
332
|
location: source.locations[1],
|
|
330
333
|
type: 'queryReference',
|
|
331
334
|
text: 'q',
|
|
@@ -336,8 +339,8 @@ describe('source references', () => {
|
|
|
336
339
|
});
|
|
337
340
|
test('reference to query in query head', () => {
|
|
338
341
|
const source = (0, test_translator_1.markSource) `
|
|
339
|
-
query: ${'q is a -> {
|
|
340
|
-
query: q2 is
|
|
342
|
+
query: ${'q is a -> { select: * }'}
|
|
343
|
+
query: q2 is ${'q'} -> { select: * }
|
|
341
344
|
`;
|
|
342
345
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
343
346
|
expect(m).toTranslate();
|
|
@@ -352,8 +355,8 @@ describe('source references', () => {
|
|
|
352
355
|
});
|
|
353
356
|
test('reference to query in refined query', () => {
|
|
354
357
|
const source = (0, test_translator_1.markSource) `
|
|
355
|
-
query: ${'q is a -> {
|
|
356
|
-
query: q2 is
|
|
358
|
+
query: ${'q is a -> { select: * }'}
|
|
359
|
+
query: q2 is ${'q'} + { limit: 10 }
|
|
357
360
|
`;
|
|
358
361
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
359
362
|
expect(m).toTranslate();
|
|
@@ -368,8 +371,8 @@ describe('source references', () => {
|
|
|
368
371
|
});
|
|
369
372
|
test('reference to field in expression', () => {
|
|
370
373
|
const source = (0, test_translator_1.markSource) `
|
|
371
|
-
source: na is ${"table('aTable')"}
|
|
372
|
-
|
|
374
|
+
source: na is ${"_db_.table('aTable')"}
|
|
375
|
+
run: na -> { select: bbool is not ${'abool'} }
|
|
373
376
|
`;
|
|
374
377
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
375
378
|
expect(m).toTranslate();
|
|
@@ -384,10 +387,10 @@ describe('source references', () => {
|
|
|
384
387
|
});
|
|
385
388
|
test('reference to quoted field in expression', () => {
|
|
386
389
|
const source = (0, test_translator_1.markSource) `
|
|
387
|
-
source: na is a {
|
|
390
|
+
source: na is a extend {
|
|
388
391
|
dimension: ${"`name` is 'name'"}
|
|
389
392
|
}
|
|
390
|
-
|
|
393
|
+
run: na -> { select: ${'`name`'} }
|
|
391
394
|
`;
|
|
392
395
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
393
396
|
expect(m).toTranslate();
|
|
@@ -402,11 +405,11 @@ describe('source references', () => {
|
|
|
402
405
|
});
|
|
403
406
|
test('reference to joined field in expression', () => {
|
|
404
407
|
const source = (0, test_translator_1.markSource) `
|
|
405
|
-
source: na is a {
|
|
406
|
-
join_one: self is ${"table('aTable')"}
|
|
408
|
+
source: na is a extend {
|
|
409
|
+
join_one: self is ${"_db_.table('aTable')"}
|
|
407
410
|
on astr = self.astr
|
|
408
411
|
}
|
|
409
|
-
|
|
412
|
+
run: na -> { select: bstr is self.${'astr'} }
|
|
410
413
|
`;
|
|
411
414
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
412
415
|
expect(m).toTranslate();
|
|
@@ -421,10 +424,10 @@ describe('source references', () => {
|
|
|
421
424
|
});
|
|
422
425
|
test('reference to joined join in expression', () => {
|
|
423
426
|
const source = (0, test_translator_1.markSource) `
|
|
424
|
-
source: na is a {
|
|
427
|
+
source: na is a extend {
|
|
425
428
|
join_one: ${'self is a on astr = self.astr'}
|
|
426
429
|
}
|
|
427
|
-
|
|
430
|
+
run: na -> { select: bstr is ${'self'}.astr }
|
|
428
431
|
`;
|
|
429
432
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
430
433
|
expect(m).toTranslate();
|
|
@@ -439,7 +442,7 @@ describe('source references', () => {
|
|
|
439
442
|
});
|
|
440
443
|
test('reference to field not in expression (group by)', () => {
|
|
441
444
|
const source = (0, test_translator_1.markSource) `
|
|
442
|
-
|
|
445
|
+
run: ${"_db_.table('aTable')"} -> { group_by: ${'abool'} }
|
|
443
446
|
`;
|
|
444
447
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
445
448
|
expect(m).toTranslate();
|
|
@@ -454,8 +457,8 @@ describe('source references', () => {
|
|
|
454
457
|
});
|
|
455
458
|
test('reference to field not in expression (project)', () => {
|
|
456
459
|
const source = (0, test_translator_1.markSource) `
|
|
457
|
-
source: na is ${"table('aTable')"}
|
|
458
|
-
|
|
460
|
+
source: na is ${"_db_.table('aTable')"}
|
|
461
|
+
run: na -> { select: ${'abool'} }
|
|
459
462
|
`;
|
|
460
463
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
461
464
|
expect(m).toTranslate();
|
|
@@ -470,7 +473,7 @@ describe('source references', () => {
|
|
|
470
473
|
});
|
|
471
474
|
test.skip('reference to field in order by', () => {
|
|
472
475
|
const source = (0, test_translator_1.markSource) `
|
|
473
|
-
|
|
476
|
+
run: ${"_db_.table('aTable')"} -> {
|
|
474
477
|
group_by: abool
|
|
475
478
|
order_by: ${'abool'}
|
|
476
479
|
}
|
|
@@ -488,7 +491,7 @@ describe('source references', () => {
|
|
|
488
491
|
});
|
|
489
492
|
test.skip('reference to field in order by (output space)', () => {
|
|
490
493
|
const source = (0, test_translator_1.markSource) `
|
|
491
|
-
|
|
494
|
+
run: a -> {
|
|
492
495
|
group_by: ${'one is 1'}
|
|
493
496
|
order_by: ${'one'}
|
|
494
497
|
}
|
|
@@ -506,7 +509,7 @@ describe('source references', () => {
|
|
|
506
509
|
});
|
|
507
510
|
test('reference to field in aggregate', () => {
|
|
508
511
|
const source = (0, test_translator_1.markSource) `
|
|
509
|
-
|
|
512
|
+
run: a extend { measure: ${'c is count()'} } -> {
|
|
510
513
|
group_by: abool
|
|
511
514
|
aggregate: ${'c'}
|
|
512
515
|
}
|
|
@@ -524,7 +527,7 @@ describe('source references', () => {
|
|
|
524
527
|
});
|
|
525
528
|
test('reference to field in measure', () => {
|
|
526
529
|
const source = (0, test_translator_1.markSource) `
|
|
527
|
-
source: e is a {
|
|
530
|
+
source: e is a extend {
|
|
528
531
|
measure: ${'c is count()'}
|
|
529
532
|
measure: c2 is ${'c'}
|
|
530
533
|
}
|
|
@@ -542,7 +545,7 @@ describe('source references', () => {
|
|
|
542
545
|
});
|
|
543
546
|
test.skip('reference to field in top', () => {
|
|
544
547
|
const source = (0, test_translator_1.markSource) `
|
|
545
|
-
|
|
548
|
+
run: ${"_db_.table('aTable')"} -> {
|
|
546
549
|
group_by: abool
|
|
547
550
|
top: 10 by ${'abool'}
|
|
548
551
|
}
|
|
@@ -560,7 +563,7 @@ describe('source references', () => {
|
|
|
560
563
|
});
|
|
561
564
|
test.skip('reference to field in top (output space)', () => {
|
|
562
565
|
const source = (0, test_translator_1.markSource) `
|
|
563
|
-
|
|
566
|
+
run: a -> {
|
|
564
567
|
group_by: ${'one is 1'}
|
|
565
568
|
top: 10 by ${'one'}
|
|
566
569
|
}
|
|
@@ -578,7 +581,7 @@ describe('source references', () => {
|
|
|
578
581
|
});
|
|
579
582
|
test('reference to field in filter', () => {
|
|
580
583
|
const source = (0, test_translator_1.markSource) `
|
|
581
|
-
|
|
584
|
+
run: ${"_db_.table('aTable')"} -> {
|
|
582
585
|
group_by: abool
|
|
583
586
|
where: ${'abool'}
|
|
584
587
|
}
|
|
@@ -596,8 +599,8 @@ describe('source references', () => {
|
|
|
596
599
|
});
|
|
597
600
|
test('reference to field in aggregate source', () => {
|
|
598
601
|
const source = (0, test_translator_1.markSource) `
|
|
599
|
-
source: na is ${"table('aTable')"}
|
|
600
|
-
|
|
602
|
+
source: na is ${"_db_.table('aTable')"}
|
|
603
|
+
run: na -> { aggregate: ai_sum is ${'ai'}.sum() }
|
|
601
604
|
`;
|
|
602
605
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
603
606
|
expect(m).toTranslate();
|
|
@@ -615,10 +618,10 @@ describe('source references', () => {
|
|
|
615
618
|
}
|
|
616
619
|
test('reference to join in aggregate source', () => {
|
|
617
620
|
const source = (0, test_translator_1.markSource) `
|
|
618
|
-
source: na is a {
|
|
621
|
+
source: na is a extend {
|
|
619
622
|
join_one: ${'self is a on astr = self.astr'}
|
|
620
623
|
}
|
|
621
|
-
|
|
624
|
+
run: na -> { aggregate: ai_sum is ${'self'}.sum(self.ai) }
|
|
622
625
|
`;
|
|
623
626
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
624
627
|
expect(m).toTranslate();
|
|
@@ -633,10 +636,10 @@ describe('source references', () => {
|
|
|
633
636
|
});
|
|
634
637
|
test('reference to join in aggregate in expr', () => {
|
|
635
638
|
const source = (0, test_translator_1.markSource) `
|
|
636
|
-
source: na is a {
|
|
639
|
+
source: na is a extend {
|
|
637
640
|
join_one: ${'self is a on astr = self.astr'}
|
|
638
641
|
}
|
|
639
|
-
|
|
642
|
+
run: na -> { aggregate: ai_sum is self.sum(${'self'}.ai) }
|
|
640
643
|
`;
|
|
641
644
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
642
645
|
expect(m).toTranslate();
|
|
@@ -652,7 +655,7 @@ describe('source references', () => {
|
|
|
652
655
|
test('reference to sourcein join', () => {
|
|
653
656
|
const source = (0, test_translator_1.markSource) `
|
|
654
657
|
source: ${'exp1 is a'}
|
|
655
|
-
source: exp2 is a {
|
|
658
|
+
source: exp2 is a extend {
|
|
656
659
|
join_one: ${'exp1'} on astr = exp1.astr
|
|
657
660
|
}
|
|
658
661
|
`;
|
|
@@ -669,8 +672,8 @@ describe('source references', () => {
|
|
|
669
672
|
});
|
|
670
673
|
test('reference to field in aggregate (in expr)', () => {
|
|
671
674
|
const source = (0, test_translator_1.markSource) `
|
|
672
|
-
source: na is ${"table('aTable')"}
|
|
673
|
-
|
|
675
|
+
source: na is ${"_db_.table('aTable')"}
|
|
676
|
+
run: na -> { aggregate: ai_sum is sum(${'ai'}) }
|
|
674
677
|
`;
|
|
675
678
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
676
679
|
expect(m).toTranslate();
|
|
@@ -685,7 +688,7 @@ describe('source references', () => {
|
|
|
685
688
|
});
|
|
686
689
|
test('reference to field in rename', () => {
|
|
687
690
|
const source = (0, test_translator_1.markSource) `
|
|
688
|
-
source: na is ${"table('aTable')"} {
|
|
691
|
+
source: na is ${"_db_.table('aTable')"} extend {
|
|
689
692
|
rename: bbool is ${'abool'}
|
|
690
693
|
}
|
|
691
694
|
`;
|
|
@@ -702,9 +705,8 @@ describe('source references', () => {
|
|
|
702
705
|
});
|
|
703
706
|
test('reference to field in join with', () => {
|
|
704
707
|
const source = (0, test_translator_1.markSource) `
|
|
705
|
-
source:
|
|
706
|
-
|
|
707
|
-
join_one: exp1 with ${'astr'}
|
|
708
|
+
source: exp2 is ${"_db_.table('aTable')"} extend {
|
|
709
|
+
join_one: exp1 is a with ${'astr'}
|
|
708
710
|
}
|
|
709
711
|
`;
|
|
710
712
|
const m = new test_translator_1.TestTranslator(source.code);
|
|
@@ -250,7 +250,11 @@ function checkForProblems(context, expectCompiles, s, defaultSeverity, ...msgs)
|
|
|
250
250
|
}
|
|
251
251
|
return {
|
|
252
252
|
pass: false,
|
|
253
|
-
message: () => `Compiler errors did not match expected errors\n${explain.join('\n')}
|
|
253
|
+
message: () => `Compiler errors did not match expected errors\n${explain.join('\n')}
|
|
254
|
+
-------- FROM SOURCE --------
|
|
255
|
+
${src}
|
|
256
|
+
-----------------------------
|
|
257
|
+
`,
|
|
254
258
|
};
|
|
255
259
|
}
|
|
256
260
|
}
|