@malloydata/malloy 0.0.80-dev230903192621 → 0.0.80-dev230905212201
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/lang/ast/field-space/query-spaces.d.ts +1 -0
- package/dist/lang/ast/field-space/query-spaces.js +34 -72
- package/dist/lang/ast/query-items/field-references.d.ts +1 -2
- package/dist/lang/ast/query-items/field-references.js +2 -5
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +1 -3
- package/dist/lang/lib/Malloy/MalloyParser.js +757 -777
- package/dist/lang/malloy-to-ast.js +4 -6
- package/dist/lang/test/parse-expects.js +11 -4
- package/dist/lang/test/query.spec.js +61 -2
- package/package.json +1 -1
|
@@ -734,24 +734,22 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
734
734
|
}
|
|
735
735
|
visitCollectionWildCard(pcx) {
|
|
736
736
|
const nameCx = pcx.fieldPath();
|
|
737
|
-
const stars = pcx.STAR() ? '*' : '**';
|
|
738
737
|
const join = nameCx
|
|
739
738
|
? this.getFieldPath(nameCx, ast.ProjectFieldReference)
|
|
740
739
|
: undefined;
|
|
741
|
-
return new ast.WildcardFieldReference(join,
|
|
740
|
+
return this.astAt(new ast.WildcardFieldReference(join), pcx);
|
|
742
741
|
}
|
|
743
742
|
visitIndexFields(pcx) {
|
|
744
743
|
const refList = pcx.indexElement().map(el => {
|
|
745
|
-
const hasStar = el.STAR() !== undefined;
|
|
746
744
|
const pathCx = el.fieldPath();
|
|
747
745
|
if (!pathCx) {
|
|
748
|
-
return new ast.WildcardFieldReference(undefined,
|
|
746
|
+
return this.astAt(new ast.WildcardFieldReference(undefined), pcx);
|
|
749
747
|
}
|
|
750
748
|
const path = this.getFieldPath(pathCx, ast.IndexFieldReference);
|
|
751
|
-
if (!
|
|
749
|
+
if (!el.STAR()) {
|
|
752
750
|
return this.astAt(path, pcx);
|
|
753
751
|
}
|
|
754
|
-
return this.astAt(new ast.WildcardFieldReference(path
|
|
752
|
+
return this.astAt(new ast.WildcardFieldReference(path), pcx);
|
|
755
753
|
});
|
|
756
754
|
return new ast.FieldReferences(refList);
|
|
757
755
|
}
|
|
@@ -24,7 +24,14 @@
|
|
|
24
24
|
*/
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const test_translator_1 = require("./test-translator");
|
|
27
|
-
|
|
27
|
+
function rangeToStr(loc) {
|
|
28
|
+
if (loc) {
|
|
29
|
+
const from = `#${loc.start.line}:${loc.start.character}`;
|
|
30
|
+
const to = `#${loc.end.line}:${loc.end.character}`;
|
|
31
|
+
return `${from}-${to}`;
|
|
32
|
+
}
|
|
33
|
+
return 'undefined';
|
|
34
|
+
}
|
|
28
35
|
function ensureNoProblems(trans) {
|
|
29
36
|
if (trans.logger === undefined) {
|
|
30
37
|
throw new Error('JESTERY BROKEN, CANT FIND ERORR LOG');
|
|
@@ -223,8 +230,8 @@ function checkForProblems(context, expectCompiles, s, defaultSeverity, ...msgs)
|
|
|
223
230
|
const have = (_a = err.at) === null || _a === void 0 ? void 0 : _a.range;
|
|
224
231
|
const want = mSrc.locations[i].range;
|
|
225
232
|
if (!context.equals(have, want)) {
|
|
226
|
-
explain.push(`Expected '${msg.message}' at location: ${(
|
|
227
|
-
`Actual location: ${(
|
|
233
|
+
explain.push(`Expected '${msg.message}' at location: ${rangeToStr(want)}\n` +
|
|
234
|
+
`Actual location: ${rangeToStr(have)}`);
|
|
228
235
|
}
|
|
229
236
|
}
|
|
230
237
|
}
|
|
@@ -243,7 +250,7 @@ function checkForProblems(context, expectCompiles, s, defaultSeverity, ...msgs)
|
|
|
243
250
|
}
|
|
244
251
|
return {
|
|
245
252
|
pass: false,
|
|
246
|
-
message: () => `Compiler did not
|
|
253
|
+
message: () => `Compiler errors did not match expected errors\n${explain.join('\n')}`,
|
|
247
254
|
};
|
|
248
255
|
}
|
|
249
256
|
}
|
|
@@ -629,8 +629,67 @@ describe('query:', () => {
|
|
|
629
629
|
test('project ref', () => {
|
|
630
630
|
expect('query:ab->{ project: b.astr }').toTranslate();
|
|
631
631
|
});
|
|
632
|
-
|
|
633
|
-
|
|
632
|
+
const afields = test_translator_1.aTableDef.fields
|
|
633
|
+
.filter(f => (0, model_1.isAtomicFieldType)(f.type))
|
|
634
|
+
.map(f => f.name)
|
|
635
|
+
.sort();
|
|
636
|
+
test('expands star correctly', () => {
|
|
637
|
+
const selstar = (0, test_translator_1.model) `run: ab->{select: *}`;
|
|
638
|
+
expect(selstar).toTranslate();
|
|
639
|
+
const query = selstar.translator.getQuery(0);
|
|
640
|
+
expect(query).toBeDefined();
|
|
641
|
+
const fields = query.pipeline[0].fields;
|
|
642
|
+
expect(fields.sort()).toEqual(afields);
|
|
643
|
+
});
|
|
644
|
+
test('expands join dot star correctly', () => {
|
|
645
|
+
const selstar = (0, test_translator_1.model) `run: ab->{select: b.*}`;
|
|
646
|
+
expect(selstar).toTranslate();
|
|
647
|
+
const query = selstar.translator.getQuery(0);
|
|
648
|
+
expect(query).toBeDefined();
|
|
649
|
+
const fields = query.pipeline[0].fields;
|
|
650
|
+
expect(fields.sort()).toEqual(afields.map(f => `b.${f}`));
|
|
651
|
+
});
|
|
652
|
+
test('star error checking', () => {
|
|
653
|
+
expect((0, test_translator_1.markSource) `run: a->{select: ${'zzz'}.*}`).translationToFailWith("No such field as 'zzz'");
|
|
654
|
+
expect((0, test_translator_1.markSource) `run: ab->{select: b.${'zzz'}.*}`).translationToFailWith("No such field as 'zzz'");
|
|
655
|
+
expect((0, test_translator_1.markSource) `run: a->{select: ${'ai'}.*}`).translationToFailWith("Field 'ai' does not contain rows and cannot be expanded with '*'");
|
|
656
|
+
expect((0, test_translator_1.markSource) `run: a->{select:ai,${'*'}}`).translationToFailWith("Cannot expand 'ai' in '*' because a field with that name already exists");
|
|
657
|
+
expect((0, test_translator_1.markSource) `run: ab->{select:ai,${'b.*'}}`).translationToFailWith("Cannot expand 'ai' in 'b.*' because a field with that name already exists");
|
|
658
|
+
const m = `
|
|
659
|
+
source: nab is a extend {
|
|
660
|
+
accept: ai
|
|
661
|
+
join_one: b is a extend {accept: ai} on ai=b.ai
|
|
662
|
+
}
|
|
663
|
+
run: nab->{select: b.*,*}
|
|
664
|
+
`;
|
|
665
|
+
expect(m).translationToFailWith("Cannot expand 'ai' in '*' because a field with that name already exists (conflicts with b.ai)");
|
|
666
|
+
});
|
|
667
|
+
test('regress check extend: and star', () => {
|
|
668
|
+
const m = (0, test_translator_1.model) `run: ab->{ extend: {dimension: x is 1} select: * }`;
|
|
669
|
+
expect(m).toTranslate();
|
|
670
|
+
const q = m.translator.getQuery(0);
|
|
671
|
+
expect(q).toBeDefined();
|
|
672
|
+
const fields = q.pipeline[0].fields;
|
|
673
|
+
expect(fields.sort()).toEqual(afields.concat('x'));
|
|
674
|
+
});
|
|
675
|
+
test('project def', () => {
|
|
676
|
+
expect('query:ab->{ project: one is 1 }').toTranslate();
|
|
677
|
+
});
|
|
678
|
+
test('project multiple', () => {
|
|
679
|
+
expect(`
|
|
680
|
+
query: a->{
|
|
681
|
+
project: one is 1, astr
|
|
682
|
+
}
|
|
683
|
+
`).toTranslate();
|
|
684
|
+
});
|
|
685
|
+
test('index single', () => { });
|
|
686
|
+
test('regress check extend: and star', () => {
|
|
687
|
+
const m = (0, test_translator_1.model) `run: ab->{ extend: {dimension: x is 1} select: * }`;
|
|
688
|
+
expect(m).toTranslate();
|
|
689
|
+
const q = m.translator.getQuery(0);
|
|
690
|
+
expect(q).toBeDefined();
|
|
691
|
+
const fields = q.pipeline[0].fields;
|
|
692
|
+
expect(fields.sort()).toEqual(afields.concat('x'));
|
|
634
693
|
});
|
|
635
694
|
test('project def', () => {
|
|
636
695
|
expect('query:ab->{ project: one is 1 }').toTranslate();
|