@malloydata/malloy 0.0.101-dev231107220340 → 0.0.101-dev231109201517
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/elements/pipeline-desc.d.ts +5 -5
- package/dist/lang/ast/elements/pipeline-desc.js +51 -23
- package/dist/lang/ast/elements/source-query-nodes.js +1 -1
- package/dist/lang/ast/query-elements/full-query.js +2 -3
- package/dist/lang/ast/query-properties/nest.d.ts +6 -5
- package/dist/lang/ast/query-properties/nest.js +81 -11
- package/dist/lang/ast/query-properties/refinements.js +4 -0
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +101 -111
- package/dist/lang/lib/Malloy/MalloyParser.js +1588 -1649
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +0 -11
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +0 -7
- package/dist/lang/malloy-to-ast.js +11 -14
- package/dist/lang/parse-tree-walkers/document-symbol-walker.js +27 -1
- package/dist/lang/test/lenses.spec.js +93 -2
- package/dist/model/malloy_types.d.ts +1 -0
- package/dist/model/malloy_types.js +5 -1
- package/package.json +1 -1
|
@@ -109,7 +109,6 @@ import { ExploreTableContext } from "./MalloyParser";
|
|
|
109
109
|
import { ConnectionIdContext } from "./MalloyParser";
|
|
110
110
|
import { QueryPropertiesContext } from "./MalloyParser";
|
|
111
111
|
import { FilterShortcutContext } from "./MalloyParser";
|
|
112
|
-
import { ExploreQueryNameContext } from "./MalloyParser";
|
|
113
112
|
import { QueryNameContext } from "./MalloyParser";
|
|
114
113
|
import { SourcePropertyListContext } from "./MalloyParser";
|
|
115
114
|
import { SourceDefinitionContext } from "./MalloyParser";
|
|
@@ -1463,16 +1462,6 @@ export interface MalloyParserListener extends ParseTreeListener {
|
|
|
1463
1462
|
* @param ctx the parse tree
|
|
1464
1463
|
*/
|
|
1465
1464
|
exitFilterShortcut?: (ctx: FilterShortcutContext) => void;
|
|
1466
|
-
/**
|
|
1467
|
-
* Enter a parse tree produced by `MalloyParser.exploreQueryName`.
|
|
1468
|
-
* @param ctx the parse tree
|
|
1469
|
-
*/
|
|
1470
|
-
enterExploreQueryName?: (ctx: ExploreQueryNameContext) => void;
|
|
1471
|
-
/**
|
|
1472
|
-
* Exit a parse tree produced by `MalloyParser.exploreQueryName`.
|
|
1473
|
-
* @param ctx the parse tree
|
|
1474
|
-
*/
|
|
1475
|
-
exitExploreQueryName?: (ctx: ExploreQueryNameContext) => void;
|
|
1476
1465
|
/**
|
|
1477
1466
|
* Enter a parse tree produced by `MalloyParser.queryName`.
|
|
1478
1467
|
* @param ctx the parse tree
|
|
@@ -109,7 +109,6 @@ import { ExploreTableContext } from "./MalloyParser";
|
|
|
109
109
|
import { ConnectionIdContext } from "./MalloyParser";
|
|
110
110
|
import { QueryPropertiesContext } from "./MalloyParser";
|
|
111
111
|
import { FilterShortcutContext } from "./MalloyParser";
|
|
112
|
-
import { ExploreQueryNameContext } from "./MalloyParser";
|
|
113
112
|
import { QueryNameContext } from "./MalloyParser";
|
|
114
113
|
import { SourcePropertyListContext } from "./MalloyParser";
|
|
115
114
|
import { SourceDefinitionContext } from "./MalloyParser";
|
|
@@ -950,12 +949,6 @@ export interface MalloyParserVisitor<Result> extends ParseTreeVisitor<Result> {
|
|
|
950
949
|
* @return the visitor result
|
|
951
950
|
*/
|
|
952
951
|
visitFilterShortcut?: (ctx: FilterShortcutContext) => Result;
|
|
953
|
-
/**
|
|
954
|
-
* Visit a parse tree produced by `MalloyParser.exploreQueryName`.
|
|
955
|
-
* @param ctx the parse tree
|
|
956
|
-
* @return the visitor result
|
|
957
|
-
*/
|
|
958
|
-
visitExploreQueryName?: (ctx: ExploreQueryNameContext) => Result;
|
|
959
952
|
/**
|
|
960
953
|
* Visit a parse tree produced by `MalloyParser.queryName`.
|
|
961
954
|
* @param ctx the parse tree
|
|
@@ -303,9 +303,9 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
303
303
|
}
|
|
304
304
|
return properties;
|
|
305
305
|
}
|
|
306
|
-
const
|
|
307
|
-
if (
|
|
308
|
-
return this.astAt(
|
|
306
|
+
const fieldPathCx = pcx.fieldPath();
|
|
307
|
+
if (fieldPathCx) {
|
|
308
|
+
return this.astAt(this.getFieldPath(fieldPathCx, ast.ViewFieldReference), fieldPathCx);
|
|
309
309
|
}
|
|
310
310
|
throw this.internalError(pcx, 'Expected either query properties or a view name in refinements');
|
|
311
311
|
}
|
|
@@ -759,9 +759,9 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
759
759
|
if (firstCx.ARROW()) {
|
|
760
760
|
this.m4advisory(firstCx, "Leading '->' in a view or nest definition is no longer needed.");
|
|
761
761
|
}
|
|
762
|
-
const nameCx = firstCx.
|
|
762
|
+
const nameCx = firstCx.fieldPath();
|
|
763
763
|
if (nameCx) {
|
|
764
|
-
pipe.turtleName = this.
|
|
764
|
+
pipe.turtleName = this.getFieldPath(nameCx, ast.ViewFieldReference);
|
|
765
765
|
}
|
|
766
766
|
const propsCx = firstCx.queryProperties();
|
|
767
767
|
if (propsCx) {
|
|
@@ -824,7 +824,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
824
824
|
return new ast.Nests(this.only(pcx.nestEntry().map(cx => this.visit(cx)), x => ast.isNestedQuery(x) && x, 'query'));
|
|
825
825
|
}
|
|
826
826
|
visitNestExisting(pcx) {
|
|
827
|
-
const name = this.
|
|
827
|
+
const name = this.getFieldPath(pcx.fieldPath(), ast.ViewFieldReference);
|
|
828
828
|
const rcxs = pcx.queryRefinement();
|
|
829
829
|
const notes = this.getNotes(pcx.tags());
|
|
830
830
|
if (rcxs.length > 0) {
|
|
@@ -1293,12 +1293,9 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
1293
1293
|
const applyTo = this.getSqExpr(pcx.sqExpr());
|
|
1294
1294
|
const viewParts = [];
|
|
1295
1295
|
const headCx = pcx.leadSeg();
|
|
1296
|
-
const
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
viewParts.push(new ast.ViewFieldReference([
|
|
1300
|
-
this.astAt(new ast.FieldName(headId), headIdCx),
|
|
1301
|
-
]));
|
|
1296
|
+
const headIdCx = headCx.fieldPath();
|
|
1297
|
+
if (headIdCx) {
|
|
1298
|
+
viewParts.push(this.getFieldPath(headIdCx, ast.ViewFieldReference));
|
|
1302
1299
|
const rcxs = headCx.queryRefinement();
|
|
1303
1300
|
if (rcxs.length > 0) {
|
|
1304
1301
|
viewParts.push(...rcxs.map(rcx => this.getQueryRefinements(rcx)));
|
|
@@ -1313,9 +1310,9 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
1313
1310
|
if (asQop) {
|
|
1314
1311
|
viewParts.push(this.visitQueryProperties(asQop));
|
|
1315
1312
|
}
|
|
1316
|
-
const viewName =
|
|
1313
|
+
const viewName = seg.fieldPath();
|
|
1317
1314
|
if (viewName) {
|
|
1318
|
-
viewParts.push(
|
|
1315
|
+
viewParts.push(this.getFieldPath(viewName, ast.ViewFieldReference));
|
|
1319
1316
|
}
|
|
1320
1317
|
}
|
|
1321
1318
|
const sqExpr = new ast.SQAppendView(applyTo, viewParts);
|
|
@@ -21,9 +21,33 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
27
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
28
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
29
|
+
}
|
|
30
|
+
Object.defineProperty(o, k2, desc);
|
|
31
|
+
}) : (function(o, m, k, k2) {
|
|
32
|
+
if (k2 === undefined) k2 = k;
|
|
33
|
+
o[k2] = m[k];
|
|
34
|
+
}));
|
|
35
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
36
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
37
|
+
}) : function(o, v) {
|
|
38
|
+
o["default"] = v;
|
|
39
|
+
});
|
|
40
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
24
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
48
|
exports.walkForDocumentSymbols = void 0;
|
|
26
49
|
const ParseTreeWalker_1 = require("antlr4ts/tree/ParseTreeWalker");
|
|
50
|
+
const parser = __importStar(require("../lib/Malloy/MalloyParser"));
|
|
27
51
|
class DocumentSymbolWalker {
|
|
28
52
|
constructor(translator, tokens, scopes, symbols) {
|
|
29
53
|
this.translator = translator;
|
|
@@ -125,7 +149,9 @@ class DocumentSymbolWalker {
|
|
|
125
149
|
handleNestEntry(pcx) {
|
|
126
150
|
const symbol = {
|
|
127
151
|
range: this.translator.rangeFromContext(pcx),
|
|
128
|
-
name: pcx.
|
|
152
|
+
name: pcx instanceof parser.NestExistingContext
|
|
153
|
+
? pcx.fieldPath().text
|
|
154
|
+
: pcx.queryName().id().text,
|
|
129
155
|
type: 'query',
|
|
130
156
|
children: [],
|
|
131
157
|
};
|
|
@@ -132,7 +132,34 @@ describe('lenses', () => {
|
|
|
132
132
|
run: x -> d + n
|
|
133
133
|
`).toTranslate();
|
|
134
134
|
});
|
|
135
|
-
test('
|
|
135
|
+
test('can reference join field when experiment is enabled', () => {
|
|
136
|
+
expect((0, test_translator_1.markSource) `
|
|
137
|
+
##! experimental { scalar_lenses }
|
|
138
|
+
source: x is a extend {
|
|
139
|
+
join_cross: y is a extend { dimension: n is 1 } on true
|
|
140
|
+
}
|
|
141
|
+
run: x -> y.n
|
|
142
|
+
`).toTranslate();
|
|
143
|
+
});
|
|
144
|
+
test('can reference join field in refinement when experiment is enabled', () => {
|
|
145
|
+
expect((0, test_translator_1.markSource) `
|
|
146
|
+
##! experimental { scalar_lenses }
|
|
147
|
+
source: x is a extend {
|
|
148
|
+
join_cross: y is a extend { dimension: n is 1 } on true
|
|
149
|
+
}
|
|
150
|
+
run: x -> ai + y.n
|
|
151
|
+
`).toTranslate();
|
|
152
|
+
});
|
|
153
|
+
test('can reference join field in nest refinement when experiment is enabled', () => {
|
|
154
|
+
expect((0, test_translator_1.markSource) `
|
|
155
|
+
##! experimental { scalar_lenses }
|
|
156
|
+
source: x is a extend {
|
|
157
|
+
join_cross: y is a extend { dimension: n is 1 } on true
|
|
158
|
+
}
|
|
159
|
+
run: x -> { nest: ai + y.n }
|
|
160
|
+
`).toTranslate();
|
|
161
|
+
});
|
|
162
|
+
test('can nest dimension when experiment is enabled', () => {
|
|
136
163
|
expect((0, test_translator_1.markSource) `
|
|
137
164
|
##! experimental { scalar_lenses }
|
|
138
165
|
source: x is a extend {
|
|
@@ -140,7 +167,71 @@ describe('lenses', () => {
|
|
|
140
167
|
view: d is { nest: n }
|
|
141
168
|
}
|
|
142
169
|
run: x -> d
|
|
143
|
-
`).
|
|
170
|
+
`).toTranslate();
|
|
171
|
+
});
|
|
172
|
+
test('cannot use join_name in refinement shortcut', () => {
|
|
173
|
+
expect((0, test_translator_1.markSource) `
|
|
174
|
+
##! experimental { scalar_lenses }
|
|
175
|
+
source: x is a extend {
|
|
176
|
+
join_one: y is a on true
|
|
177
|
+
view: m is { aggregate: c is count() }
|
|
178
|
+
}
|
|
179
|
+
run: x -> m + y + { limit: 1 }`).translationToFailWith('named refinement `y` must be a view, found a struct');
|
|
180
|
+
});
|
|
181
|
+
test('cannot use view from join as whole pipeline', () => {
|
|
182
|
+
expect((0, test_translator_1.markSource) `
|
|
183
|
+
##! experimental { scalar_lenses }
|
|
184
|
+
source: x is a extend {
|
|
185
|
+
join_one: y is a extend {
|
|
186
|
+
view: z is { group_by: d is 1 }
|
|
187
|
+
} on true
|
|
188
|
+
}
|
|
189
|
+
run: x -> y.z
|
|
190
|
+
`).translationToFailWith('Cannot use view from join');
|
|
191
|
+
});
|
|
192
|
+
test('cannot use view from join in nest', () => {
|
|
193
|
+
expect((0, test_translator_1.markSource) `
|
|
194
|
+
##! experimental { scalar_lenses }
|
|
195
|
+
source: x is a extend {
|
|
196
|
+
join_one: y is a extend {
|
|
197
|
+
view: z is { group_by: d is 1 }
|
|
198
|
+
} on true
|
|
199
|
+
}
|
|
200
|
+
run: x -> { nest: y.z }
|
|
201
|
+
`).translationToFailWith('Cannot nest view from join');
|
|
202
|
+
});
|
|
203
|
+
test('cannot use view from join as nest view head', () => {
|
|
204
|
+
expect((0, test_translator_1.markSource) `
|
|
205
|
+
##! experimental { scalar_lenses }
|
|
206
|
+
source: x is a extend {
|
|
207
|
+
join_one: y is a extend {
|
|
208
|
+
view: z is { group_by: d is 1 }
|
|
209
|
+
} on true
|
|
210
|
+
}
|
|
211
|
+
run: x -> { nest: y.z + { limit: 1 } }
|
|
212
|
+
`).translationToFailWith('Cannot use view from join');
|
|
213
|
+
});
|
|
214
|
+
test('cannot use view from join as lens in query', () => {
|
|
215
|
+
expect((0, test_translator_1.markSource) `
|
|
216
|
+
##! experimental { scalar_lenses }
|
|
217
|
+
source: x is a extend {
|
|
218
|
+
join_one: y is a extend {
|
|
219
|
+
view: z is { group_by: d is 1 }
|
|
220
|
+
} on true
|
|
221
|
+
}
|
|
222
|
+
run: x -> ai + y.z
|
|
223
|
+
`).translationToFailWith('Cannot use view from join as refinement');
|
|
224
|
+
});
|
|
225
|
+
test('cannot use view from join as lens in nest', () => {
|
|
226
|
+
expect((0, test_translator_1.markSource) `
|
|
227
|
+
##! experimental { scalar_lenses }
|
|
228
|
+
source: x is a extend {
|
|
229
|
+
join_one: y is a extend {
|
|
230
|
+
view: z is { group_by: d is 1 }
|
|
231
|
+
} on true
|
|
232
|
+
}
|
|
233
|
+
run: x -> { nest: ai + y.z }
|
|
234
|
+
`).translationToFailWith('Cannot use view from join as refinement');
|
|
144
235
|
});
|
|
145
236
|
test('can nest dimension with refinement when experiment is enabled', () => {
|
|
146
237
|
expect((0, test_translator_1.markSource) `
|
|
@@ -671,6 +671,7 @@ export interface QueryResult extends CompiledQuery {
|
|
|
671
671
|
runStats?: QueryRunStats;
|
|
672
672
|
}
|
|
673
673
|
export declare function isTurtleDef(def: FieldDef): def is TurtleDef;
|
|
674
|
+
export declare function isAtomicField(def: FieldDef): def is FieldAtomicDef;
|
|
674
675
|
export interface SearchResultRow {
|
|
675
676
|
field_name: string;
|
|
676
677
|
field_value: string;
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.isSQLFragment = exports.isJoinOn = exports.isIndexSegment = exports.isSamplingEnable = exports.isSamplingPercent = exports.isSamplingRows = exports.isQuerySegment = exports.isProjectSegment = exports.isPartialSegment = exports.isReduceSegment = exports.refIsStructDef = exports.isByExpression = exports.isByName = exports.ValueType = exports.isExtractUnit = exports.isTimestampUnit = exports.isDateUnit = exports.FieldIsIntrinsic = exports.isCastType = exports.isAtomicFieldType = exports.isTimeFieldType = exports.hasExpression = exports.maxOfExpressionTypes = exports.maxExpressionType = exports.isExpressionTypeLEQ = exports.expressionIsAnalytic = exports.expressionIsCalculation = exports.expressionInvolvesAggregate = exports.expressionIsUngroupedAggregate = exports.expressionIsAggregate = exports.expressionIsScalar = exports.mkExpr = exports.isApplyFragment = exports.isApplyValue = exports.isParameterFragment = exports.isFieldFragment = exports.isSpreadFragment = exports.isSQLExpressionFragment = exports.isFunctionCallFragment = exports.isFunctionParameterFragment = exports.isUngroupFragment = exports.isAsymmetricFragment = exports.isAggregateFragment = exports.isDialectFragment = exports.isFilterFragment = exports.isOutputFieldFragment = exports.isFilteredAliasedName = exports.paramHasValue = exports.isConditionParameter = exports.isValueParameter = void 0;
|
|
26
|
-
exports.isValueDate = exports.isValueTimestamp = exports.isValueBoolean = exports.isValueNumber = exports.isValueString = exports.isMeasureLike = exports.getPhysicalFields = exports.getDimensions = exports.isPhysical = exports.isDimensional = exports.isTurtleDef = exports.getIdentifier = exports.isFieldStructDef = exports.isFieldTimeBased = exports.isFieldTypeDef = exports.isSQLBlockStruct = exports.mergeEvalSpaces = void 0;
|
|
26
|
+
exports.isValueDate = exports.isValueTimestamp = exports.isValueBoolean = exports.isValueNumber = exports.isValueString = exports.isMeasureLike = exports.getPhysicalFields = exports.getDimensions = exports.isPhysical = exports.isDimensional = exports.isAtomicField = exports.isTurtleDef = exports.getIdentifier = exports.isFieldStructDef = exports.isFieldTimeBased = exports.isFieldTypeDef = exports.isSQLBlockStruct = exports.mergeEvalSpaces = void 0;
|
|
27
27
|
function isValueParameter(p) {
|
|
28
28
|
return p.value !== undefined;
|
|
29
29
|
}
|
|
@@ -366,6 +366,10 @@ function isTurtleDef(def) {
|
|
|
366
366
|
return def.type === 'turtle';
|
|
367
367
|
}
|
|
368
368
|
exports.isTurtleDef = isTurtleDef;
|
|
369
|
+
function isAtomicField(def) {
|
|
370
|
+
return isAtomicFieldType(def.type);
|
|
371
|
+
}
|
|
372
|
+
exports.isAtomicField = isAtomicField;
|
|
369
373
|
function isDimensional(field) {
|
|
370
374
|
var _a;
|
|
371
375
|
if ('resultMetadata' in field) {
|