@malloydata/malloy 0.0.22-dev230207182613 → 0.0.22-dev230207183024
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/connection_utils.js +7 -7
- package/dist/dialect/dialect.d.ts +1 -1
- package/dist/dialect/duckdb.d.ts +1 -1
- package/dist/dialect/duckdb.js +9 -9
- package/dist/dialect/postgres.d.ts +1 -1
- package/dist/dialect/postgres.js +16 -16
- package/dist/dialect/standardsql.d.ts +1 -1
- package/dist/dialect/standardsql.js +8 -8
- package/dist/index.d.ts +6 -6
- package/dist/lang/ast/ast-utils.js +3 -3
- package/dist/lang/ast/elements/define-query.js +4 -4
- package/dist/lang/ast/elements/define-source.d.ts +1 -1
- package/dist/lang/ast/elements/define-source.js +8 -8
- package/dist/lang/ast/elements/import-statement.js +2 -2
- package/dist/lang/ast/elements/pipeline-desc.d.ts +1 -1
- package/dist/lang/ast/elements/pipeline-desc.js +7 -7
- package/dist/lang/ast/elements/refined-source.d.ts +1 -1
- package/dist/lang/ast/elements/refined-source.js +5 -5
- package/dist/lang/ast/elements/source.js +1 -1
- package/dist/lang/ast/error-factory.js +16 -13
- package/dist/lang/ast/expressions/binary-boolean.d.ts +1 -1
- package/dist/lang/ast/expressions/binary-boolean.js +4 -4
- package/dist/lang/ast/expressions/binary-numeric.d.ts +1 -1
- package/dist/lang/ast/expressions/binary-numeric.js +1 -1
- package/dist/lang/ast/expressions/boolean.js +1 -1
- package/dist/lang/ast/expressions/constant-sub-expression.js +7 -7
- package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +3 -3
- package/dist/lang/ast/expressions/expr-aggregate-function.js +12 -12
- package/dist/lang/ast/expressions/expr-alternation-tree.js +3 -3
- package/dist/lang/ast/expressions/expr-asymmetric.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-asymmetric.js +1 -1
- package/dist/lang/ast/expressions/expr-avg.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-avg.js +1 -1
- package/dist/lang/ast/expressions/expr-cast.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-cast.js +26 -4
- package/dist/lang/ast/expressions/expr-compare.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-compare.js +3 -3
- package/dist/lang/ast/expressions/expr-count.js +6 -6
- package/dist/lang/ast/expressions/expr-filter.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-filter.js +8 -8
- package/dist/lang/ast/expressions/expr-func.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-func.js +3 -3
- package/dist/lang/ast/expressions/expr-granular-time.js +7 -7
- package/dist/lang/ast/expressions/expr-id-reference.js +11 -11
- package/dist/lang/ast/expressions/expr-logical-op.js +1 -1
- package/dist/lang/ast/expressions/expr-minus.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-minus.js +3 -3
- package/dist/lang/ast/expressions/expr-not.js +2 -2
- package/dist/lang/ast/expressions/expr-now.js +7 -7
- package/dist/lang/ast/expressions/expr-null.js +3 -3
- package/dist/lang/ast/expressions/expr-number.js +1 -1
- package/dist/lang/ast/expressions/expr-parens.js +2 -2
- package/dist/lang/ast/expressions/expr-regex.js +3 -3
- package/dist/lang/ast/expressions/expr-string.js +6 -6
- package/dist/lang/ast/expressions/expr-sum.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-sum.js +1 -1
- package/dist/lang/ast/expressions/expr-time-extract.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-time-extract.js +29 -29
- package/dist/lang/ast/expressions/expr-time.js +7 -7
- package/dist/lang/ast/expressions/expr-ungroup.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-ungroup.js +11 -8
- package/dist/lang/ast/expressions/for-range.d.ts +1 -1
- package/dist/lang/ast/expressions/for-range.js +1 -1
- package/dist/lang/ast/expressions/granular-literal.js +12 -12
- package/dist/lang/ast/expressions/partial-compare.d.ts +1 -1
- package/dist/lang/ast/expressions/partial-compare.js +1 -1
- package/dist/lang/ast/expressions/pick-when.d.ts +1 -1
- package/dist/lang/ast/expressions/pick-when.js +11 -11
- package/dist/lang/ast/expressions/range.js +4 -4
- package/dist/lang/ast/expressions/top-by.d.ts +1 -1
- package/dist/lang/ast/expressions/top-by.js +4 -4
- package/dist/lang/ast/expressions/unary.js +1 -1
- package/dist/lang/ast/field-space/dynamic-space.d.ts +1 -1
- package/dist/lang/ast/field-space/dynamic-space.js +1 -1
- package/dist/lang/ast/field-space/index-field-space.js +2 -2
- package/dist/lang/ast/field-space/query-field-struct.js +1 -1
- package/dist/lang/ast/field-space/query-space-field.js +1 -1
- package/dist/lang/ast/field-space/query-spaces.js +2 -2
- package/dist/lang/ast/field-space/reference-field.js +1 -1
- package/dist/lang/ast/field-space/rename-space-field.js +2 -2
- package/dist/lang/ast/field-space/static-space.js +8 -8
- package/dist/lang/ast/field-space/struct-space-field-base.js +1 -1
- package/dist/lang/ast/fragtype-utils.js +2 -2
- package/dist/lang/ast/parameters/constant-parameter.js +9 -9
- package/dist/lang/ast/parameters/has-parameter.js +5 -5
- package/dist/lang/ast/query-elements/anonymous-query.js +1 -1
- package/dist/lang/ast/query-elements/existing-query.d.ts +1 -1
- package/dist/lang/ast/query-elements/existing-query.js +11 -11
- package/dist/lang/ast/query-elements/full-query.js +11 -11
- package/dist/lang/ast/query-elements/query-head-struct.js +1 -1
- package/dist/lang/ast/query-items/field-declaration.d.ts +1 -1
- package/dist/lang/ast/query-items/field-declaration.js +11 -11
- package/dist/lang/ast/query-items/field-references.d.ts +1 -1
- package/dist/lang/ast/query-items/field-references.js +1 -1
- package/dist/lang/ast/query-properties/filters.d.ts +1 -1
- package/dist/lang/ast/query-properties/filters.js +7 -7
- package/dist/lang/ast/query-properties/indexing.d.ts +1 -1
- package/dist/lang/ast/query-properties/indexing.js +2 -2
- package/dist/lang/ast/query-properties/joins.d.ts +1 -1
- package/dist/lang/ast/query-properties/joins.js +17 -14
- package/dist/lang/ast/query-properties/nest.js +4 -4
- package/dist/lang/ast/query-properties/ordering.js +2 -2
- package/dist/lang/ast/query-properties/qop-desc.js +1 -1
- package/dist/lang/ast/query-properties/top.js +3 -3
- package/dist/lang/ast/source-properties/field-list-edit.js +1 -1
- package/dist/lang/ast/source-properties/primary-key.js +1 -1
- package/dist/lang/ast/source-properties/renames.js +1 -1
- package/dist/lang/ast/sources/named-source.d.ts +2 -2
- package/dist/lang/ast/sources/named-source.js +6 -6
- package/dist/lang/ast/sources/query-source.d.ts +1 -1
- package/dist/lang/ast/sources/query-source.js +2 -2
- package/dist/lang/ast/sources/table-source.js +7 -5
- package/dist/lang/ast/space-seed.d.ts +1 -1
- package/dist/lang/ast/sql-elements/sql-statement.js +5 -5
- package/dist/lang/ast/sql-elements/sql-string.js +1 -1
- package/dist/lang/ast/struct-utils.js +2 -2
- package/dist/lang/ast/time-utils.js +32 -32
- package/dist/lang/ast/types/expression-def.js +34 -34
- package/dist/lang/ast/types/malloy-element.d.ts +4 -4
- package/dist/lang/ast/types/malloy-element.js +27 -27
- package/dist/lang/ast/types/query-comp.d.ts +1 -1
- package/dist/lang/ast/types/space-field.js +1 -1
- package/dist/lang/ast/types/space-param.js +2 -2
- package/dist/lang/ast/types/turtle-headed-pipe.d.ts +1 -1
- package/dist/lang/ast/types/turtle-headed-pipe.js +1 -1
- package/dist/lang/ast/types/type-desc.d.ts +1 -1
- package/dist/lang/field-utils.d.ts +1 -1
- package/dist/lang/index.d.ts +1 -1
- package/dist/lang/malloy-to-ast.d.ts +1 -1
- package/dist/lang/malloy-to-ast.js +11 -11
- package/dist/lang/parse-error-handler.js +4 -4
- package/dist/lang/parse-malloy.d.ts +4 -4
- package/dist/lang/parse-malloy.js +61 -61
- package/dist/lang/parse-tree-walkers/document-completion-walker.js +16 -16
- package/dist/lang/parse-tree-walkers/document-help-context-walker.js +10 -10
- package/dist/lang/parse-tree-walkers/document-highlight-walker.js +85 -82
- package/dist/lang/parse-tree-walkers/document-symbol-walker.js +40 -40
- package/dist/lang/parse-tree-walkers/find-external-references.d.ts +1 -1
- package/dist/lang/parse-tree-walkers/find-external-references.js +2 -2
- package/dist/lang/reference-list.d.ts +1 -1
- package/dist/lang/test/document-help-context-walker.spec.js +6 -6
- package/dist/lang/test/document-symbol-walker.spec.js +3 -3
- package/dist/lang/test/field-symbols.spec.js +62 -58
- package/dist/lang/test/parse.spec.js +262 -260
- package/dist/lang/test/test-translator.d.ts +1 -1
- package/dist/lang/test/test-translator.js +139 -139
- package/dist/lang/translate-response.d.ts +1 -1
- package/dist/lang/zone.js +5 -5
- package/dist/malloy.d.ts +5 -5
- package/dist/malloy.js +72 -72
- package/dist/model/malloy_query.d.ts +2 -2
- package/dist/model/malloy_query.js +179 -176
- package/dist/model/malloy_types.js +41 -41
- package/dist/model/sql_block.js +2 -2
- package/package.json +1 -1
|
@@ -84,13 +84,13 @@ function checkForErrors(trans) {
|
|
|
84
84
|
}
|
|
85
85
|
if (trans.logger.hasErrors()) {
|
|
86
86
|
return {
|
|
87
|
-
message: () => `Translation Errors:\n${trans.prettyErrors()}`,
|
|
88
|
-
pass: false
|
|
87
|
+
"message": () => `Translation Errors:\n${trans.prettyErrors()}`,
|
|
88
|
+
"pass": false
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
return {
|
|
92
|
-
message: () => "Unexpected error free translation",
|
|
93
|
-
pass: true
|
|
92
|
+
"message": () => "Unexpected error free translation",
|
|
93
|
+
"pass": true
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
function prettyNeeds(response) {
|
|
@@ -112,13 +112,13 @@ function checkForNeededs(trans) {
|
|
|
112
112
|
const response = trans.translateStep.step(trans);
|
|
113
113
|
if (!response.final) {
|
|
114
114
|
return {
|
|
115
|
-
message: () => `Translation is not complete, needs:\n${prettyNeeds(response)}`,
|
|
116
|
-
pass: false
|
|
115
|
+
"message": () => `Translation is not complete, needs:\n${prettyNeeds(response)}`,
|
|
116
|
+
"pass": false
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
return {
|
|
120
|
-
message: () => "Unexpected complete translation",
|
|
121
|
-
pass: true
|
|
120
|
+
"message": () => "Unexpected complete translation",
|
|
121
|
+
"pass": true
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
function highlightError(dl, txt) {
|
|
@@ -127,7 +127,7 @@ function highlightError(dl, txt) {
|
|
|
127
127
|
}
|
|
128
128
|
const { start, end } = dl.range;
|
|
129
129
|
const output = [
|
|
130
|
-
`${start.line}:${start.character}-${end.line}:${end.character}
|
|
130
|
+
`${start.line}:${start.character}-${end.line}:${end.character}`
|
|
131
131
|
];
|
|
132
132
|
let errStart = start.character;
|
|
133
133
|
const doc = txt.split("\n");
|
|
@@ -156,7 +156,7 @@ function unlocatedStructDef(sd) {
|
|
|
156
156
|
return ret;
|
|
157
157
|
}
|
|
158
158
|
expect.extend({
|
|
159
|
-
toCompile: function (s) {
|
|
159
|
+
"toCompile": function (s) {
|
|
160
160
|
const x = new BetaModel(s);
|
|
161
161
|
x.compile();
|
|
162
162
|
const errorCheck = checkForErrors(x);
|
|
@@ -166,11 +166,11 @@ expect.extend({
|
|
|
166
166
|
x.translate();
|
|
167
167
|
return checkForNeededs(x);
|
|
168
168
|
},
|
|
169
|
-
modelParsed: function (x) {
|
|
169
|
+
"modelParsed": function (x) {
|
|
170
170
|
x.compile();
|
|
171
171
|
return checkForErrors(x);
|
|
172
172
|
},
|
|
173
|
-
modelCompiled: function (x) {
|
|
173
|
+
"modelCompiled": function (x) {
|
|
174
174
|
x.compile();
|
|
175
175
|
const errorCheck = checkForErrors(x);
|
|
176
176
|
if (!errorCheck.pass) {
|
|
@@ -179,10 +179,10 @@ expect.extend({
|
|
|
179
179
|
x.translate();
|
|
180
180
|
return checkForNeededs(x);
|
|
181
181
|
},
|
|
182
|
-
toBeErrorless: function (trans) {
|
|
182
|
+
"toBeErrorless": function (trans) {
|
|
183
183
|
return checkForErrors(trans);
|
|
184
184
|
},
|
|
185
|
-
toReturnType: function (functionCall, returnType) {
|
|
185
|
+
"toReturnType": function (functionCall, returnType) {
|
|
186
186
|
const exprModel = new BetaModel(`explore: x is a { dimension: d is ${functionCall} }`);
|
|
187
187
|
expect(exprModel).modelCompiled();
|
|
188
188
|
const x = exprModel.getSourceDef("x");
|
|
@@ -192,11 +192,11 @@ expect.extend({
|
|
|
192
192
|
expect(d === null || d === void 0 ? void 0 : d.type).toBe(returnType);
|
|
193
193
|
}
|
|
194
194
|
return {
|
|
195
|
-
pass: true,
|
|
196
|
-
message: () => ""
|
|
195
|
+
"pass": true,
|
|
196
|
+
"message": () => ""
|
|
197
197
|
};
|
|
198
198
|
},
|
|
199
|
-
compileToFailWith: function (s, ...msgs) {
|
|
199
|
+
"compileToFailWith": function (s, ...msgs) {
|
|
200
200
|
var _a;
|
|
201
201
|
let emsg = "Compile Error expectation not met\nExpected error";
|
|
202
202
|
let mSrc;
|
|
@@ -226,15 +226,15 @@ expect.extend({
|
|
|
226
226
|
emsg += `\nSource:\n${src}`;
|
|
227
227
|
const t = m.translate();
|
|
228
228
|
if (t.translated) {
|
|
229
|
-
return { pass: false, message: () => emsg };
|
|
229
|
+
return { "pass": false, "message": () => emsg };
|
|
230
230
|
}
|
|
231
231
|
else if (t.errors == undefined) {
|
|
232
232
|
return {
|
|
233
|
-
pass: false,
|
|
234
|
-
message: () => `TEST ERROR, not all objects resolved in source\n` +
|
|
233
|
+
"pass": false,
|
|
234
|
+
"message": () => `TEST ERROR, not all objects resolved in source\n` +
|
|
235
235
|
(0, test_translator_1.pretty)(t) +
|
|
236
236
|
"\n" +
|
|
237
|
-
emsg
|
|
237
|
+
emsg
|
|
238
238
|
};
|
|
239
239
|
}
|
|
240
240
|
else {
|
|
@@ -266,31 +266,31 @@ expect.extend({
|
|
|
266
266
|
}
|
|
267
267
|
if (explain.length == 0) {
|
|
268
268
|
return {
|
|
269
|
-
pass: true,
|
|
270
|
-
message: () => `All expected errors found: ${(0, test_translator_1.pretty)(msgs)}
|
|
269
|
+
"pass": true,
|
|
270
|
+
"message": () => `All expected errors found: ${(0, test_translator_1.pretty)(msgs)}`
|
|
271
271
|
};
|
|
272
272
|
}
|
|
273
273
|
return {
|
|
274
|
-
pass: false,
|
|
275
|
-
message: () => `Compiler did not generated expected errors\n${explain.join("\n")}
|
|
274
|
+
"pass": false,
|
|
275
|
+
"message": () => `Compiler did not generated expected errors\n${explain.join("\n")}`
|
|
276
276
|
};
|
|
277
277
|
}
|
|
278
278
|
},
|
|
279
|
-
isLocationIn: function (checkAt, at, text) {
|
|
279
|
+
"isLocationIn": function (checkAt, at, text) {
|
|
280
280
|
if (this.equals(at, checkAt)) {
|
|
281
281
|
return {
|
|
282
|
-
pass: true,
|
|
283
|
-
message: () => `Locations match
|
|
282
|
+
"pass": true,
|
|
283
|
+
"message": () => `Locations match`
|
|
284
284
|
};
|
|
285
285
|
}
|
|
286
286
|
const errMsg = `Locations do not match\n` +
|
|
287
287
|
`Expected: ${highlightError(at, text)}\n` +
|
|
288
288
|
`Received: ${highlightError(checkAt, text)}\n`;
|
|
289
289
|
return {
|
|
290
|
-
pass: false,
|
|
291
|
-
message: () => errMsg
|
|
290
|
+
"pass": false,
|
|
291
|
+
"message": () => errMsg
|
|
292
292
|
};
|
|
293
|
-
}
|
|
293
|
+
}
|
|
294
294
|
});
|
|
295
295
|
class BetaExpression extends Testable {
|
|
296
296
|
constructor(src) {
|
|
@@ -510,9 +510,9 @@ describe("model statements", () => {
|
|
|
510
510
|
const docParse = new BetaModel(`import "child"`);
|
|
511
511
|
const xr = docParse.unresolved();
|
|
512
512
|
expect(docParse).toBeErrorless();
|
|
513
|
-
expect(xr).toEqual({ urls: ["internal://test/langtests/child"] });
|
|
513
|
+
expect(xr).toEqual({ "urls": ["internal://test/langtests/child"] });
|
|
514
514
|
docParse.update({
|
|
515
|
-
urls: { "internal://test/langtests/child": "explore: aa is a" }
|
|
515
|
+
"urls": { "internal://test/langtests/child": "explore: aa is a" }
|
|
516
516
|
});
|
|
517
517
|
const yr = docParse.unresolved();
|
|
518
518
|
expect(yr).toBeNull();
|
|
@@ -521,10 +521,12 @@ describe("model statements", () => {
|
|
|
521
521
|
const docParse = new BetaModel(`import "child"`);
|
|
522
522
|
const xr = docParse.unresolved();
|
|
523
523
|
expect(docParse).toBeErrorless();
|
|
524
|
-
expect(xr).toEqual({ urls: ["internal://test/langtests/child"] });
|
|
524
|
+
expect(xr).toEqual({ "urls": ["internal://test/langtests/child"] });
|
|
525
525
|
const reportedError = "ENOWAY: No way to find your child";
|
|
526
526
|
docParse.update({
|
|
527
|
-
errors: {
|
|
527
|
+
"errors": {
|
|
528
|
+
"urls": { "internal://test/langtests/child": reportedError }
|
|
529
|
+
}
|
|
528
530
|
});
|
|
529
531
|
docParse.translate();
|
|
530
532
|
expect(docParse).not.toBeErrorless();
|
|
@@ -533,21 +535,21 @@ describe("model statements", () => {
|
|
|
533
535
|
test("chained imports", () => {
|
|
534
536
|
const docParse = new BetaModel(`import "child"`);
|
|
535
537
|
docParse.update({
|
|
536
|
-
urls: { "internal://test/langtests/child": `import "grandChild"` }
|
|
538
|
+
"urls": { "internal://test/langtests/child": `import "grandChild"` }
|
|
537
539
|
});
|
|
538
540
|
const xr = docParse.unresolved();
|
|
539
541
|
expect(docParse).toBeErrorless();
|
|
540
|
-
expect(xr).toEqual({ urls: ["internal://test/langtests/grandChild"] });
|
|
542
|
+
expect(xr).toEqual({ "urls": ["internal://test/langtests/grandChild"] });
|
|
541
543
|
});
|
|
542
544
|
test("relative imports", () => {
|
|
543
545
|
const docParse = new BetaModel(`import "../parent.malloy"`);
|
|
544
546
|
expect(docParse).modelParsed();
|
|
545
547
|
const xr = docParse.unresolved();
|
|
546
|
-
expect(xr).toEqual({ urls: ["internal://test/parent.malloy"] });
|
|
548
|
+
expect(xr).toEqual({ "urls": ["internal://test/parent.malloy"] });
|
|
547
549
|
docParse.update({
|
|
548
|
-
urls: {
|
|
549
|
-
"internal://test/parent.malloy": `source: aa is table('aTable')
|
|
550
|
-
}
|
|
550
|
+
"urls": {
|
|
551
|
+
"internal://test/parent.malloy": `source: aa is table('aTable')`
|
|
552
|
+
}
|
|
551
553
|
});
|
|
552
554
|
expect(docParse).modelCompiled();
|
|
553
555
|
});
|
|
@@ -555,14 +557,14 @@ describe("model statements", () => {
|
|
|
555
557
|
const docParse = new BetaModel(`import "../parent.malloy"`);
|
|
556
558
|
expect(docParse).modelParsed();
|
|
557
559
|
const xr = docParse.unresolved();
|
|
558
|
-
expect(xr).toEqual({ urls: ["internal://test/parent.malloy"] });
|
|
560
|
+
expect(xr).toEqual({ "urls": ["internal://test/parent.malloy"] });
|
|
559
561
|
docParse.update({
|
|
560
|
-
urls: {
|
|
562
|
+
"urls": {
|
|
561
563
|
"internal://test/parent.malloy": `
|
|
562
564
|
source: aa is table('aTable') {
|
|
563
565
|
dimension: astr is 'not legal beause astr exists'
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
+
}`
|
|
567
|
+
}
|
|
566
568
|
});
|
|
567
569
|
expect(docParse).compileToFailWith("Cannot redefine 'astr'");
|
|
568
570
|
});
|
|
@@ -572,12 +574,12 @@ describe("model statements", () => {
|
|
|
572
574
|
import "bottom"
|
|
573
575
|
source: midSrc is from(bottomSrc -> { group_by: astr })
|
|
574
576
|
`,
|
|
575
|
-
"internal://test/langtests/bottom": `source: bottomSrc is table('aTable')
|
|
577
|
+
"internal://test/langtests/bottom": `source: bottomSrc is table('aTable')`
|
|
576
578
|
};
|
|
577
579
|
const fullModel = new BetaModel(`
|
|
578
580
|
import "middle"
|
|
579
581
|
`);
|
|
580
|
-
fullModel.update({ urls: srcFiles });
|
|
582
|
+
fullModel.update({ "urls": srcFiles });
|
|
581
583
|
expect(fullModel).modelCompiled();
|
|
582
584
|
const ms = fullModel.getSourceDef("midSrc");
|
|
583
585
|
expect(ms).toBeDefined();
|
|
@@ -760,7 +762,7 @@ describe("qops", () => {
|
|
|
760
762
|
const index = q.pipeline[0];
|
|
761
763
|
expect(index.type).toBe("index");
|
|
762
764
|
if (index.type == "index") {
|
|
763
|
-
expect(index.sample).toEqual({ percent: 42 });
|
|
765
|
+
expect(index.sample).toEqual({ "percent": 42 });
|
|
764
766
|
}
|
|
765
767
|
}
|
|
766
768
|
});
|
|
@@ -923,7 +925,7 @@ describe("expressions", () => {
|
|
|
923
925
|
"week",
|
|
924
926
|
"month",
|
|
925
927
|
"quarter",
|
|
926
|
-
"year"
|
|
928
|
+
"year"
|
|
927
929
|
];
|
|
928
930
|
describe("timestamp truncation", () => {
|
|
929
931
|
for (const unit of timeframes) {
|
|
@@ -1087,20 +1089,20 @@ describe("sql:", () => {
|
|
|
1087
1089
|
function makeSchemaResponse(sql) {
|
|
1088
1090
|
const cname = sql.connection || "bigquery";
|
|
1089
1091
|
return {
|
|
1090
|
-
type: "struct",
|
|
1091
|
-
name: sql.name,
|
|
1092
|
-
dialect: "standardsql'",
|
|
1093
|
-
structSource: {
|
|
1094
|
-
type: "sql",
|
|
1095
|
-
method: "subquery",
|
|
1096
|
-
sqlBlock: {
|
|
1097
|
-
type: "sqlBlock",
|
|
1092
|
+
"type": "struct",
|
|
1093
|
+
"name": sql.name,
|
|
1094
|
+
"dialect": "standardsql'",
|
|
1095
|
+
"structSource": {
|
|
1096
|
+
"type": "sql",
|
|
1097
|
+
"method": "subquery",
|
|
1098
|
+
"sqlBlock": {
|
|
1099
|
+
"type": "sqlBlock",
|
|
1098
1100
|
...sql,
|
|
1099
|
-
selectStr: sql.select.filter((s) => typeof s == "string").join("")
|
|
1100
|
-
}
|
|
1101
|
+
"selectStr": sql.select.filter((s) => typeof s == "string").join("")
|
|
1102
|
+
}
|
|
1101
1103
|
},
|
|
1102
|
-
structRelationship: { type: "basetable", connectionName: cname },
|
|
1103
|
-
fields: test_translator_1.aTableDef.fields
|
|
1104
|
+
"structRelationship": { "type": "basetable", "connectionName": cname },
|
|
1105
|
+
"fields": test_translator_1.aTableDef.fields
|
|
1104
1106
|
};
|
|
1105
1107
|
}
|
|
1106
1108
|
test("definition", () => {
|
|
@@ -1116,15 +1118,15 @@ describe("sql:", () => {
|
|
|
1116
1118
|
const needs = needReq === null || needReq === void 0 ? void 0 : needReq.compileSQL;
|
|
1117
1119
|
expect(needs).toBeDefined();
|
|
1118
1120
|
if (needs) {
|
|
1119
|
-
const sql = (0, sql_block_1.makeSQLBlock)([{ sql: selStmt }], "aConnection");
|
|
1121
|
+
const sql = (0, sql_block_1.makeSQLBlock)([{ "sql": selStmt }], "aConnection");
|
|
1120
1122
|
expect(needs).toMatchObject(sql);
|
|
1121
1123
|
const refKey = needs.name;
|
|
1122
1124
|
expect(refKey).toBeDefined();
|
|
1123
1125
|
if (refKey) {
|
|
1124
1126
|
const sr = makeSchemaResponse(sql);
|
|
1125
|
-
model.update({ compileSQL: { [refKey]: sr } });
|
|
1127
|
+
model.update({ "compileSQL": { [refKey]: sr } });
|
|
1126
1128
|
expect(model).modelCompiled();
|
|
1127
|
-
expect(unlocatedStructDef(model.sqlBlocks[0])).toEqual(unlocatedStructDef({ ...sr, as: "users" }));
|
|
1129
|
+
expect(unlocatedStructDef(model.sqlBlocks[0])).toEqual(unlocatedStructDef({ ...sr, "as": "users" }));
|
|
1128
1130
|
}
|
|
1129
1131
|
}
|
|
1130
1132
|
});
|
|
@@ -1139,9 +1141,9 @@ describe("sql:", () => {
|
|
|
1139
1141
|
const needs = needReq === null || needReq === void 0 ? void 0 : needReq.compileSQL;
|
|
1140
1142
|
expect(needs).toBeDefined();
|
|
1141
1143
|
if (needs) {
|
|
1142
|
-
const sql = (0, sql_block_1.makeSQLBlock)([{ sql: selStmt }], "aConnection");
|
|
1144
|
+
const sql = (0, sql_block_1.makeSQLBlock)([{ "sql": selStmt }], "aConnection");
|
|
1143
1145
|
const refKey = needs.name;
|
|
1144
|
-
model.update({ compileSQL: { [refKey]: makeSchemaResponse(sql) } });
|
|
1146
|
+
model.update({ "compileSQL": { [refKey]: makeSchemaResponse(sql) } });
|
|
1145
1147
|
expect(model).modelCompiled();
|
|
1146
1148
|
const users = model.getSourceDef("malloyUsers");
|
|
1147
1149
|
expect(users).toBeDefined();
|
|
@@ -1162,8 +1164,8 @@ describe("sql:", () => {
|
|
|
1162
1164
|
const needReq = model.translate();
|
|
1163
1165
|
const needs = needReq === null || needReq === void 0 ? void 0 : needReq.compileSQL;
|
|
1164
1166
|
expect(needs).toBeDefined();
|
|
1165
|
-
const sql = (0, sql_block_1.makeSQLBlock)([{ sql: selStmt }]);
|
|
1166
|
-
model.update({ compileSQL: { [sql.name]: makeSchemaResponse(sql) } });
|
|
1167
|
+
const sql = (0, sql_block_1.makeSQLBlock)([{ "sql": selStmt }]);
|
|
1168
|
+
model.update({ "compileSQL": { [sql.name]: makeSchemaResponse(sql) } });
|
|
1167
1169
|
expect(model).modelCompiled();
|
|
1168
1170
|
});
|
|
1169
1171
|
it("turducken", () => {
|
|
@@ -1179,9 +1181,9 @@ describe("sql:", () => {
|
|
|
1179
1181
|
const select = compileSql.select[0];
|
|
1180
1182
|
const star = compileSql.select[1];
|
|
1181
1183
|
const where = compileSql.select[2];
|
|
1182
|
-
expect(select).toEqual({ sql: "SELECT * FROM " });
|
|
1184
|
+
expect(select).toEqual({ "sql": "SELECT * FROM " });
|
|
1183
1185
|
expect((0, model_1.isSQLFragment)(star)).toBeFalsy();
|
|
1184
|
-
expect(where).toEqual({ sql: " WHERE 1=1" });
|
|
1186
|
+
expect(where).toEqual({ "sql": " WHERE 1=1" });
|
|
1185
1187
|
}
|
|
1186
1188
|
});
|
|
1187
1189
|
it("model preserved", () => {
|
|
@@ -1196,8 +1198,8 @@ describe("sql:", () => {
|
|
|
1196
1198
|
const needReq = model.translate();
|
|
1197
1199
|
const needs = needReq === null || needReq === void 0 ? void 0 : needReq.compileSQL;
|
|
1198
1200
|
expect(needs).toBeDefined();
|
|
1199
|
-
const sql = (0, sql_block_1.makeSQLBlock)([{ sql: selStmt }]);
|
|
1200
|
-
model.update({ compileSQL: { [sql.name]: makeSchemaResponse(sql) } });
|
|
1201
|
+
const sql = (0, sql_block_1.makeSQLBlock)([{ "sql": selStmt }]);
|
|
1202
|
+
model.update({ "compileSQL": { [sql.name]: makeSchemaResponse(sql) } });
|
|
1201
1203
|
expect(model).modelCompiled();
|
|
1202
1204
|
});
|
|
1203
1205
|
});
|
|
@@ -1297,11 +1299,11 @@ describe("error handling", () => {
|
|
|
1297
1299
|
expect(needSchema.compileSQL).toBeDefined();
|
|
1298
1300
|
if (needSchema.compileSQL) {
|
|
1299
1301
|
badModel.update({
|
|
1300
|
-
errors: {
|
|
1301
|
-
compileSQL: {
|
|
1302
|
-
[needSchema.compileSQL.name]: "ZZZZ"
|
|
1303
|
-
}
|
|
1304
|
-
}
|
|
1302
|
+
"errors": {
|
|
1303
|
+
"compileSQL": {
|
|
1304
|
+
[needSchema.compileSQL.name]: "ZZZZ"
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1305
1307
|
});
|
|
1306
1308
|
}
|
|
1307
1309
|
expect(badModel).compileToFailWith("Invalid SQL, ZZZZ");
|
|
@@ -1313,20 +1315,20 @@ function getSelectOneStruct(sqlBlock) {
|
|
|
1313
1315
|
throw new Error("weird test support error sorry");
|
|
1314
1316
|
}
|
|
1315
1317
|
return {
|
|
1316
|
-
type: "struct",
|
|
1317
|
-
name: sqlBlock.name,
|
|
1318
|
-
dialect: "bigquery",
|
|
1319
|
-
structSource: {
|
|
1320
|
-
type: "sql",
|
|
1321
|
-
method: "subquery",
|
|
1322
|
-
sqlBlock: {
|
|
1323
|
-
type: "sqlBlock",
|
|
1324
|
-
name: sqlBlock.name,
|
|
1325
|
-
selectStr: selectThis.sql
|
|
1326
|
-
}
|
|
1318
|
+
"type": "struct",
|
|
1319
|
+
"name": sqlBlock.name,
|
|
1320
|
+
"dialect": "bigquery",
|
|
1321
|
+
"structSource": {
|
|
1322
|
+
"type": "sql",
|
|
1323
|
+
"method": "subquery",
|
|
1324
|
+
"sqlBlock": {
|
|
1325
|
+
"type": "sqlBlock",
|
|
1326
|
+
"name": sqlBlock.name,
|
|
1327
|
+
"selectStr": selectThis.sql
|
|
1328
|
+
}
|
|
1327
1329
|
},
|
|
1328
|
-
structRelationship: { type: "basetable", connectionName: "bigquery" },
|
|
1329
|
-
fields: [{ type: "number", name: "one" }]
|
|
1330
|
+
"structRelationship": { "type": "basetable", "connectionName": "bigquery" },
|
|
1331
|
+
"fields": [{ "type": "number", "name": "one" }]
|
|
1330
1332
|
};
|
|
1331
1333
|
}
|
|
1332
1334
|
describe("source locations", () => {
|
|
@@ -1414,7 +1416,7 @@ describe("source locations", () => {
|
|
|
1414
1416
|
expect(compileSql).toBeDefined();
|
|
1415
1417
|
if (compileSql) {
|
|
1416
1418
|
m.update({
|
|
1417
|
-
compileSQL: { [compileSql.name]: getSelectOneStruct(compileSql) }
|
|
1419
|
+
"compileSQL": { [compileSql.name]: getSelectOneStruct(compileSql) }
|
|
1418
1420
|
});
|
|
1419
1421
|
expect(m).modelCompiled();
|
|
1420
1422
|
const na = (0, test_translator_1.getExplore)(m.modelDef, "na");
|
|
@@ -1463,7 +1465,7 @@ describe("source locations", () => {
|
|
|
1463
1465
|
expect(compileSql).toBeDefined();
|
|
1464
1466
|
if (compileSql) {
|
|
1465
1467
|
m.update({
|
|
1466
|
-
compileSQL: { [compileSql.name]: getSelectOneStruct(compileSql) }
|
|
1468
|
+
"compileSQL": { [compileSql.name]: getSelectOneStruct(compileSql) }
|
|
1467
1469
|
});
|
|
1468
1470
|
expect(m).modelCompiled();
|
|
1469
1471
|
const s = m.sqlBlocks[0];
|
|
@@ -1545,12 +1547,12 @@ describe("source references", () => {
|
|
|
1545
1547
|
const m = new BetaModel(source.code);
|
|
1546
1548
|
expect(m).modelCompiled();
|
|
1547
1549
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1548
|
-
location: source.locations[1],
|
|
1549
|
-
type: "exploreReference",
|
|
1550
|
-
text: "na",
|
|
1551
|
-
definition: {
|
|
1552
|
-
location: source.locations[0]
|
|
1553
|
-
}
|
|
1550
|
+
"location": source.locations[1],
|
|
1551
|
+
"type": "exploreReference",
|
|
1552
|
+
"text": "na",
|
|
1553
|
+
"definition": {
|
|
1554
|
+
"location": source.locations[0]
|
|
1555
|
+
}
|
|
1554
1556
|
});
|
|
1555
1557
|
});
|
|
1556
1558
|
test("reference to query in query", () => {
|
|
@@ -1563,12 +1565,12 @@ describe("source references", () => {
|
|
|
1563
1565
|
const m = new BetaModel(source.code);
|
|
1564
1566
|
expect(m).modelCompiled();
|
|
1565
1567
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1566
|
-
location: source.locations[1],
|
|
1567
|
-
type: "fieldReference",
|
|
1568
|
-
text: "q",
|
|
1569
|
-
definition: {
|
|
1570
|
-
location: source.locations[0]
|
|
1571
|
-
}
|
|
1568
|
+
"location": source.locations[1],
|
|
1569
|
+
"type": "fieldReference",
|
|
1570
|
+
"text": "q",
|
|
1571
|
+
"definition": {
|
|
1572
|
+
"location": source.locations[0]
|
|
1573
|
+
}
|
|
1572
1574
|
});
|
|
1573
1575
|
});
|
|
1574
1576
|
test("reference to query in query (version 2)", () => {
|
|
@@ -1579,12 +1581,12 @@ describe("source references", () => {
|
|
|
1579
1581
|
const m = new BetaModel(source.code);
|
|
1580
1582
|
expect(m).modelCompiled();
|
|
1581
1583
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1582
|
-
location: source.locations[1],
|
|
1583
|
-
type: "fieldReference",
|
|
1584
|
-
text: "x",
|
|
1585
|
-
definition: {
|
|
1586
|
-
location: source.locations[0]
|
|
1587
|
-
}
|
|
1584
|
+
"location": source.locations[1],
|
|
1585
|
+
"type": "fieldReference",
|
|
1586
|
+
"text": "x",
|
|
1587
|
+
"definition": {
|
|
1588
|
+
"location": source.locations[0]
|
|
1589
|
+
}
|
|
1588
1590
|
});
|
|
1589
1591
|
});
|
|
1590
1592
|
test("reference to sql block", () => {
|
|
@@ -1598,18 +1600,18 @@ describe("source references", () => {
|
|
|
1598
1600
|
expect(compileSql).toBeDefined();
|
|
1599
1601
|
if (compileSql) {
|
|
1600
1602
|
m.update({
|
|
1601
|
-
compileSQL: { [compileSql.name]: getSelectOneStruct(compileSql) }
|
|
1603
|
+
"compileSQL": { [compileSql.name]: getSelectOneStruct(compileSql) }
|
|
1602
1604
|
});
|
|
1603
1605
|
expect(m).modelCompiled();
|
|
1604
1606
|
const ref = m.referenceAt(pos(source.locations[1]));
|
|
1605
1607
|
expect(ref).toMatchObject({
|
|
1606
|
-
location: source.locations[1],
|
|
1607
|
-
type: "sqlBlockReference",
|
|
1608
|
-
text: "s",
|
|
1609
|
-
definition: {
|
|
1608
|
+
"location": source.locations[1],
|
|
1609
|
+
"type": "sqlBlockReference",
|
|
1610
|
+
"text": "s",
|
|
1611
|
+
"definition": {
|
|
1610
1612
|
...getSelectOneStruct(compileSql),
|
|
1611
|
-
location: source.locations[0]
|
|
1612
|
-
}
|
|
1613
|
+
"location": source.locations[0]
|
|
1614
|
+
}
|
|
1613
1615
|
});
|
|
1614
1616
|
}
|
|
1615
1617
|
});
|
|
@@ -1621,12 +1623,12 @@ describe("source references", () => {
|
|
|
1621
1623
|
const m = new BetaModel(source.code);
|
|
1622
1624
|
expect(m).modelCompiled();
|
|
1623
1625
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1624
|
-
location: source.locations[1],
|
|
1625
|
-
type: "queryReference",
|
|
1626
|
-
text: "q",
|
|
1627
|
-
definition: {
|
|
1628
|
-
location: source.locations[0]
|
|
1629
|
-
}
|
|
1626
|
+
"location": source.locations[1],
|
|
1627
|
+
"type": "queryReference",
|
|
1628
|
+
"text": "q",
|
|
1629
|
+
"definition": {
|
|
1630
|
+
"location": source.locations[0]
|
|
1631
|
+
}
|
|
1630
1632
|
});
|
|
1631
1633
|
});
|
|
1632
1634
|
test("reference to query in query head", () => {
|
|
@@ -1637,12 +1639,12 @@ describe("source references", () => {
|
|
|
1637
1639
|
const m = new BetaModel(source.code);
|
|
1638
1640
|
expect(m).modelCompiled();
|
|
1639
1641
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1640
|
-
location: source.locations[1],
|
|
1641
|
-
type: "queryReference",
|
|
1642
|
-
text: "q",
|
|
1643
|
-
definition: {
|
|
1644
|
-
location: source.locations[0]
|
|
1645
|
-
}
|
|
1642
|
+
"location": source.locations[1],
|
|
1643
|
+
"type": "queryReference",
|
|
1644
|
+
"text": "q",
|
|
1645
|
+
"definition": {
|
|
1646
|
+
"location": source.locations[0]
|
|
1647
|
+
}
|
|
1646
1648
|
});
|
|
1647
1649
|
});
|
|
1648
1650
|
test("reference to query in refined query", () => {
|
|
@@ -1653,12 +1655,12 @@ describe("source references", () => {
|
|
|
1653
1655
|
const m = new BetaModel(source.code);
|
|
1654
1656
|
expect(m).modelCompiled();
|
|
1655
1657
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1656
|
-
location: source.locations[1],
|
|
1657
|
-
type: "queryReference",
|
|
1658
|
-
text: "q",
|
|
1659
|
-
definition: {
|
|
1660
|
-
location: source.locations[0]
|
|
1661
|
-
}
|
|
1658
|
+
"location": source.locations[1],
|
|
1659
|
+
"type": "queryReference",
|
|
1660
|
+
"text": "q",
|
|
1661
|
+
"definition": {
|
|
1662
|
+
"location": source.locations[0]
|
|
1663
|
+
}
|
|
1662
1664
|
});
|
|
1663
1665
|
});
|
|
1664
1666
|
test("reference to field in expression", () => {
|
|
@@ -1669,12 +1671,12 @@ describe("source references", () => {
|
|
|
1669
1671
|
const m = new BetaModel(source.code);
|
|
1670
1672
|
expect(m).modelCompiled();
|
|
1671
1673
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1672
|
-
location: source.locations[1],
|
|
1673
|
-
type: "fieldReference",
|
|
1674
|
-
text: "abool",
|
|
1675
|
-
definition: {
|
|
1676
|
-
location: source.locations[0]
|
|
1677
|
-
}
|
|
1674
|
+
"location": source.locations[1],
|
|
1675
|
+
"type": "fieldReference",
|
|
1676
|
+
"text": "abool",
|
|
1677
|
+
"definition": {
|
|
1678
|
+
"location": source.locations[0]
|
|
1679
|
+
}
|
|
1678
1680
|
});
|
|
1679
1681
|
});
|
|
1680
1682
|
test("reference to quoted field in expression", () => {
|
|
@@ -1687,12 +1689,12 @@ describe("source references", () => {
|
|
|
1687
1689
|
const m = new BetaModel(source.code);
|
|
1688
1690
|
expect(m).modelCompiled();
|
|
1689
1691
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1690
|
-
location: source.locations[1],
|
|
1691
|
-
type: "fieldReference",
|
|
1692
|
-
text: "name",
|
|
1693
|
-
definition: {
|
|
1694
|
-
location: source.locations[0]
|
|
1695
|
-
}
|
|
1692
|
+
"location": source.locations[1],
|
|
1693
|
+
"type": "fieldReference",
|
|
1694
|
+
"text": "name",
|
|
1695
|
+
"definition": {
|
|
1696
|
+
"location": source.locations[0]
|
|
1697
|
+
}
|
|
1696
1698
|
});
|
|
1697
1699
|
});
|
|
1698
1700
|
test("reference to joined field in expression", () => {
|
|
@@ -1706,12 +1708,12 @@ describe("source references", () => {
|
|
|
1706
1708
|
const m = new BetaModel(source.code);
|
|
1707
1709
|
expect(m).modelCompiled();
|
|
1708
1710
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1709
|
-
location: source.locations[1],
|
|
1710
|
-
type: "fieldReference",
|
|
1711
|
-
text: "astr",
|
|
1712
|
-
definition: {
|
|
1713
|
-
location: source.locations[0]
|
|
1714
|
-
}
|
|
1711
|
+
"location": source.locations[1],
|
|
1712
|
+
"type": "fieldReference",
|
|
1713
|
+
"text": "astr",
|
|
1714
|
+
"definition": {
|
|
1715
|
+
"location": source.locations[0]
|
|
1716
|
+
}
|
|
1715
1717
|
});
|
|
1716
1718
|
});
|
|
1717
1719
|
test("reference to joined join in expression", () => {
|
|
@@ -1724,12 +1726,12 @@ describe("source references", () => {
|
|
|
1724
1726
|
const m = new BetaModel(source.code);
|
|
1725
1727
|
expect(m).modelCompiled();
|
|
1726
1728
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1727
|
-
location: source.locations[1],
|
|
1728
|
-
type: "joinReference",
|
|
1729
|
-
text: "self",
|
|
1730
|
-
definition: {
|
|
1731
|
-
location: source.locations[0]
|
|
1732
|
-
}
|
|
1729
|
+
"location": source.locations[1],
|
|
1730
|
+
"type": "joinReference",
|
|
1731
|
+
"text": "self",
|
|
1732
|
+
"definition": {
|
|
1733
|
+
"location": source.locations[0]
|
|
1734
|
+
}
|
|
1733
1735
|
});
|
|
1734
1736
|
});
|
|
1735
1737
|
test("reference to field not in expression (group by)", () => {
|
|
@@ -1739,12 +1741,12 @@ describe("source references", () => {
|
|
|
1739
1741
|
const m = new BetaModel(source.code);
|
|
1740
1742
|
expect(m).modelCompiled();
|
|
1741
1743
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1742
|
-
location: source.locations[1],
|
|
1743
|
-
type: "fieldReference",
|
|
1744
|
-
text: "abool",
|
|
1745
|
-
definition: {
|
|
1746
|
-
location: source.locations[0]
|
|
1747
|
-
}
|
|
1744
|
+
"location": source.locations[1],
|
|
1745
|
+
"type": "fieldReference",
|
|
1746
|
+
"text": "abool",
|
|
1747
|
+
"definition": {
|
|
1748
|
+
"location": source.locations[0]
|
|
1749
|
+
}
|
|
1748
1750
|
});
|
|
1749
1751
|
});
|
|
1750
1752
|
test("reference to field not in expression (project)", () => {
|
|
@@ -1755,12 +1757,12 @@ describe("source references", () => {
|
|
|
1755
1757
|
const m = new BetaModel(source.code);
|
|
1756
1758
|
expect(m).modelCompiled();
|
|
1757
1759
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1758
|
-
location: source.locations[1],
|
|
1759
|
-
type: "fieldReference",
|
|
1760
|
-
text: "abool",
|
|
1761
|
-
definition: {
|
|
1762
|
-
location: source.locations[0]
|
|
1763
|
-
}
|
|
1760
|
+
"location": source.locations[1],
|
|
1761
|
+
"type": "fieldReference",
|
|
1762
|
+
"text": "abool",
|
|
1763
|
+
"definition": {
|
|
1764
|
+
"location": source.locations[0]
|
|
1765
|
+
}
|
|
1764
1766
|
});
|
|
1765
1767
|
});
|
|
1766
1768
|
test.skip("reference to field in order by", () => {
|
|
@@ -1773,12 +1775,12 @@ describe("source references", () => {
|
|
|
1773
1775
|
const m = new BetaModel(source.code);
|
|
1774
1776
|
expect(m).modelCompiled();
|
|
1775
1777
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1776
|
-
location: source.locations[1],
|
|
1777
|
-
type: "fieldReference",
|
|
1778
|
-
text: "abool",
|
|
1779
|
-
definition: {
|
|
1780
|
-
location: source.locations[0]
|
|
1781
|
-
}
|
|
1778
|
+
"location": source.locations[1],
|
|
1779
|
+
"type": "fieldReference",
|
|
1780
|
+
"text": "abool",
|
|
1781
|
+
"definition": {
|
|
1782
|
+
"location": source.locations[0]
|
|
1783
|
+
}
|
|
1782
1784
|
});
|
|
1783
1785
|
});
|
|
1784
1786
|
test.skip("reference to field in order by (output space)", () => {
|
|
@@ -1791,12 +1793,12 @@ describe("source references", () => {
|
|
|
1791
1793
|
const m = new BetaModel(source.code);
|
|
1792
1794
|
expect(m).modelCompiled();
|
|
1793
1795
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1794
|
-
location: source.locations[1],
|
|
1795
|
-
type: "fieldReference",
|
|
1796
|
-
text: "abool",
|
|
1797
|
-
definition: {
|
|
1798
|
-
location: source.locations[0]
|
|
1799
|
-
}
|
|
1796
|
+
"location": source.locations[1],
|
|
1797
|
+
"type": "fieldReference",
|
|
1798
|
+
"text": "abool",
|
|
1799
|
+
"definition": {
|
|
1800
|
+
"location": source.locations[0]
|
|
1801
|
+
}
|
|
1800
1802
|
});
|
|
1801
1803
|
});
|
|
1802
1804
|
test("reference to field in aggregate", () => {
|
|
@@ -1809,12 +1811,12 @@ describe("source references", () => {
|
|
|
1809
1811
|
const m = new BetaModel(source.code);
|
|
1810
1812
|
expect(m).modelCompiled();
|
|
1811
1813
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1812
|
-
location: source.locations[1],
|
|
1813
|
-
type: "fieldReference",
|
|
1814
|
-
text: "c",
|
|
1815
|
-
definition: {
|
|
1816
|
-
location: source.locations[0]
|
|
1817
|
-
}
|
|
1814
|
+
"location": source.locations[1],
|
|
1815
|
+
"type": "fieldReference",
|
|
1816
|
+
"text": "c",
|
|
1817
|
+
"definition": {
|
|
1818
|
+
"location": source.locations[0]
|
|
1819
|
+
}
|
|
1818
1820
|
});
|
|
1819
1821
|
});
|
|
1820
1822
|
test("reference to field in measure", () => {
|
|
@@ -1827,12 +1829,12 @@ describe("source references", () => {
|
|
|
1827
1829
|
const m = new BetaModel(source.code);
|
|
1828
1830
|
expect(m).modelCompiled();
|
|
1829
1831
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1830
|
-
location: source.locations[1],
|
|
1831
|
-
type: "fieldReference",
|
|
1832
|
-
text: "c",
|
|
1833
|
-
definition: {
|
|
1834
|
-
location: source.locations[0]
|
|
1835
|
-
}
|
|
1832
|
+
"location": source.locations[1],
|
|
1833
|
+
"type": "fieldReference",
|
|
1834
|
+
"text": "c",
|
|
1835
|
+
"definition": {
|
|
1836
|
+
"location": source.locations[0]
|
|
1837
|
+
}
|
|
1836
1838
|
});
|
|
1837
1839
|
});
|
|
1838
1840
|
test.skip("reference to field in top", () => {
|
|
@@ -1845,12 +1847,12 @@ describe("source references", () => {
|
|
|
1845
1847
|
const m = new BetaModel(source.code);
|
|
1846
1848
|
expect(m).modelCompiled();
|
|
1847
1849
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1848
|
-
location: source.locations[1],
|
|
1849
|
-
type: "fieldReference",
|
|
1850
|
-
text: "abool",
|
|
1851
|
-
definition: {
|
|
1852
|
-
location: source.locations[0]
|
|
1853
|
-
}
|
|
1850
|
+
"location": source.locations[1],
|
|
1851
|
+
"type": "fieldReference",
|
|
1852
|
+
"text": "abool",
|
|
1853
|
+
"definition": {
|
|
1854
|
+
"location": source.locations[0]
|
|
1855
|
+
}
|
|
1854
1856
|
});
|
|
1855
1857
|
});
|
|
1856
1858
|
test.skip("reference to field in top (output space)", () => {
|
|
@@ -1863,12 +1865,12 @@ describe("source references", () => {
|
|
|
1863
1865
|
const m = new BetaModel(source.code);
|
|
1864
1866
|
expect(m).modelCompiled();
|
|
1865
1867
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1866
|
-
location: source.locations[1],
|
|
1867
|
-
type: "fieldReference",
|
|
1868
|
-
text: "abool",
|
|
1869
|
-
definition: {
|
|
1870
|
-
location: source.locations[0]
|
|
1871
|
-
}
|
|
1868
|
+
"location": source.locations[1],
|
|
1869
|
+
"type": "fieldReference",
|
|
1870
|
+
"text": "abool",
|
|
1871
|
+
"definition": {
|
|
1872
|
+
"location": source.locations[0]
|
|
1873
|
+
}
|
|
1872
1874
|
});
|
|
1873
1875
|
});
|
|
1874
1876
|
test("reference to field in filter", () => {
|
|
@@ -1881,12 +1883,12 @@ describe("source references", () => {
|
|
|
1881
1883
|
const m = new BetaModel(source.code);
|
|
1882
1884
|
expect(m).modelCompiled();
|
|
1883
1885
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1884
|
-
location: source.locations[1],
|
|
1885
|
-
type: "fieldReference",
|
|
1886
|
-
text: "abool",
|
|
1887
|
-
definition: {
|
|
1888
|
-
location: source.locations[0]
|
|
1889
|
-
}
|
|
1886
|
+
"location": source.locations[1],
|
|
1887
|
+
"type": "fieldReference",
|
|
1888
|
+
"text": "abool",
|
|
1889
|
+
"definition": {
|
|
1890
|
+
"location": source.locations[0]
|
|
1891
|
+
}
|
|
1890
1892
|
});
|
|
1891
1893
|
});
|
|
1892
1894
|
test("reference to field in aggregate source", () => {
|
|
@@ -1897,12 +1899,12 @@ describe("source references", () => {
|
|
|
1897
1899
|
const m = new BetaModel(source.code);
|
|
1898
1900
|
expect(m).modelCompiled();
|
|
1899
1901
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1900
|
-
location: source.locations[1],
|
|
1901
|
-
type: "fieldReference",
|
|
1902
|
-
text: "ai",
|
|
1903
|
-
definition: {
|
|
1904
|
-
location: source.locations[0]
|
|
1905
|
-
}
|
|
1902
|
+
"location": source.locations[1],
|
|
1903
|
+
"type": "fieldReference",
|
|
1904
|
+
"text": "ai",
|
|
1905
|
+
"definition": {
|
|
1906
|
+
"location": source.locations[0]
|
|
1907
|
+
}
|
|
1906
1908
|
});
|
|
1907
1909
|
});
|
|
1908
1910
|
function pos(location) {
|
|
@@ -1918,12 +1920,12 @@ describe("source references", () => {
|
|
|
1918
1920
|
const m = new BetaModel(source.code);
|
|
1919
1921
|
expect(m).modelCompiled();
|
|
1920
1922
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1921
|
-
location: source.locations[1],
|
|
1922
|
-
type: "joinReference",
|
|
1923
|
-
text: "self",
|
|
1924
|
-
definition: {
|
|
1925
|
-
location: source.locations[0]
|
|
1926
|
-
}
|
|
1923
|
+
"location": source.locations[1],
|
|
1924
|
+
"type": "joinReference",
|
|
1925
|
+
"text": "self",
|
|
1926
|
+
"definition": {
|
|
1927
|
+
"location": source.locations[0]
|
|
1928
|
+
}
|
|
1927
1929
|
});
|
|
1928
1930
|
});
|
|
1929
1931
|
test("reference to join in aggregate in expr", () => {
|
|
@@ -1936,12 +1938,12 @@ describe("source references", () => {
|
|
|
1936
1938
|
const m = new BetaModel(source.code);
|
|
1937
1939
|
expect(m).modelCompiled();
|
|
1938
1940
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1939
|
-
location: source.locations[1],
|
|
1940
|
-
type: "joinReference",
|
|
1941
|
-
text: "self",
|
|
1942
|
-
definition: {
|
|
1943
|
-
location: source.locations[0]
|
|
1944
|
-
}
|
|
1941
|
+
"location": source.locations[1],
|
|
1942
|
+
"type": "joinReference",
|
|
1943
|
+
"text": "self",
|
|
1944
|
+
"definition": {
|
|
1945
|
+
"location": source.locations[0]
|
|
1946
|
+
}
|
|
1945
1947
|
});
|
|
1946
1948
|
});
|
|
1947
1949
|
test("reference to explore in join", () => {
|
|
@@ -1954,12 +1956,12 @@ describe("source references", () => {
|
|
|
1954
1956
|
const m = new BetaModel(source.code);
|
|
1955
1957
|
expect(m).modelCompiled();
|
|
1956
1958
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1957
|
-
location: source.locations[1],
|
|
1958
|
-
type: "exploreReference",
|
|
1959
|
-
text: "exp1",
|
|
1960
|
-
definition: {
|
|
1961
|
-
location: source.locations[0]
|
|
1962
|
-
}
|
|
1959
|
+
"location": source.locations[1],
|
|
1960
|
+
"type": "exploreReference",
|
|
1961
|
+
"text": "exp1",
|
|
1962
|
+
"definition": {
|
|
1963
|
+
"location": source.locations[0]
|
|
1964
|
+
}
|
|
1963
1965
|
});
|
|
1964
1966
|
});
|
|
1965
1967
|
test("reference to field in aggregate (in expr)", () => {
|
|
@@ -1970,12 +1972,12 @@ describe("source references", () => {
|
|
|
1970
1972
|
const m = new BetaModel(source.code);
|
|
1971
1973
|
expect(m).modelCompiled();
|
|
1972
1974
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1973
|
-
location: source.locations[1],
|
|
1974
|
-
type: "fieldReference",
|
|
1975
|
-
text: "ai",
|
|
1976
|
-
definition: {
|
|
1977
|
-
location: source.locations[0]
|
|
1978
|
-
}
|
|
1975
|
+
"location": source.locations[1],
|
|
1976
|
+
"type": "fieldReference",
|
|
1977
|
+
"text": "ai",
|
|
1978
|
+
"definition": {
|
|
1979
|
+
"location": source.locations[0]
|
|
1980
|
+
}
|
|
1979
1981
|
});
|
|
1980
1982
|
});
|
|
1981
1983
|
test("reference to field in rename", () => {
|
|
@@ -1987,12 +1989,12 @@ describe("source references", () => {
|
|
|
1987
1989
|
const m = new BetaModel(source.code);
|
|
1988
1990
|
expect(m).modelCompiled();
|
|
1989
1991
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
1990
|
-
location: source.locations[1],
|
|
1991
|
-
type: "fieldReference",
|
|
1992
|
-
text: "abool",
|
|
1993
|
-
definition: {
|
|
1994
|
-
location: source.locations[0]
|
|
1995
|
-
}
|
|
1992
|
+
"location": source.locations[1],
|
|
1993
|
+
"type": "fieldReference",
|
|
1994
|
+
"text": "abool",
|
|
1995
|
+
"definition": {
|
|
1996
|
+
"location": source.locations[0]
|
|
1997
|
+
}
|
|
1996
1998
|
});
|
|
1997
1999
|
});
|
|
1998
2000
|
test("reference to field in join with", () => {
|
|
@@ -2005,12 +2007,12 @@ describe("source references", () => {
|
|
|
2005
2007
|
const m = new BetaModel(source.code);
|
|
2006
2008
|
expect(m).modelCompiled();
|
|
2007
2009
|
expect(m.referenceAt(pos(source.locations[1]))).toMatchObject({
|
|
2008
|
-
location: source.locations[1],
|
|
2009
|
-
type: "fieldReference",
|
|
2010
|
-
text: "astr",
|
|
2011
|
-
definition: {
|
|
2012
|
-
location: source.locations[0]
|
|
2013
|
-
}
|
|
2010
|
+
"location": source.locations[1],
|
|
2011
|
+
"type": "fieldReference",
|
|
2012
|
+
"text": "astr",
|
|
2013
|
+
"definition": {
|
|
2014
|
+
"location": source.locations[0]
|
|
2015
|
+
}
|
|
2014
2016
|
});
|
|
2015
2017
|
});
|
|
2016
2018
|
});
|
|
@@ -2020,7 +2022,7 @@ describe("translation need error locations", () => {
|
|
|
2020
2022
|
const m = new BetaModel(source.code);
|
|
2021
2023
|
const result = m.translate();
|
|
2022
2024
|
m.update({
|
|
2023
|
-
errors: { urls: { [(result.urls || [])[0]]: "Bad file!" } }
|
|
2025
|
+
"errors": { "urls": { [(result.urls || [])[0]]: "Bad file!" } }
|
|
2024
2026
|
});
|
|
2025
2027
|
expect(m).not.modelParsed();
|
|
2026
2028
|
const errList = m.errors().errors;
|
|
@@ -2037,7 +2039,7 @@ describe("translation need error locations", () => {
|
|
|
2037
2039
|
const req = m.translate().compileSQL;
|
|
2038
2040
|
expect(req).toBeDefined();
|
|
2039
2041
|
if (req) {
|
|
2040
|
-
m.update({ errors: { compileSQL: { [req.name]: "Bad SQL!" } } });
|
|
2042
|
+
m.update({ "errors": { "compileSQL": { [req.name]: "Bad SQL!" } } });
|
|
2041
2043
|
}
|
|
2042
2044
|
expect(m).not.modelCompiled();
|
|
2043
2045
|
const errList = m.errors().errors;
|
|
@@ -2050,9 +2052,9 @@ describe("translation need error locations", () => {
|
|
|
2050
2052
|
const m = new BetaModel(source.code);
|
|
2051
2053
|
const result = m.translate();
|
|
2052
2054
|
m.update({
|
|
2053
|
-
errors: {
|
|
2054
|
-
tables: { [(result.tables || [])[0]]: "Bad table!" }
|
|
2055
|
-
}
|
|
2055
|
+
"errors": {
|
|
2056
|
+
"tables": { [(result.tables || [])[0]]: "Bad table!" }
|
|
2057
|
+
}
|
|
2056
2058
|
});
|
|
2057
2059
|
expect(m).not.modelParsed();
|
|
2058
2060
|
const errList = m.errors().errors;
|