@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.
Files changed (66) hide show
  1. package/dist/api/core.d.ts +1 -0
  2. package/dist/api/core.js +2 -1
  3. package/dist/lang/malloy-parse-info.d.ts +2 -10
  4. package/dist/lang/malloy-to-ast.d.ts +1 -0
  5. package/dist/lang/malloy-to-ast.js +9 -6
  6. package/dist/lang/malloy-to-stable-query.d.ts +76 -0
  7. package/dist/lang/malloy-to-stable-query.js +660 -0
  8. package/dist/lang/parse-log.d.ts +1 -0
  9. package/dist/lang/parse-malloy.d.ts +2 -9
  10. package/dist/lang/parse-malloy.js +7 -112
  11. package/dist/lang/parse-tree-walkers/model-annotation-walker.js +1 -1
  12. package/dist/lang/run-malloy-parser.d.ts +3 -0
  13. package/dist/lang/run-malloy-parser.js +53 -0
  14. package/dist/lang/syntax-errors/malloy-parser-error-listener.d.ts +4 -3
  15. package/dist/lang/syntax-errors/malloy-parser-error-listener.js +8 -4
  16. package/dist/lang/utils.d.ts +27 -1
  17. package/dist/lang/utils.js +78 -1
  18. package/package.json +3 -3
  19. package/dist/api/asynchronous.spec.d.ts +0 -1
  20. package/dist/api/asynchronous.spec.js +0 -240
  21. package/dist/api/sessioned.spec.d.ts +0 -1
  22. package/dist/api/sessioned.spec.js +0 -476
  23. package/dist/api/stateless.spec.d.ts +0 -1
  24. package/dist/api/stateless.spec.js +0 -400
  25. package/dist/lang/test/annotation.spec.d.ts +0 -14
  26. package/dist/lang/test/annotation.spec.js +0 -809
  27. package/dist/lang/test/composite-field-usage.spec.d.ts +0 -1
  28. package/dist/lang/test/composite-field-usage.spec.js +0 -261
  29. package/dist/lang/test/document-help-context-walker.spec.d.ts +0 -1
  30. package/dist/lang/test/document-help-context-walker.spec.js +0 -55
  31. package/dist/lang/test/document-symbol-walker.spec.d.ts +0 -1
  32. package/dist/lang/test/document-symbol-walker.spec.js +0 -209
  33. package/dist/lang/test/expressions.spec.d.ts +0 -1
  34. package/dist/lang/test/expressions.spec.js +0 -1181
  35. package/dist/lang/test/field-symbols.spec.d.ts +0 -1
  36. package/dist/lang/test/field-symbols.spec.js +0 -194
  37. package/dist/lang/test/find-table-path-walker.spec.d.ts +0 -1
  38. package/dist/lang/test/find-table-path-walker.spec.js +0 -50
  39. package/dist/lang/test/imports.spec.d.ts +0 -1
  40. package/dist/lang/test/imports.spec.js +0 -283
  41. package/dist/lang/test/lenses.spec.d.ts +0 -1
  42. package/dist/lang/test/lenses.spec.js +0 -384
  43. package/dist/lang/test/literals.spec.d.ts +0 -1
  44. package/dist/lang/test/literals.spec.js +0 -267
  45. package/dist/lang/test/locations.spec.d.ts +0 -1
  46. package/dist/lang/test/locations.spec.js +0 -679
  47. package/dist/lang/test/model-annotation-walker.spec.d.ts +0 -1
  48. package/dist/lang/test/model-annotation-walker.spec.js +0 -46
  49. package/dist/lang/test/model_serialization.spec.d.ts +0 -5
  50. package/dist/lang/test/model_serialization.spec.js +0 -116
  51. package/dist/lang/test/parameters.spec.d.ts +0 -1
  52. package/dist/lang/test/parameters.spec.js +0 -619
  53. package/dist/lang/test/parse.spec.d.ts +0 -1
  54. package/dist/lang/test/parse.spec.js +0 -893
  55. package/dist/lang/test/pretranslate.spec.d.ts +0 -1
  56. package/dist/lang/test/pretranslate.spec.js +0 -80
  57. package/dist/lang/test/query.spec.d.ts +0 -1
  58. package/dist/lang/test/query.spec.js +0 -1149
  59. package/dist/lang/test/source.spec.d.ts +0 -1
  60. package/dist/lang/test/source.spec.js +0 -570
  61. package/dist/lang/test/sql-block.spec.d.ts +0 -1
  62. package/dist/lang/test/sql-block.spec.js +0 -145
  63. package/dist/lang/test/syntax-errors.spec.d.ts +0 -1
  64. package/dist/lang/test/syntax-errors.spec.js +0 -142
  65. package/dist/model/utils.spec.d.ts +0 -1
  66. package/dist/model/utils.spec.js +0 -38
