@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
|
@@ -140,11 +140,11 @@ describe('expressions', () => {
|
|
|
140
140
|
});
|
|
141
141
|
});
|
|
142
142
|
test('filtered measure', () => {
|
|
143
|
-
expect((0, test_translator_1.expr) `acount {
|
|
143
|
+
expect((0, test_translator_1.expr) `acount {where: astr = 'why?' }`).toTranslate();
|
|
144
144
|
});
|
|
145
145
|
test('filtered ungrouped aggregate', () => {
|
|
146
146
|
expect(`
|
|
147
|
-
|
|
147
|
+
run: a -> {
|
|
148
148
|
group_by: ai
|
|
149
149
|
aggregate: x is all(avg(ai)) { where: true }
|
|
150
150
|
}
|
|
@@ -165,7 +165,7 @@ describe('expressions', () => {
|
|
|
165
165
|
});
|
|
166
166
|
test('correctly flags filtered analytic', () => {
|
|
167
167
|
expect((0, test_translator_1.markSource) `
|
|
168
|
-
|
|
168
|
+
run: a -> {
|
|
169
169
|
group_by: ai
|
|
170
170
|
calculate: l is lag(ai) { where: true }
|
|
171
171
|
}
|
|
@@ -478,14 +478,14 @@ describe('expressions', () => {
|
|
|
478
478
|
});
|
|
479
479
|
test('n-ary without else', () => {
|
|
480
480
|
expect(`
|
|
481
|
-
source: na is a
|
|
481
|
+
source: na is a extend { dimension: d is
|
|
482
482
|
pick 7 when true and true
|
|
483
483
|
}
|
|
484
484
|
`).translationToFailWith("pick incomplete, missing 'else'");
|
|
485
485
|
});
|
|
486
486
|
test('n-ary with mismatch when clauses', () => {
|
|
487
487
|
expect((0, test_translator_1.markSource) `
|
|
488
|
-
source: na is a
|
|
488
|
+
source: na is a extend { dimension: d is
|
|
489
489
|
pick 7 when true and true
|
|
490
490
|
pick '7' when true or true
|
|
491
491
|
else 7
|
|
@@ -494,7 +494,7 @@ describe('expressions', () => {
|
|
|
494
494
|
});
|
|
495
495
|
test('n-ary with mismatched else clause', () => {
|
|
496
496
|
expect((0, test_translator_1.markSource) `
|
|
497
|
-
source: na is a
|
|
497
|
+
source: na is a extend { dimension: d is
|
|
498
498
|
pick 7 when true and true
|
|
499
499
|
else '7'
|
|
500
500
|
}
|
|
@@ -502,21 +502,21 @@ describe('expressions', () => {
|
|
|
502
502
|
});
|
|
503
503
|
test('applied else mismatch', () => {
|
|
504
504
|
expect((0, test_translator_1.markSource) `
|
|
505
|
-
source: na is a
|
|
505
|
+
source: na is a extend { dimension: d is
|
|
506
506
|
7 ? pick 7 when 7 else 'not seven'
|
|
507
507
|
}
|
|
508
508
|
`).translationToFailWith("else type 'string', expected 'number'");
|
|
509
509
|
});
|
|
510
510
|
test('applied default mismatch', () => {
|
|
511
511
|
expect((0, test_translator_1.markSource) `
|
|
512
|
-
source: na is a
|
|
512
|
+
source: na is a extend { dimension: d is
|
|
513
513
|
7 ? pick 'seven' when 7
|
|
514
514
|
}
|
|
515
515
|
`).translationToFailWith("pick default type 'number', expected 'string'");
|
|
516
516
|
});
|
|
517
517
|
test('applied when mismatch', () => {
|
|
518
518
|
expect((0, test_translator_1.markSource) `
|
|
519
|
-
source: na is a
|
|
519
|
+
source: na is a extend { dimension: d is
|
|
520
520
|
7 ? pick 'seven' when 7 pick 6 when 6
|
|
521
521
|
}
|
|
522
522
|
`).translationToFailWith("pick type 'number', expected 'string'");
|
|
@@ -586,33 +586,33 @@ describe('expressions', () => {
|
|
|
586
586
|
});
|
|
587
587
|
describe('unspported fields in schema', () => {
|
|
588
588
|
test('unsupported reference in result allowed', () => {
|
|
589
|
-
const uModel = new test_translator_1.TestTranslator('
|
|
589
|
+
const uModel = new test_translator_1.TestTranslator('run: a->{ group_by: aun }');
|
|
590
590
|
expect(uModel).toTranslate();
|
|
591
591
|
});
|
|
592
592
|
test('unsupported reference can be compared to NULL', () => {
|
|
593
|
-
const uModel = new test_translator_1.TestTranslator('
|
|
593
|
+
const uModel = new test_translator_1.TestTranslator('run: a->{ where: aun != NULL; select: * }');
|
|
594
594
|
expect(uModel).toTranslate();
|
|
595
595
|
});
|
|
596
596
|
test('flag unsupported equality', () => {
|
|
597
597
|
// because we don't know if the two unsupported types are comparable
|
|
598
|
-
const uModel = new test_translator_1.TestTranslator('
|
|
598
|
+
const uModel = new test_translator_1.TestTranslator('run: ab->{ where: aun = b.aun select: * }');
|
|
599
599
|
expect(uModel).translationToFailWith('Unsupported type not allowed in expression');
|
|
600
600
|
});
|
|
601
601
|
test('flag unsupported compare', () => {
|
|
602
602
|
// because we don't know if the two unsupported types are comparable
|
|
603
|
-
const uModel = new test_translator_1.TestTranslator('
|
|
603
|
+
const uModel = new test_translator_1.TestTranslator('run: ab->{ where: aun > b.aun select: * }');
|
|
604
604
|
expect(uModel).translationToFailWith('Unsupported type not allowed in expression');
|
|
605
605
|
});
|
|
606
606
|
test('allow unsupported equality when raw types match', () => {
|
|
607
|
-
const uModel = new test_translator_1.TestTranslator('
|
|
607
|
+
const uModel = new test_translator_1.TestTranslator('run: ab->{ where: aweird = b.aweird select: * }');
|
|
608
608
|
expect(uModel).toTranslate();
|
|
609
609
|
});
|
|
610
610
|
test('flag not applied to unsupported', () => {
|
|
611
|
-
const uModel = new test_translator_1.TestTranslator('source: x is a { dimension: notUn is not aun }');
|
|
611
|
+
const uModel = new test_translator_1.TestTranslator('source: x is a extend { dimension: notUn is not aun }');
|
|
612
612
|
expect(uModel).translationToFailWith("'not' Can't use type unsupported");
|
|
613
613
|
});
|
|
614
614
|
test('allow unsupported to be cast', () => {
|
|
615
|
-
const uModel = new test_translator_1.TestTranslator('source: x is a { dimension: notUn is aun::string }');
|
|
615
|
+
const uModel = new test_translator_1.TestTranslator('source: x is a extend { dimension: notUn is aun::string }');
|
|
616
616
|
expect(uModel).toTranslate();
|
|
617
617
|
});
|
|
618
618
|
describe('cast', () => {
|
|
@@ -60,7 +60,7 @@ describe('import:', () => {
|
|
|
60
60
|
expect(xr).toEqual({ urls: ['internal://test/langtests/child'] });
|
|
61
61
|
docParse.update({
|
|
62
62
|
urls: {
|
|
63
|
-
'internal://test/langtests/child': 'query: aq is a->{
|
|
63
|
+
'internal://test/langtests/child': 'query: aq is a->{ select: * }',
|
|
64
64
|
},
|
|
65
65
|
});
|
|
66
66
|
expect(docParse).toTranslate();
|
|
@@ -70,7 +70,7 @@ describe('import:', () => {
|
|
|
70
70
|
test('query based source with named structref', () => {
|
|
71
71
|
const docParse = new test_translator_1.TestTranslator(`
|
|
72
72
|
import "child"
|
|
73
|
-
source: newSrc is a {
|
|
73
|
+
source: newSrc is a extend {
|
|
74
74
|
join_one: b is botProjQSrc on b.astr = astr
|
|
75
75
|
}
|
|
76
76
|
`);
|
|
@@ -81,8 +81,8 @@ source: newSrc is a {
|
|
|
81
81
|
urls: {
|
|
82
82
|
'internal://test/langtests/child': `
|
|
83
83
|
source: bottomSrc is a
|
|
84
|
-
query: botProjQ is bottomSrc -> {
|
|
85
|
-
source: botProjQSrc is
|
|
84
|
+
query: botProjQ is bottomSrc -> { select: * }
|
|
85
|
+
source: botProjQSrc is botProjQ
|
|
86
86
|
`,
|
|
87
87
|
},
|
|
88
88
|
});
|
|
@@ -128,7 +128,7 @@ source: botProjQSrc is from(->botProjQ)
|
|
|
128
128
|
expect(xr).toEqual({ urls: ['internal://test/parent.malloy'] });
|
|
129
129
|
docParse.update({
|
|
130
130
|
urls: {
|
|
131
|
-
'internal://test/parent.malloy': "source: aa is table('aTable')",
|
|
131
|
+
'internal://test/parent.malloy': "source: aa is _db_.table('aTable')",
|
|
132
132
|
},
|
|
133
133
|
});
|
|
134
134
|
expect(docParse).toTranslate();
|
|
@@ -141,7 +141,7 @@ source: botProjQSrc is from(->botProjQ)
|
|
|
141
141
|
docParse.update({
|
|
142
142
|
urls: {
|
|
143
143
|
'internal://test/parent.malloy': `
|
|
144
|
-
source: aa is table('aTable') {
|
|
144
|
+
source: aa is _db_.table('aTable') extend {
|
|
145
145
|
dimension: astr is 'not legal beause astr exists'
|
|
146
146
|
}`,
|
|
147
147
|
},
|
|
@@ -152,9 +152,11 @@ source: botProjQSrc is from(->botProjQ)
|
|
|
152
152
|
const srcFiles = {
|
|
153
153
|
'internal://test/langtests/middle': `
|
|
154
154
|
import "bottom"
|
|
155
|
-
source:
|
|
155
|
+
// in m4 source: NAME is SRC -> { QUERY } wasn't parsing
|
|
156
|
+
query: q is bottomSrc -> { group_by: astr }
|
|
157
|
+
source: midSrc is q
|
|
156
158
|
`,
|
|
157
|
-
'internal://test/langtests/bottom': "source: bottomSrc is table('aTable')",
|
|
159
|
+
'internal://test/langtests/bottom': "source: bottomSrc is _db_.table('aTable')",
|
|
158
160
|
};
|
|
159
161
|
const fullModel = new test_translator_1.TestTranslator(`
|
|
160
162
|
import "middle"
|
|
@@ -207,19 +207,19 @@ describe('literals', () => {
|
|
|
207
207
|
expect(v).toMatchObject({ literal: 'right\n mid\nleft' });
|
|
208
208
|
});
|
|
209
209
|
test('timezone single quote', () => {
|
|
210
|
-
const m = new test_translator_1.TestTranslator(`run: a-> {timezone: '${tz}';
|
|
210
|
+
const m = new test_translator_1.TestTranslator(`run: a-> {timezone: '${tz}'; select: *}`);
|
|
211
211
|
expect(m).toParse();
|
|
212
212
|
});
|
|
213
213
|
test('timezone double quote', () => {
|
|
214
|
-
const m = new test_translator_1.TestTranslator(`run: a-> {timezone: "${tz}";
|
|
214
|
+
const m = new test_translator_1.TestTranslator(`run: a-> {timezone: "${tz}"; select: *}`);
|
|
215
215
|
expect(m).toParse();
|
|
216
216
|
});
|
|
217
217
|
test('timezone triple quote', () => {
|
|
218
|
-
const m = new test_translator_1.TestTranslator(`run: a->{timezone: """${tz}""";
|
|
218
|
+
const m = new test_translator_1.TestTranslator(`run: a->{timezone: """${tz}"""; select: *}`);
|
|
219
219
|
expect(m).toParse();
|
|
220
220
|
});
|
|
221
221
|
test('timezone with illegal query', () => {
|
|
222
|
-
expect(`run: a->{timezone: """${tz}%{ab->aturtle}""";
|
|
222
|
+
expect(`run: a->{timezone: """${tz}%{ab->aturtle}"""; select: *}`).translationToFailWith('%{ query } illegal in this string');
|
|
223
223
|
});
|
|
224
224
|
test('table single quote', () => {
|
|
225
225
|
const m = new test_translator_1.TestTranslator("source: n is bigquery.table('n')");
|