@malloydata/malloy 0.0.163-dev240808193357 → 0.0.164-dev240808200109
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/lib/Malloy/MalloyParser.d.ts +88 -78
- package/dist/lang/lib/Malloy/MalloyParser.js +1673 -1606
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +11 -0
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +7 -0
- package/dist/lang/malloy-to-ast.d.ts +2 -1
- package/dist/lang/malloy-to-ast.js +13 -8
- package/dist/lang/parse-tree-walkers/document-symbol-walker.js +1 -1
- package/dist/lang/test/parameters.spec.js +21 -1
- package/package.json +1 -1
|
@@ -135,6 +135,7 @@ import { QueryExtendStatementListContext } from "./MalloyParser";
|
|
|
135
135
|
import { JoinListContext } from "./MalloyParser";
|
|
136
136
|
import { IsExploreContext } from "./MalloyParser";
|
|
137
137
|
import { MatrixOperationContext } from "./MalloyParser";
|
|
138
|
+
import { JoinFromContext } from "./MalloyParser";
|
|
138
139
|
import { JoinDefContext } from "./MalloyParser";
|
|
139
140
|
import { JoinExpressionContext } from "./MalloyParser";
|
|
140
141
|
import { FilterStatementContext } from "./MalloyParser";
|
|
@@ -1728,6 +1729,16 @@ export interface MalloyParserListener extends ParseTreeListener {
|
|
|
1728
1729
|
* @param ctx the parse tree
|
|
1729
1730
|
*/
|
|
1730
1731
|
exitMatrixOperation?: (ctx: MatrixOperationContext) => void;
|
|
1732
|
+
/**
|
|
1733
|
+
* Enter a parse tree produced by `MalloyParser.joinFrom`.
|
|
1734
|
+
* @param ctx the parse tree
|
|
1735
|
+
*/
|
|
1736
|
+
enterJoinFrom?: (ctx: JoinFromContext) => void;
|
|
1737
|
+
/**
|
|
1738
|
+
* Exit a parse tree produced by `MalloyParser.joinFrom`.
|
|
1739
|
+
* @param ctx the parse tree
|
|
1740
|
+
*/
|
|
1741
|
+
exitJoinFrom?: (ctx: JoinFromContext) => void;
|
|
1731
1742
|
/**
|
|
1732
1743
|
* Enter a parse tree produced by `MalloyParser.joinDef`.
|
|
1733
1744
|
* @param ctx the parse tree
|
|
@@ -135,6 +135,7 @@ import { QueryExtendStatementListContext } from "./MalloyParser";
|
|
|
135
135
|
import { JoinListContext } from "./MalloyParser";
|
|
136
136
|
import { IsExploreContext } from "./MalloyParser";
|
|
137
137
|
import { MatrixOperationContext } from "./MalloyParser";
|
|
138
|
+
import { JoinFromContext } from "./MalloyParser";
|
|
138
139
|
import { JoinDefContext } from "./MalloyParser";
|
|
139
140
|
import { JoinExpressionContext } from "./MalloyParser";
|
|
140
141
|
import { FilterStatementContext } from "./MalloyParser";
|
|
@@ -1110,6 +1111,12 @@ export interface MalloyParserVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
|
1110
1111
|
* @return the visitor result
|
|
1111
1112
|
*/
|
|
1112
1113
|
visitMatrixOperation?: (ctx: MatrixOperationContext) => Result;
|
|
1114
|
+
/**
|
|
1115
|
+
* Visit a parse tree produced by `MalloyParser.joinFrom`.
|
|
1116
|
+
* @param ctx the parse tree
|
|
1117
|
+
* @return the visitor result
|
|
1118
|
+
*/
|
|
1119
|
+
visitJoinFrom?: (ctx: JoinFromContext) => Result;
|
|
1113
1120
|
/**
|
|
1114
1121
|
* Visit a parse tree produced by `MalloyParser.joinDef`.
|
|
1115
1122
|
* @param ctx the parse tree
|
|
@@ -91,7 +91,8 @@ export declare class MalloyToAST extends AbstractParseTreeVisitor<ast.MalloyElem
|
|
|
91
91
|
visitDefJoinOne(pcx: parse.DefJoinOneContext): ast.Joins;
|
|
92
92
|
visitDefJoinCross(pcx: parse.DefJoinCrossContext): ast.Joins;
|
|
93
93
|
protected getJoinList(pcx: parse.JoinListContext): ast.MalloyElement[];
|
|
94
|
-
protected
|
|
94
|
+
protected getJoinFrom(cx: parse.JoinFromContext): {
|
|
95
|
+
joinAs: ast.ModelEntryReference;
|
|
95
96
|
joinFrom: ast.SourceQueryElement;
|
|
96
97
|
notes: Note[];
|
|
97
98
|
};
|
|
@@ -407,13 +407,20 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
407
407
|
getJoinList(pcx) {
|
|
408
408
|
return pcx.joinDef().map(jcx => this.visit(jcx));
|
|
409
409
|
}
|
|
410
|
-
|
|
410
|
+
getJoinFrom(cx) {
|
|
411
|
+
const ecx = cx.isExplore();
|
|
412
|
+
const joinAs = this.getModelEntryName(cx.joinNameDef());
|
|
411
413
|
if (ecx) {
|
|
412
|
-
const
|
|
414
|
+
const joinFrom = this.getSqExpr(ecx.sqExpr());
|
|
413
415
|
const notes = this.getNotes(ecx._before_is).concat(this.getNotes(ecx._after_is));
|
|
414
|
-
return { joinFrom
|
|
416
|
+
return { joinFrom, notes, joinAs };
|
|
415
417
|
}
|
|
416
|
-
|
|
418
|
+
const acx = cx.sourceArguments();
|
|
419
|
+
if (acx) {
|
|
420
|
+
const joinFrom = this.astAt(new ast.SQReference(joinAs, this.getSQArguments(acx)), cx);
|
|
421
|
+
return { joinFrom, notes: [], joinAs };
|
|
422
|
+
}
|
|
423
|
+
return { joinAs, joinFrom: new ast.SQReference(joinAs), notes: [] };
|
|
417
424
|
}
|
|
418
425
|
visitQueryJoinStatement(pcx) {
|
|
419
426
|
const result = this.astAt(this.visit(pcx.joinStatement()), pcx);
|
|
@@ -422,8 +429,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
422
429
|
}
|
|
423
430
|
visitJoinOn(pcx) {
|
|
424
431
|
var _a;
|
|
425
|
-
const joinAs = this.
|
|
426
|
-
const { joinFrom, notes } = this.getJoinSource(joinAs, pcx.isExplore());
|
|
432
|
+
const { joinAs, joinFrom, notes } = this.getJoinFrom(pcx.joinFrom());
|
|
427
433
|
const join = new ast.ExpressionJoin(joinAs, joinFrom);
|
|
428
434
|
const onCx = pcx.joinExpression();
|
|
429
435
|
const mop = ((_a = pcx.matrixOperation()) === null || _a === void 0 ? void 0 : _a.text.toLocaleLowerCase()) || 'left';
|
|
@@ -440,8 +446,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
440
446
|
return this.astAt(join, pcx);
|
|
441
447
|
}
|
|
442
448
|
visitJoinWith(pcx) {
|
|
443
|
-
const joinAs = this.
|
|
444
|
-
const { joinFrom, notes } = this.getJoinSource(joinAs, pcx.isExplore());
|
|
449
|
+
const { joinAs, joinFrom, notes } = this.getJoinFrom(pcx.joinFrom());
|
|
445
450
|
const joinOn = this.getFieldExpr(pcx.fieldExpr());
|
|
446
451
|
const join = new ast.KeyJoin(joinAs, joinFrom, joinOn);
|
|
447
452
|
join.extendNote({ notes: this.getNotes(pcx).concat(notes) });
|
|
@@ -232,7 +232,7 @@ class DocumentSymbolWalker {
|
|
|
232
232
|
handleJoinDef(pcx) {
|
|
233
233
|
const symbol = {
|
|
234
234
|
range: this.translator.rangeFromContext(pcx),
|
|
235
|
-
name: pcx.joinNameDef().id().text,
|
|
235
|
+
name: pcx.joinFrom().joinNameDef().id().text,
|
|
236
236
|
type: 'join',
|
|
237
237
|
children: [],
|
|
238
238
|
};
|
|
@@ -286,7 +286,27 @@ describe('parameters', () => {
|
|
|
286
286
|
run: ab_new(param is ${'ai'}) -> { select: * }
|
|
287
287
|
`).translationToFailWith('`ai` is not defined');
|
|
288
288
|
});
|
|
289
|
-
test('can pass through parameter to joined source', () => {
|
|
289
|
+
test('can pass through parameter to joined source (shorthand)', () => {
|
|
290
|
+
expect(`
|
|
291
|
+
##! experimental.parameters
|
|
292
|
+
source: ab_ext_1(a_1::string) is ab extend {
|
|
293
|
+
where: ai = a_1
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
source: ab_ext_2(a_2::string) is ab extend {
|
|
297
|
+
where: ai = a_2
|
|
298
|
+
join_many: ab_ext_1(a_1 is a_2) on 1 = 1
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
run: ab_ext_2(a_2 is "CA") -> {
|
|
302
|
+
group_by:
|
|
303
|
+
a1 is ai,
|
|
304
|
+
a2 is ab_ext_1.ai
|
|
305
|
+
aggregate: c is count()
|
|
306
|
+
}
|
|
307
|
+
`).toTranslate();
|
|
308
|
+
});
|
|
309
|
+
test('can pass through parameter to joined source (longhand)', () => {
|
|
290
310
|
expect(`
|
|
291
311
|
##! experimental.parameters
|
|
292
312
|
source: ab_ext_1(a_1::string) is ab extend {
|