@@ -1,679 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright 2023 Google LLC
4
- *
5
- * Permission is hereby granted, free of charge, to any person obtaining
6
- * a copy of this software and associated documentation files
7
- * (the "Software"), to deal in the Software without restriction,
8
- * including without limitation the rights to use, copy, modify, merge,
9
- * publish, distribute, sublicense, and/or sell copies of the Software,
10
- * and to permit persons to whom the Software is furnished to do so,
11
- * subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be
14
- * included in all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
- */
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- const test_translator_1 = require("./test-translator");
26
- require("./parse-expects");
27
- describe('source locations', () => {
28
- test('renamed source location', () => {
29
- const source = (0, test_translator_1.markSource) `source: ${'na is a'}`;
30
- const m = new test_translator_1.TestTranslator(source.code);
31
- expect(m).toParse();
32
- expect((0, test_translator_1.getExplore)(m.modelDef, 'na').location).toMatchObject(source.locations[0]);
33
- });
34
- test('refined source location', () => {
35
- const source = (0, test_translator_1.markSource) `source: ${'na is a extend {}'}`;
36
- const m = new test_translator_1.TestTranslator(source.code);
37
- expect(m).toParse();
38
- expect((0, test_translator_1.getExplore)(m.modelDef, 'na').location).toMatchObject(source.locations[0]);
39
- });
40
- // TODO make parameters have locations, and make references to them work
41
- // with existing jump-to-definition system
42
- test.todo('location of parameter');
43
- test('location of defined dimension', () => {
44
- const source = (0, test_translator_1.markSource) `source: na is a extend { dimension: ${'x is 1'} }`;
45
- const m = new test_translator_1.TestTranslator(source.code);
46
- expect(m).toTranslate();
47
- const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
48
- const x = (0, test_translator_1.getFieldDef)(na, 'x');
49
- expect(x.location).toMatchObject(source.locations[0]);
50
- });
51
- test('location of defined measure', () => {
52
- const source = (0, test_translator_1.markSource) `source: na is a extend { measure: ${'x is count()'} }`;
53
- const m = new test_translator_1.TestTranslator(source.code);
54
- expect(m).toTranslate();
55
- const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
56
- const x = (0, test_translator_1.getFieldDef)(na, 'x');
57
- expect(x.location).toMatchObject(source.locations[0]);
58
- });
59
- test('location of defined view', () => {
60
- const source = (0, test_translator_1.markSource) `source: na is a extend { view: ${'x is { group_by: y is 1 }'} }`;
61
- const m = new test_translator_1.TestTranslator(source.code);
62
- expect(m).toTranslate();
63
- const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
64
- const x = (0, test_translator_1.getFieldDef)(na, 'x');
65
- expect(x.location).toMatchObject(source.locations[0]);
66
- });
67
- test('location of defined field inside a view', () => {
68
- const source = (0, test_translator_1.markSource) `
69
- source: na is a extend {
70
- view: x is {
71
- group_by: ${'y is 1'}
72
- }
73
- }`;
74
- const m = new test_translator_1.TestTranslator(source.code);
75
- expect(m).toTranslate();
76
- const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
77
- const x = (0, test_translator_1.getQueryField)(na, 'x');
78
- const y = (0, test_translator_1.getQueryFieldDef)(x.pipeline[0], 'y');
79
- // mtoy todo ask chris if there should be locations
80
- if (y.type !== 'fieldref') {
81
- expect(y.location).toMatchObject(source.locations[0]);
82
- }
83
- });
84
- test('location of filtered field inside a view', () => {
85
- const source = (0, test_translator_1.markSource) `
86
- source: na is a extend {
87
- measure: y is count()
88
- view: x is {
89
- aggregate: ${'z is y { where: true }'}
90
- }
91
- }`;
92
- const m = new test_translator_1.TestTranslator(source.code);
93
- expect(m).toTranslate();
94
- const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
95
- const x = (0, test_translator_1.getQueryField)(na, 'x');
96
- const z = (0, test_translator_1.getQueryFieldDef)(x.pipeline[0], 'z');
97
- if (z.type !== 'fieldref') {
98
- expect(z.location).toMatchObject(source.locations[0]);
99
- }
100
- });
101
- test('location of field inherited from table', () => {
102
- const source = (0, test_translator_1.markSource) `source: na is ${"_db_.table('aTable')"}`;
103
- const m = new test_translator_1.TestTranslator(source.code);
104
- expect(m).toTranslate();
105
- const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
106
- const abool = (0, test_translator_1.getFieldDef)(na, 'abool');
107
- expect(abool.location).toMatchObject(source.locations[0]);
108
- });
109
- test('location of field inherited from sql source', () => {
110
- const source = (0, test_translator_1.markSource) `
111
- source: na is conn.sql(${'"""SELECT 1 as one """'})
112
- `;
113
- const m = new test_translator_1.TestTranslator(source.code);
114
- expect(m).toParse();
115
- const compileSql = m.translate().compileSQL;
116
- expect(compileSql).toBeDefined();
117
- if (compileSql) {
118
- m.update({
119
- compileSQL: (0, test_translator_1.getSelectOneStruct)(compileSql),
120
- });
121
- expect(m).toTranslate();
122
- const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
123
- const one = (0, test_translator_1.getFieldDef)(na, 'one');
124
- expect(one.location).isLocationIn(source.locations[0], source.code);
125
- }
126
- });
127
- test('location of fields inherited from a query', () => {
128
- const source = (0, test_translator_1.markSource) `
129
- source: na is ${"_db_.table('aTable')"} -> {
130
- group_by:
131
- abool
132
- ${'y is 1'}
133
- }
134
- `;
135
- const m = new test_translator_1.TestTranslator(source.code);
136
- expect(m).toTranslate();
137
- const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
138
- const abool = (0, test_translator_1.getFieldDef)(na, 'abool');
139
- expect(abool.location).toMatchObject(source.locations[0]);
140
- const y = (0, test_translator_1.getFieldDef)(na, 'y');
141
- expect(y.location).toMatchObject(source.locations[1]);
142
- });
143
- test('location of named query', () => {
144
- const source = (0, test_translator_1.markSource) `query: ${'q is a -> { select: * }'}`;
145
- const m = new test_translator_1.TestTranslator(source.code);
146
- expect(m).toTranslate();
147
- const q = (0, test_translator_1.getExplore)(m.modelDef, 'q');
148
- expect(q.location).toMatchObject(source.locations[0]);
149
- });
150
- test('location of field in named query', () => {
151
- const source = (0, test_translator_1.markSource) `query: q is a -> { group_by: ${'b is 1'} }`;
152
- const m = new test_translator_1.TestTranslator(source.code);
153
- expect(m).toTranslate();
154
- const q = (0, test_translator_1.getModelQuery)(m.modelDef, 'q');
155
- const a = (0, test_translator_1.getQueryFieldDef)(q.pipeline[0], 'b');
156
- if (a.type !== 'fieldref') {
157
- expect(a.location).toMatchObject(source.locations[0]);
158
- }
159
- });
160
- test('location of renamed field', () => {
161
- const source = (0, test_translator_1.markSource) `
162
- source: na is a extend {
163
- rename: ${'bbool is abool'}
164
- }
165
- `;
166
- const m = new test_translator_1.TestTranslator(source.code);
167
- expect(m).toTranslate();
168
- const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
169
- const bbool = (0, test_translator_1.getFieldDef)(na, 'bbool');
170
- expect(bbool.location).toMatchObject(source.locations[0]);
171
- });
172
- test('location of join on', () => {
173
- const source = (0, test_translator_1.markSource) `
174
- source: na is a extend {
175
- join_one: ${'x is a extend { primary_key: abool } on abool'}
176
- }
177
- `;
178
- const m = new test_translator_1.TestTranslator(source.code);
179
- expect(m).toTranslate();
180
- const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
181
- const x = (0, test_translator_1.getFieldDef)(na, 'x');
182
- expect(x.location).toMatchObject(source.locations[0]);
183
- });
184
- test('location of join with', () => {
185
- const source = (0, test_translator_1.markSource) `
186
- source: na is a extend {
187
- join_one: ${'x is a extend { primary_key: astr } with astr'}
188
- }
189
- `;
190
- const m = new test_translator_1.TestTranslator(source.code);
191
- expect(m).toTranslate();
192
- const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
193
- const x = (0, test_translator_1.getFieldDef)(na, 'x');
194
- expect(x.location).toMatchObject(source.locations[0]);
195
- });
196
- test('location of field in join', () => {
197
- const source = (0, test_translator_1.markSource) `
198
- source: na is a extend {
199
- join_one: x is a extend {
200
- primary_key: abool
201
- dimension: ${'y is 1'}
202
- } on abool
203
- }
204
- `;
205
- const m = new test_translator_1.TestTranslator(source.code);
206
- expect(m).toTranslate();
207
- const na = (0, test_translator_1.getExplore)(m.modelDef, 'na');
208
- const x = (0, test_translator_1.getJoinField)(na, 'x');
209
- const y = (0, test_translator_1.getFieldDef)(x, 'y');
210
- expect(y.location).toMatchObject(source.locations[0]);
211
- });
212
- test('undefined query location', () => {
213
- expect((0, test_translator_1.model) `run: ${'xyz'}`).toLog((0, test_translator_1.errorMessage)("Reference to undefined object 'xyz'"));
214
- });
215
- test('undefined field reference', () => {
216
- expect((0, test_translator_1.model) `run: a -> { group_by: ${'xyz'} }`).toLog((0, test_translator_1.errorMessage)("'xyz' is not defined"));
217
- });
218
- test('bad query', () => {
219
- expect((0, test_translator_1.model) `run: a -> { group_by: astr; ${'select: *'} }`).toLog((0, test_translator_1.errorMessage)(/Not legal in grouping query/));
220
- });
221
- test.skip('undefined field reference in top', () => {
222
- expect((0, test_translator_1.model) `run: a -> { group_by: one is 1; top: 1 by ${'xyz'} }`).toLog((0, test_translator_1.errorMessage)("'xyz' is not defined"));
223
- });
224
- test.skip('undefined field reference in order_by', () => {
225
- expect((0, test_translator_1.model) `run: a -> { group_by: one is 1; order_by: ${'xyz'} }`).toLog((0, test_translator_1.errorMessage)("'xyz' is not defined"));
226
- });
227
- });
228
- describe('source references', () => {
229
- test('reference to explore', () => {
230
- const source = (0, test_translator_1.markSource) `
231
- source: ${'na is a'}
232
- run: ${'na'} -> { select: * }
233
- `;
234
- const m = new test_translator_1.TestTranslator(source.code);
235
- expect(m).toTranslate();
236
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
237
- location: source.locations[1],
238
- type: 'exploreReference',
239
- text: 'na',
240
- definition: {
241
- location: source.locations[0],
242
- },
243
- });
244
- });
245
- test('reference to query in query', () => {
246
- const source = (0, test_translator_1.markSource) `
247
- source: t is a extend {
248
- view: ${'q is { select: * }'}
249
- }
250
- run: t -> ${'q'}
251
- `;
252
- const m = new test_translator_1.TestTranslator(source.code);
253
- expect(m).toTranslate();
254
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
255
- location: source.locations[1],
256
- type: 'fieldReference',
257
- text: 'q',
258
- definition: {
259
- location: source.locations[0],
260
- },
261
- });
262
- });
263
- test('reference to query in query (version 2)', () => {
264
- const source = (0, test_translator_1.markSource) `
265
- source: na is a extend { view: ${'x is { group_by: y is 1 }'} }
266
- run: na -> ${'x'}
267
- `;
268
- const m = new test_translator_1.TestTranslator(source.code);
269
- expect(m).toTranslate();
270
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
271
- location: source.locations[1],
272
- type: 'fieldReference',
273
- text: 'x',
274
- definition: {
275
- location: source.locations[0],
276
- },
277
- });
278
- });
279
- test('reference to query', () => {
280
- const source = (0, test_translator_1.model) `
281
- query: ${'q is a -> { select: * }'}
282
- source: na is ${'q'}
283
- `;
284
- expect(source).toTranslate();
285
- const mt = source.translator;
286
- expect(mt.referenceAt(pos(source.locations[1]))).toMatchObject({
287
- location: source.locations[1],
288
- type: 'queryReference',
289
- text: 'q',
290
- definition: {
291
- location: source.locations[0],
292
- },
293
- });
294
- });
295
- test('reference to query in query head', () => {
296
- const source = (0, test_translator_1.markSource) `
297
- query: ${'q is a -> { select: * }'}
298
- query: q2 is ${'q'} -> { select: * }
299
- `;
300
- const m = new test_translator_1.TestTranslator(source.code);
301
- expect(m).toTranslate();
302
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
303
- location: source.locations[1],
304
- type: 'queryReference',
305
- text: 'q',
306
- definition: {
307
- location: source.locations[0],
308
- },
309
- });
310
- });
311
- test('reference to query in refined query', () => {
312
- const source = (0, test_translator_1.markSource) `
313
- query: ${'q is a -> { select: * }'}
314
- query: q2 is ${'q'} + { limit: 10 }
315
- `;
316
- const m = new test_translator_1.TestTranslator(source.code);
317
- expect(m).toTranslate();
318
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
319
- location: source.locations[1],
320
- type: 'queryReference',
321
- text: 'q',
322
- definition: {
323
- location: source.locations[0],
324
- },
325
- });
326
- });
327
- test('reference to field in expression', () => {
328
- const source = (0, test_translator_1.markSource) `
329
- source: na is ${"_db_.table('aTable')"}
330
- run: na -> { select: bbool is not ${'abool'} }
331
- `;
332
- const m = new test_translator_1.TestTranslator(source.code);
333
- expect(m).toTranslate();
334
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
335
- location: source.locations[1],
336
- type: 'fieldReference',
337
- text: 'abool',
338
- definition: {
339
- location: source.locations[0],
340
- },
341
- });
342
- });
343
- test('reference to quoted field in expression', () => {
344
- const source = (0, test_translator_1.markSource) `
345
- source: na is a extend {
346
- dimension: ${"`name` is 'name'"}
347
- }
348
- run: na -> { select: ${'`name`'} }
349
- `;
350
- const m = new test_translator_1.TestTranslator(source.code);
351
- expect(m).toTranslate();
352
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
353
- location: source.locations[1],
354
- type: 'fieldReference',
355
- text: 'name',
356
- definition: {
357
- location: source.locations[0],
358
- },
359
- });
360
- });
361
- test('reference to joined field in expression', () => {
362
- const source = (0, test_translator_1.markSource) `
363
- source: na is a extend {
364
- join_one: self is ${"_db_.table('aTable')"}
365
- on astr = self.astr
366
- }
367
- run: na -> { select: bstr is self.${'astr'} }
368
- `;
369
- const m = new test_translator_1.TestTranslator(source.code);
370
- expect(m).toTranslate();
371
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
372
- location: source.locations[1],
373
- type: 'fieldReference',
374
- text: 'astr',
375
- definition: {
376
- location: source.locations[0],
377
- },
378
- });
379
- });
380
- test('reference to joined join in expression', () => {
381
- const source = (0, test_translator_1.markSource) `
382
- source: na is a extend {
383
- join_one: ${'self is a on astr = self.astr'}
384
- }
385
- run: na -> { select: bstr is ${'self'}.astr }
386
- `;
387
- const m = new test_translator_1.TestTranslator(source.code);
388
- expect(m).toTranslate();
389
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
390
- location: source.locations[1],
391
- type: 'joinReference',
392
- text: 'self',
393
- definition: {
394
- location: source.locations[0],
395
- },
396
- });
397
- });
398
- test('reference to field not in expression (group by)', () => {
399
- const source = (0, test_translator_1.markSource) `
400
- run: ${"_db_.table('aTable')"} -> { group_by: ${'abool'} }
401
- `;
402
- const m = new test_translator_1.TestTranslator(source.code);
403
- expect(m).toTranslate();
404
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
405
- location: source.locations[1],
406
- type: 'fieldReference',
407
- text: 'abool',
408
- definition: {
409
- location: source.locations[0],
410
- },
411
- });
412
- });
413
- test('reference to field not in expression (project)', () => {
414
- const source = (0, test_translator_1.markSource) `
415
- source: na is ${"_db_.table('aTable')"}
416
- run: na -> { select: ${'abool'} }
417
- `;
418
- const m = new test_translator_1.TestTranslator(source.code);
419
- expect(m).toTranslate();
420
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
421
- location: source.locations[1],
422
- type: 'fieldReference',
423
- text: 'abool',
424
- definition: {
425
- location: source.locations[0],
426
- },
427
- });
428
- });
429
- test.skip('reference to field in order by', () => {
430
- const source = (0, test_translator_1.markSource) `
431
- run: ${"_db_.table('aTable')"} -> {
432
- group_by: abool
433
- order_by: ${'abool'}
434
- }
435
- `;
436
- const m = new test_translator_1.TestTranslator(source.code);
437
- expect(m).toTranslate();
438
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
439
- location: source.locations[1],
440
- type: 'fieldReference',
441
- text: 'abool',
442
- definition: {
443
- location: source.locations[0],
444
- },
445
- });
446
- });
447
- test.skip('reference to field in order by (output space)', () => {
448
- const source = (0, test_translator_1.markSource) `
449
- run: a -> {
450
- group_by: ${'one is 1'}
451
- order_by: ${'one'}
452
- }
453
- `;
454
- const m = new test_translator_1.TestTranslator(source.code);
455
- expect(m).toTranslate();
456
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
457
- location: source.locations[1],
458
- type: 'fieldReference',
459
- text: 'abool',
460
- definition: {
461
- location: source.locations[0],
462
- },
463
- });
464
- });
465
- test('reference to field in aggregate', () => {
466
- const source = (0, test_translator_1.markSource) `
467
- run: a extend { measure: ${'c is count()'} } -> {
468
- group_by: abool
469
- aggregate: ${'c'}
470
- }
471
- `;
472
- const m = new test_translator_1.TestTranslator(source.code);
473
- expect(m).toTranslate();
474
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
475
- location: source.locations[1],
476
- type: 'fieldReference',
477
- text: 'c',
478
- definition: {
479
- location: source.locations[0],
480
- },
481
- });
482
- });
483
- test('reference to field in measure', () => {
484
- const source = (0, test_translator_1.markSource) `
485
- source: e is a extend {
486
- measure: ${'c is count()'}
487
- measure: c2 is ${'c'}
488
- }
489
- `;
490
- const m = new test_translator_1.TestTranslator(source.code);
491
- expect(m).toTranslate();
492
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
493
- location: source.locations[1],
494
- type: 'fieldReference',
495
- text: 'c',
496
- definition: {
497
- location: source.locations[0],
498
- },
499
- });
500
- });
501
- test.skip('reference to field in top', () => {
502
- const source = (0, test_translator_1.markSource) `
503
- run: ${"_db_.table('aTable')"} -> {
504
- group_by: abool
505
- top: 10 by ${'abool'}
506
- }
507
- `;
508
- const m = new test_translator_1.TestTranslator(source.code);
509
- expect(m).toTranslate();
510
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
511
- location: source.locations[1],
512
- type: 'fieldReference',
513
- text: 'abool',
514
- definition: {
515
- location: source.locations[0],
516
- },
517
- });
518
- });
519
- test.skip('reference to field in top (output space)', () => {
520
- const source = (0, test_translator_1.markSource) `
521
- run: a -> {
522
- group_by: ${'one is 1'}
523
- top: 10 by ${'one'}
524
- }
525
- `;
526
- const m = new test_translator_1.TestTranslator(source.code);
527
- expect(m).toTranslate();
528
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
529
- location: source.locations[1],
530
- type: 'fieldReference',
531
- text: 'abool',
532
- definition: {
533
- location: source.locations[0],
534
- },
535
- });
536
- });
537
- test('reference to field in filter', () => {
538
- const source = (0, test_translator_1.markSource) `
539
- run: ${"_db_.table('aTable')"} -> {
540
- group_by: abool
541
- where: ${'abool'}
542
- }
543
- `;
544
- const m = new test_translator_1.TestTranslator(source.code);
545
- expect(m).toTranslate();
546
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
547
- location: source.locations[1],
548
- type: 'fieldReference',
549
- text: 'abool',
550
- definition: {
551
- location: source.locations[0],
552
- },
553
- });
554
- });
555
- test('reference to field in aggregate source', () => {
556
- const source = (0, test_translator_1.markSource) `
557
- source: na is ${"_db_.table('aTable')"}
558
- run: na -> { aggregate: ai_sum is ${'ai'}.sum() }
559
- `;
560
- const m = new test_translator_1.TestTranslator(source.code);
561
- expect(m).toTranslate();
562
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
563
- location: source.locations[1],
564
- type: 'fieldReference',
565
- text: 'ai',
566
- definition: {
567
- location: source.locations[0],
568
- },
569
- });
570
- });
571
- function pos(location) {
572
- return location.range.start;
573
- }
574
- test('reference to join in aggregate source', () => {
575
- const source = (0, test_translator_1.markSource) `
576
- source: na is a extend {
577
- join_one: ${'self is a on astr = self.astr'}
578
- }
579
- run: na -> { aggregate: ai_sum is ${'self'}.sum(self.ai) }
580
- `;
581
- const m = new test_translator_1.TestTranslator(source.code);
582
- expect(m).toTranslate();
583
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
584
- location: source.locations[1],
585
- type: 'joinReference',
586
- text: 'self',
587
- definition: {
588
- location: source.locations[0],
589
- },
590
- });
591
- });
592
- test('reference to join in aggregate in expr', () => {
593
- const source = (0, test_translator_1.markSource) `
594
- source: na is a extend {
595
- join_one: ${'self is a on astr = self.astr'}
596
- }
597
- run: na -> { aggregate: ai_sum is self.sum(${'self'}.ai) }
598
- `;
599
- const m = new test_translator_1.TestTranslator(source.code);
600
- expect(m).toTranslate();
601
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
602
- location: source.locations[1],
603
- type: 'joinReference',
604
- text: 'self',
605
- definition: {
606
- location: source.locations[0],
607
- },
608
- });
609
- });
610
- test('reference to sourcein join', () => {
611
- const source = (0, test_translator_1.markSource) `
612
- source: ${'exp1 is a'}
613
- source: exp2 is a extend {
614
- join_one: ${'exp1'} on astr = exp1.astr
615
- }
616
- `;
617
- const m = new test_translator_1.TestTranslator(source.code);
618
- expect(m).toTranslate();
619
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
620
- location: source.locations[1],
621
- type: 'exploreReference',
622
- text: 'exp1',
623
- definition: {
624
- location: source.locations[0],
625
- },
626
- });
627
- });
628
- test('reference to field in aggregate (in expr)', () => {
629
- const source = (0, test_translator_1.markSource) `
630
- source: na is ${"_db_.table('aTable')"}
631
- run: na -> { aggregate: ai_sum is sum(${'ai'}) }
632
- `;
633
- const m = new test_translator_1.TestTranslator(source.code);
634
- expect(m).toTranslate();
635
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
636
- location: source.locations[1],
637
- type: 'fieldReference',
638
- text: 'ai',
639
- definition: {
640
- location: source.locations[0],
641
- },
642
- });
643
- });
644
- test('reference to field in rename', () => {
645
- const source = (0, test_translator_1.markSource) `
646
- source: na is ${"_db_.table('aTable')"} extend {
647
- rename: bbool is ${'abool'}
648
- }
649
- `;
650
- const m = new test_translator_1.TestTranslator(source.code);
651
- expect(m).toTranslate();
652
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
653
- location: source.locations[1],
654
- type: 'fieldReference',
655
- text: 'abool',
656
- definition: {
657
- location: source.locations[0],
658
- },
659
- });
660
- });
661
- test('reference to field in join with', () => {
662
- const source = (0, test_translator_1.markSource) `
663
- source: exp2 is ${"_db_.table('aTable')"} extend {
664
- join_one: exp1 is a with ${'astr'}
665
- }
666
- `;
667
- const m = new test_translator_1.TestTranslator(source.code);
668
- expect(m).toTranslate();
669
- expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
670
- location: source.locations[1],
671
- type: 'fieldReference',
672
- text: 'astr',
673
- definition: {
674
- location: source.locations[0],
675
- },
676
- });
677
- });
678
- });
679
- //# sourceMappingURL=locations.spec.js.map
@@ -1 +0,0 @@
1
- export {};