@malloydata/malloy 0.0.39-dev230613161129 → 0.0.39
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.d.ts +9 -13
- package/dist/dialect/dialect.js +16 -3
- package/dist/dialect/dialect_map.d.ts +2 -0
- package/dist/dialect/dialect_map.js +61 -1
- package/dist/dialect/{duckdb.d.ts → duckdb/duckdb.d.ts} +8 -5
- package/dist/dialect/{duckdb.js → duckdb/duckdb.js} +21 -9
- package/dist/dialect/duckdb/functions/byte_length.d.ts +2 -0
- package/dist/dialect/duckdb/functions/byte_length.js +33 -0
- package/dist/dialect/duckdb/functions/div.d.ts +2 -0
- package/dist/dialect/duckdb/functions/div.js +38 -0
- package/dist/dialect/duckdb/functions/duckdb_functions.d.ts +1 -0
- package/dist/dialect/duckdb/functions/duckdb_functions.js +52 -0
- package/dist/dialect/duckdb/functions/ends_with.d.ts +2 -0
- package/dist/dialect/duckdb/functions/ends_with.js +35 -0
- package/dist/dialect/duckdb/functions/greatest_and_least.d.ts +3 -0
- package/dist/dialect/duckdb/functions/greatest_and_least.js +58 -0
- package/dist/dialect/duckdb/functions/index.d.ts +1 -0
- package/dist/dialect/duckdb/functions/index.js +28 -0
- package/dist/dialect/duckdb/functions/is_inf.d.ts +2 -0
- package/dist/dialect/duckdb/functions/is_inf.js +33 -0
- package/dist/dialect/duckdb/functions/is_nan.d.ts +2 -0
- package/dist/dialect/duckdb/functions/is_nan.js +33 -0
- package/dist/dialect/duckdb/functions/log.d.ts +2 -0
- package/dist/dialect/duckdb/functions/log.js +38 -0
- package/dist/dialect/duckdb/functions/rand.d.ts +2 -0
- package/dist/dialect/duckdb/functions/rand.js +31 -0
- package/dist/dialect/duckdb/functions/replace.d.ts +2 -0
- package/dist/dialect/duckdb/functions/replace.js +40 -0
- package/dist/dialect/duckdb/functions/trunc.d.ts +2 -0
- package/dist/dialect/duckdb/functions/trunc.js +39 -0
- package/dist/dialect/duckdb/functions/unicode.d.ts +2 -0
- package/dist/dialect/duckdb/functions/unicode.js +35 -0
- package/dist/dialect/duckdb/index.d.ts +1 -0
- package/dist/dialect/duckdb/index.js +40 -0
- package/dist/dialect/functions/all_functions.d.ts +8 -0
- package/dist/dialect/functions/all_functions.js +135 -0
- package/dist/dialect/functions/atan2.d.ts +2 -0
- package/dist/dialect/functions/atan2.js +33 -0
- package/dist/dialect/functions/avg_moving.d.ts +2 -0
- package/dist/dialect/functions/avg_moving.js +46 -0
- package/dist/dialect/functions/chr.d.ts +4 -0
- package/dist/dialect/functions/chr.js +45 -0
- package/dist/dialect/functions/coalesce.d.ts +2 -0
- package/dist/dialect/functions/coalesce.js +38 -0
- package/dist/dialect/functions/concat.d.ts +2 -0
- package/dist/dialect/functions/concat.js +38 -0
- package/dist/dialect/functions/div.d.ts +2 -0
- package/dist/dialect/functions/div.js +36 -0
- package/dist/dialect/functions/first_value_window.d.ts +3 -0
- package/dist/dialect/functions/first_value_window.js +49 -0
- package/dist/dialect/functions/function_map.d.ts +16 -0
- package/dist/dialect/functions/function_map.js +50 -0
- package/dist/dialect/functions/greatest_and_least.d.ts +3 -0
- package/dist/dialect/functions/greatest_and_least.js +44 -0
- package/dist/dialect/functions/ifnull.d.ts +2 -0
- package/dist/dialect/functions/ifnull.js +38 -0
- package/dist/dialect/functions/index.d.ts +2 -0
- package/dist/dialect/functions/index.js +28 -0
- package/dist/dialect/functions/is_inf.d.ts +2 -0
- package/dist/dialect/functions/is_inf.js +33 -0
- package/dist/dialect/functions/is_nan.d.ts +2 -0
- package/dist/dialect/functions/is_nan.js +33 -0
- package/dist/dialect/functions/lag.d.ts +2 -0
- package/dist/dialect/functions/lag.js +53 -0
- package/dist/dialect/functions/lead.d.ts +2 -0
- package/dist/dialect/functions/lead.js +50 -0
- package/dist/dialect/functions/length.d.ts +3 -0
- package/dist/dialect/functions/length.js +39 -0
- package/dist/dialect/functions/log.d.ts +2 -0
- package/dist/dialect/functions/log.js +35 -0
- package/dist/dialect/functions/lower.d.ts +2 -0
- package/dist/dialect/functions/lower.js +34 -0
- package/dist/dialect/functions/nullif.d.ts +2 -0
- package/dist/dialect/functions/nullif.js +42 -0
- package/dist/dialect/functions/pi.d.ts +2 -0
- package/dist/{lang/ast/types/type-desc.js → dialect/functions/pi.js} +7 -1
- package/dist/dialect/functions/pow.d.ts +2 -0
- package/dist/dialect/functions/pow.js +35 -0
- package/dist/dialect/functions/rand.d.ts +2 -0
- package/dist/dialect/functions/rand.js +31 -0
- package/dist/dialect/functions/rank.d.ts +2 -0
- package/dist/dialect/functions/rank.js +36 -0
- package/dist/dialect/functions/regexp_extract.d.ts +2 -0
- package/dist/dialect/functions/regexp_extract.js +41 -0
- package/dist/dialect/functions/repeat.d.ts +2 -0
- package/dist/dialect/functions/repeat.js +35 -0
- package/dist/dialect/functions/replace.d.ts +2 -0
- package/dist/dialect/functions/replace.js +42 -0
- package/dist/dialect/functions/reverse.d.ts +2 -0
- package/dist/dialect/functions/reverse.js +34 -0
- package/dist/dialect/functions/round.d.ts +2 -0
- package/dist/dialect/functions/round.js +40 -0
- package/dist/dialect/functions/row_number.d.ts +2 -0
- package/dist/dialect/functions/row_number.js +40 -0
- package/dist/dialect/functions/simple_numeric_functions.d.ts +15 -0
- package/dist/dialect/functions/simple_numeric_functions.js +60 -0
- package/dist/dialect/functions/starts_ends_with.d.ts +3 -0
- package/dist/dialect/functions/starts_ends_with.js +43 -0
- package/dist/dialect/functions/stddev.d.ts +2 -0
- package/dist/dialect/functions/stddev.js +34 -0
- package/dist/dialect/functions/strpos.d.ts +2 -0
- package/dist/dialect/functions/strpos.js +35 -0
- package/dist/dialect/functions/substr.d.ts +2 -0
- package/dist/dialect/functions/substr.js +37 -0
- package/dist/dialect/functions/sum_min_max_window.d.ts +7 -0
- package/dist/dialect/functions/sum_min_max_window.js +94 -0
- package/dist/dialect/functions/trim_functions.d.ts +4 -0
- package/dist/dialect/functions/trim_functions.js +42 -0
- package/dist/dialect/functions/trunc.d.ts +2 -0
- package/dist/dialect/functions/trunc.js +38 -0
- package/dist/dialect/functions/upper.d.ts +2 -0
- package/dist/dialect/functions/upper.js +34 -0
- package/dist/dialect/functions/util.d.ts +45 -0
- package/dist/dialect/functions/util.js +187 -0
- package/dist/dialect/index.d.ts +1 -1
- package/dist/dialect/index.js +2 -1
- package/dist/dialect/postgres/functions/byte_length.d.ts +2 -0
- package/dist/dialect/postgres/functions/byte_length.js +33 -0
- package/dist/dialect/postgres/functions/ends_with.d.ts +2 -0
- package/dist/dialect/postgres/functions/ends_with.js +38 -0
- package/dist/dialect/postgres/functions/greatest_and_least.d.ts +3 -0
- package/dist/dialect/postgres/functions/greatest_and_least.js +45 -0
- package/dist/dialect/postgres/functions/ifnull.d.ts +2 -0
- package/dist/dialect/postgres/functions/ifnull.js +40 -0
- package/dist/dialect/postgres/functions/index.d.ts +1 -0
- package/dist/dialect/postgres/functions/index.js +28 -0
- package/dist/dialect/postgres/functions/is_inf.d.ts +2 -0
- package/dist/dialect/postgres/functions/is_inf.js +34 -0
- package/dist/dialect/postgres/functions/is_nan.d.ts +2 -0
- package/dist/dialect/postgres/functions/is_nan.js +33 -0
- package/dist/dialect/postgres/functions/log.d.ts +2 -0
- package/dist/dialect/postgres/functions/log.js +37 -0
- package/dist/dialect/postgres/functions/postgres_functions.d.ts +1 -0
- package/dist/dialect/postgres/functions/postgres_functions.js +60 -0
- package/dist/dialect/postgres/functions/rand.d.ts +2 -0
- package/dist/dialect/postgres/functions/rand.js +31 -0
- package/dist/dialect/postgres/functions/regexp_extract.d.ts +2 -0
- package/dist/dialect/postgres/functions/regexp_extract.js +35 -0
- package/dist/dialect/postgres/functions/replace.d.ts +2 -0
- package/dist/dialect/postgres/functions/replace.js +40 -0
- package/dist/dialect/postgres/functions/round.d.ts +2 -0
- package/dist/dialect/postgres/functions/round.js +39 -0
- package/dist/dialect/postgres/functions/stddev.d.ts +2 -0
- package/dist/dialect/postgres/functions/stddev.js +37 -0
- package/dist/dialect/postgres/functions/substr.d.ts +2 -0
- package/dist/dialect/postgres/functions/substr.js +38 -0
- package/dist/dialect/postgres/functions/trunc.d.ts +2 -0
- package/dist/dialect/postgres/functions/trunc.js +40 -0
- package/dist/dialect/postgres/functions/unicode.d.ts +2 -0
- package/dist/dialect/postgres/functions/unicode.js +34 -0
- package/dist/dialect/postgres/index.d.ts +1 -0
- package/dist/dialect/postgres/index.js +40 -0
- package/dist/dialect/{postgres.d.ts → postgres/postgres.d.ts} +9 -5
- package/dist/dialect/{postgres.js → postgres/postgres.js} +24 -10
- package/dist/dialect/standardsql/functions/chr.d.ts +2 -0
- package/dist/dialect/standardsql/functions/chr.js +37 -0
- package/dist/dialect/standardsql/functions/index.d.ts +1 -0
- package/dist/dialect/standardsql/functions/index.js +28 -0
- package/dist/dialect/standardsql/functions/pi.d.ts +2 -0
- package/dist/dialect/standardsql/functions/pi.js +32 -0
- package/dist/dialect/standardsql/functions/standardsql_functions.d.ts +1 -0
- package/dist/dialect/standardsql/functions/standardsql_functions.js +33 -0
- package/dist/dialect/standardsql/index.d.ts +1 -0
- package/dist/dialect/standardsql/index.js +40 -0
- package/dist/dialect/{standardsql.d.ts → standardsql/standardsql.d.ts} +7 -4
- package/dist/dialect/{standardsql.js → standardsql/standardsql.js} +13 -11
- package/dist/index.d.ts +1 -1
- package/dist/lang/ast/ast-utils.js +1 -0
- package/dist/lang/ast/elements/define-query.js +1 -1
- package/dist/lang/ast/elements/import-statement.js +6 -1
- package/dist/lang/ast/executors/index-executor.d.ts +1 -1
- package/dist/lang/ast/executors/index-executor.js +2 -2
- package/dist/lang/ast/executors/project-executor.d.ts +1 -1
- package/dist/lang/ast/executors/project-executor.js +2 -2
- package/dist/lang/ast/executors/reduce-executor.d.ts +2 -4
- package/dist/lang/ast/executors/reduce-executor.js +8 -4
- package/dist/lang/ast/expressions/binary-boolean.d.ts +1 -1
- package/dist/lang/ast/expressions/binary-boolean.js +2 -0
- package/dist/lang/ast/expressions/constant-sub-expression.js +10 -0
- package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-aggregate-function.js +28 -2
- package/dist/lang/ast/expressions/expr-alternation-tree.js +1 -0
- package/dist/lang/ast/expressions/expr-cast.js +1 -0
- package/dist/lang/ast/expressions/expr-coalesce.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-coalesce.js +1 -0
- package/dist/lang/ast/expressions/expr-count-distinct.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-count.js +1 -0
- package/dist/lang/ast/expressions/expr-filter.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-filter.js +1 -1
- package/dist/lang/ast/expressions/expr-func.d.ts +6 -1
- package/dist/lang/ast/expressions/expr-func.js +266 -16
- package/dist/lang/ast/expressions/expr-granular-time.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-id-reference.js +12 -0
- package/dist/lang/ast/expressions/expr-logical-op.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-max.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-min.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-not.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-now.js +2 -0
- package/dist/lang/ast/expressions/expr-null.js +1 -0
- package/dist/lang/ast/expressions/expr-number.js +5 -1
- package/dist/lang/ast/expressions/expr-regex.js +4 -1
- package/dist/lang/ast/expressions/expr-string.js +1 -0
- package/dist/lang/ast/expressions/expr-time-extract.js +2 -0
- package/dist/lang/ast/expressions/expr-time.js +1 -0
- package/dist/lang/ast/expressions/expr-ungroup.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-ungroup.js +15 -7
- package/dist/lang/ast/expressions/for-range.d.ts +1 -1
- package/dist/lang/ast/expressions/pick-when.js +7 -0
- package/dist/lang/ast/expressions/range.js +1 -0
- package/dist/lang/ast/expressions/time-literal.js +9 -3
- package/dist/lang/ast/field-space/column-space-field.d.ts +1 -2
- package/dist/lang/ast/field-space/dynamic-space.js +6 -4
- package/dist/lang/ast/field-space/field-definition-value.d.ts +1 -1
- package/dist/lang/ast/field-space/project-field-space.d.ts +2 -2
- package/dist/lang/ast/field-space/project-field-space.js +12 -13
- package/dist/lang/ast/field-space/query-space-field.d.ts +1 -2
- package/dist/lang/ast/field-space/query-space-field.js +1 -1
- package/dist/lang/ast/field-space/query-spaces.d.ts +16 -2
- package/dist/lang/ast/field-space/query-spaces.js +175 -10
- package/dist/lang/ast/field-space/reference-field.d.ts +3 -2
- package/dist/lang/ast/field-space/reference-field.js +8 -1
- package/dist/lang/ast/field-space/rename-space-field.d.ts +1 -2
- package/dist/lang/ast/field-space/static-space.d.ts +4 -3
- package/dist/lang/ast/field-space/static-space.js +4 -0
- package/dist/lang/ast/field-space/struct-space-field-base.d.ts +1 -2
- package/dist/lang/ast/field-space/struct-space-field-base.js +1 -1
- package/dist/lang/ast/field-space/wild-space-field.d.ts +1 -2
- package/dist/lang/ast/fragtype-utils.d.ts +1 -1
- package/dist/lang/ast/fragtype-utils.js +4 -3
- package/dist/lang/ast/index.d.ts +1 -0
- package/dist/lang/ast/index.js +1 -0
- package/dist/lang/ast/query-items/field-declaration.d.ts +40 -4
- package/dist/lang/ast/query-items/field-declaration.js +102 -3
- package/dist/lang/ast/query-items/field-references.d.ts +44 -2
- package/dist/lang/ast/query-items/field-references.js +110 -2
- package/dist/lang/ast/query-items/typecheck_utils.d.ts +10 -0
- package/dist/lang/ast/query-items/typecheck_utils.js +177 -0
- package/dist/lang/ast/query-properties/aggregate.js +0 -6
- package/dist/lang/ast/query-properties/calculate.d.ts +5 -0
- package/dist/lang/ast/query-properties/calculate.js +33 -0
- package/dist/lang/ast/query-properties/dimmensions.js +0 -3
- package/dist/lang/ast/query-properties/filters.js +6 -3
- package/dist/lang/ast/query-properties/group-by.js +0 -6
- package/dist/lang/ast/query-properties/measures.js +0 -3
- package/dist/lang/ast/query-properties/nest-reference.d.ts +2 -0
- package/dist/lang/ast/query-properties/nest-reference.js +23 -0
- package/dist/lang/ast/query-properties/ordering.d.ts +1 -1
- package/dist/lang/ast/query-properties/ordering.js +18 -8
- package/dist/lang/ast/query-properties/qop-desc.js +8 -4
- package/dist/lang/ast/query-properties/top.js +20 -6
- package/dist/lang/ast/sources/named-source.js +4 -0
- package/dist/lang/ast/sources/sql-source.js +5 -1
- package/dist/lang/ast/time-utils.d.ts +1 -2
- package/dist/lang/ast/types/expr-result.d.ts +1 -2
- package/dist/lang/ast/types/expression-def.d.ts +3 -4
- package/dist/lang/ast/types/expression-def.js +10 -2
- package/dist/lang/ast/types/field-space.d.ts +7 -0
- package/dist/lang/ast/types/global-name-space.d.ts +12 -0
- package/dist/lang/ast/types/global-name-space.js +51 -0
- package/dist/lang/ast/types/malloy-element.d.ts +1 -0
- package/dist/lang/ast/types/malloy-element.js +15 -2
- package/dist/lang/ast/types/query-property.d.ts +1 -2
- package/dist/lang/ast/types/query-property.js +2 -0
- package/dist/lang/ast/types/space-entry.d.ts +1 -1
- package/dist/lang/ast/types/space-field.d.ts +1 -2
- package/dist/lang/ast/types/space-field.js +5 -1
- package/dist/lang/ast/types/space-param.d.ts +1 -2
- package/dist/lang/ast/types/space-param.js +10 -2
- package/dist/lang/lib/Malloy/MalloyLexer.d.ts +138 -135
- package/dist/lang/lib/Malloy/MalloyLexer.js +1135 -1103
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +252 -275
- package/dist/lang/lib/Malloy/MalloyParser.js +1753 -1905
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +40 -103
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +25 -64
- package/dist/lang/malloy-to-ast.d.ts +11 -7
- package/dist/lang/malloy-to-ast.js +90 -51
- package/dist/lang/parse-tree-walkers/document-symbol-walker.js +5 -2
- package/dist/lang/test/parse.spec.js +399 -18
- package/dist/lang/test/test-translator.d.ts +1 -0
- package/dist/lang/test/test-translator.js +5 -0
- package/dist/model/malloy_query.d.ts +13 -4
- package/dist/model/malloy_query.js +240 -76
- package/dist/model/malloy_types.d.ts +89 -18
- package/dist/model/malloy_types.js +88 -61
- package/dist/model/utils.d.ts +4 -0
- package/dist/model/utils.js +118 -1
- package/package.json +1 -1
- package/dist/lang/ast/types/type-desc.d.ts +0 -8
|
@@ -208,22 +208,8 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
208
208
|
const fel = new ast.FilterElement(expr, this.getSourceCode(cx));
|
|
209
209
|
return this.astAt(fel, cx);
|
|
210
210
|
}
|
|
211
|
-
getFieldDefs(cxList,
|
|
212
|
-
|
|
213
|
-
for (const cx of cxList) {
|
|
214
|
-
const v = this.visit(cx);
|
|
215
|
-
if (v instanceof ast.FieldDeclaration) {
|
|
216
|
-
this.astAt(v, cx);
|
|
217
|
-
visited.push(v);
|
|
218
|
-
if (isAgg !== undefined) {
|
|
219
|
-
v.isMeasure = isAgg;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
this.contextError(cx, 'Expected field definition');
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return visited;
|
|
211
|
+
getFieldDefs(cxList, makeFieldDef) {
|
|
212
|
+
return cxList.map(cx => this.getFieldDef(cx, makeFieldDef));
|
|
227
213
|
}
|
|
228
214
|
getFieldExpr(cx) {
|
|
229
215
|
const element = this.visit(cx);
|
|
@@ -397,25 +383,25 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
397
383
|
const join = new ast.KeyJoin(joinAs, joinFrom, joinOn);
|
|
398
384
|
return this.astAt(join, pcx);
|
|
399
385
|
}
|
|
400
|
-
|
|
386
|
+
getFieldDef(pcx, makeFieldDef) {
|
|
401
387
|
const defCx = pcx.fieldExpr();
|
|
402
388
|
const fieldName = this.getIdText(pcx.fieldNameDef());
|
|
403
389
|
const valExpr = this.getFieldExpr(defCx);
|
|
404
|
-
const def = new
|
|
390
|
+
const def = new makeFieldDef(valExpr, fieldName, this.getSourceCode(defCx));
|
|
405
391
|
return this.astAt(def, pcx);
|
|
406
392
|
}
|
|
407
393
|
visitDefExploreDimension(pcx) {
|
|
408
|
-
const defs = this.getFieldDefs(pcx.
|
|
394
|
+
const defs = this.getFieldDefs(pcx.defList().fieldDef(), ast.DimensionFieldDeclaration);
|
|
409
395
|
const stmt = new ast.Dimensions(defs);
|
|
410
396
|
return this.astAt(stmt, pcx);
|
|
411
397
|
}
|
|
412
398
|
visitDefExploreMeasure(pcx) {
|
|
413
|
-
const defs = this.getFieldDefs(pcx.
|
|
399
|
+
const defs = this.getFieldDefs(pcx.defList().fieldDef(), ast.MeasureFieldDeclaration);
|
|
414
400
|
const stmt = new ast.Measures(defs);
|
|
415
401
|
return this.astAt(stmt, pcx);
|
|
416
402
|
}
|
|
417
403
|
visitDeclareStatement(pcx) {
|
|
418
|
-
const defs = this.getFieldDefs(pcx.fieldDef(),
|
|
404
|
+
const defs = this.getFieldDefs(pcx.defList().fieldDef(), ast.DeclareFieldDeclaration);
|
|
419
405
|
const stmt = new ast.DeclareFields(defs);
|
|
420
406
|
return this.astAt(stmt, pcx);
|
|
421
407
|
}
|
|
@@ -461,7 +447,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
461
447
|
visitFieldNameList(pcx) {
|
|
462
448
|
const members = pcx
|
|
463
449
|
.fieldName()
|
|
464
|
-
.map(cx => new ast.
|
|
450
|
+
.map(cx => new ast.AcceptExceptFieldReference([this.getFieldName(cx)]));
|
|
465
451
|
return new ast.FieldReferences(members);
|
|
466
452
|
}
|
|
467
453
|
visitDefExploreEditField(pcx) {
|
|
@@ -495,17 +481,13 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
495
481
|
}
|
|
496
482
|
return new ast.QOPDesc(qProps);
|
|
497
483
|
}
|
|
498
|
-
|
|
484
|
+
getFieldPath(pcx, makeFieldRef) {
|
|
499
485
|
const names = pcx.fieldName().map(nameCx => this.getFieldName(nameCx));
|
|
500
|
-
return this.astAt(new
|
|
501
|
-
}
|
|
502
|
-
visitQueryFieldDef(pcx) {
|
|
503
|
-
const defCx = pcx.dimensionDef().fieldDef();
|
|
504
|
-
const dim = this.visitFieldDef(defCx);
|
|
505
|
-
return this.astAt(dim, defCx);
|
|
486
|
+
return this.astAt(new makeFieldRef(names), pcx);
|
|
506
487
|
}
|
|
507
|
-
|
|
508
|
-
|
|
488
|
+
getQueryFieldDef(pcx, makeFieldDef) {
|
|
489
|
+
const dim = this.getFieldDef(pcx, makeFieldDef);
|
|
490
|
+
return this.astAt(dim, pcx);
|
|
509
491
|
}
|
|
510
492
|
// visitQueryFieldNameless(
|
|
511
493
|
// pcx: parse.QueryFieldNamelessContext
|
|
@@ -515,33 +497,60 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
515
497
|
// noItem.reported = true;
|
|
516
498
|
// return noItem;
|
|
517
499
|
// }
|
|
518
|
-
|
|
519
|
-
const
|
|
500
|
+
getQueryFieldEntry(ctx, makeFieldDef, makeFieldRef) {
|
|
501
|
+
const fieldPath = ctx.fieldPath();
|
|
502
|
+
if (fieldPath) {
|
|
503
|
+
return this.getFieldPath(fieldPath, makeFieldRef);
|
|
504
|
+
}
|
|
505
|
+
const def = ctx.fieldDef();
|
|
506
|
+
if (def) {
|
|
507
|
+
return this.getQueryFieldDef(def, makeFieldDef);
|
|
508
|
+
}
|
|
509
|
+
throw new Error('Expected query field entry to be a field reference or definition');
|
|
510
|
+
}
|
|
511
|
+
getQueryItems(pcx, makeFieldDef, makeFieldRef) {
|
|
512
|
+
const itemList = pcx
|
|
513
|
+
.queryFieldEntry()
|
|
514
|
+
.map(e => this.getQueryFieldEntry(e, makeFieldDef, makeFieldRef));
|
|
520
515
|
return this.onlyQueryRefs(itemList);
|
|
521
516
|
}
|
|
522
517
|
visitAggregateStatement(pcx) {
|
|
523
|
-
return new ast.Aggregate(this.getQueryItems(pcx.queryFieldList()));
|
|
518
|
+
return new ast.Aggregate(this.getQueryItems(pcx.queryFieldList(), ast.AggregateFieldDeclaration, ast.AggregateFieldReference));
|
|
524
519
|
}
|
|
525
520
|
visitGroupByStatement(pcx) {
|
|
526
|
-
return new ast.GroupBy(this.getQueryItems(pcx.queryFieldList()));
|
|
521
|
+
return new ast.GroupBy(this.getQueryItems(pcx.queryFieldList(), ast.GroupByFieldDeclaration, ast.GroupByFieldReference));
|
|
527
522
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
523
|
+
visitCalculateStatement(pcx) {
|
|
524
|
+
return new ast.Calculate(this.getQueryItems(pcx.queryFieldList(), ast.CalculateFieldDeclaration, ast.CalculateFieldReference));
|
|
525
|
+
}
|
|
526
|
+
getFieldCollectionMember(pcx, makeFieldDef, makeFieldRef) {
|
|
527
|
+
const fieldDef = pcx.fieldDef();
|
|
528
|
+
if (fieldDef) {
|
|
529
|
+
return this.getFieldDef(fieldDef, makeFieldDef);
|
|
530
|
+
}
|
|
531
|
+
const fieldPath = pcx.fieldPath();
|
|
532
|
+
if (fieldPath) {
|
|
533
|
+
return this.getFieldPath(fieldPath, makeFieldRef);
|
|
534
|
+
}
|
|
535
|
+
const collectionWildcard = pcx.collectionWildCard();
|
|
536
|
+
if (collectionWildcard) {
|
|
537
|
+
return this.visitCollectionWildCard(collectionWildcard);
|
|
538
538
|
}
|
|
539
|
+
throw this.internalError(pcx, 'Unexpected element in fieldCollectionMember');
|
|
540
|
+
}
|
|
541
|
+
// "FieldCollection" can only mean a project statement today
|
|
542
|
+
visitFieldCollection(pcx) {
|
|
543
|
+
const fields = pcx
|
|
544
|
+
.collectionMember()
|
|
545
|
+
.map(c => this.getFieldCollectionMember(c, ast.ProjectFieldDeclaration, ast.ProjectFieldReference));
|
|
539
546
|
return this.astAt(new ast.ProjectStatement(fields), pcx);
|
|
540
547
|
}
|
|
541
|
-
|
|
548
|
+
visitCollectionWildCard(pcx) {
|
|
542
549
|
const nameCx = pcx.fieldPath();
|
|
543
550
|
const stars = pcx.STAR() ? '*' : '**';
|
|
544
|
-
const join = nameCx
|
|
551
|
+
const join = nameCx
|
|
552
|
+
? this.getFieldPath(nameCx, ast.ProjectFieldReference)
|
|
553
|
+
: undefined;
|
|
545
554
|
return new ast.WildcardFieldReference(join, stars);
|
|
546
555
|
}
|
|
547
556
|
visitIndexFields(pcx) {
|
|
@@ -551,7 +560,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
551
560
|
if (!pathCx) {
|
|
552
561
|
return new ast.WildcardFieldReference(undefined, '*');
|
|
553
562
|
}
|
|
554
|
-
const path = this.
|
|
563
|
+
const path = this.getFieldPath(pathCx, ast.IndexFieldReference);
|
|
555
564
|
if (!hasStar) {
|
|
556
565
|
return this.astAt(path, pcx);
|
|
557
566
|
}
|
|
@@ -772,7 +781,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
772
781
|
}
|
|
773
782
|
}
|
|
774
783
|
visitExprFieldPath(pcx) {
|
|
775
|
-
const idRef = new ast.ExprIdReference(this.
|
|
784
|
+
const idRef = new ast.ExprIdReference(this.getFieldPath(pcx.fieldPath(), ast.ExpressionFieldReference));
|
|
776
785
|
return this.astAt(idRef, pcx);
|
|
777
786
|
}
|
|
778
787
|
visitExprNULL(_pcx) {
|
|
@@ -811,7 +820,9 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
811
820
|
}
|
|
812
821
|
visitExprAggregate(pcx) {
|
|
813
822
|
const pathCx = pcx.fieldPath();
|
|
814
|
-
const path = pathCx
|
|
823
|
+
const path = pathCx
|
|
824
|
+
? this.getFieldPath(pathCx, ast.ExpressionFieldReference)
|
|
825
|
+
: undefined;
|
|
815
826
|
const source = pathCx && path ? this.astAt(path, pathCx) : undefined;
|
|
816
827
|
const exprDef = pcx.fieldExpr();
|
|
817
828
|
if (pcx.aggregate().COUNT()) {
|
|
@@ -891,9 +902,37 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
891
902
|
const units = this.visitTimeframe(pcx.timeframe());
|
|
892
903
|
return new ast.ForRange(begin, duration, units);
|
|
893
904
|
}
|
|
905
|
+
visitExprAggFunc(pcx) {
|
|
906
|
+
const argsCx = pcx.argumentList();
|
|
907
|
+
const args = argsCx ? this.allFieldExpressions(argsCx.fieldExpr()) : [];
|
|
908
|
+
const idCx = pcx.id();
|
|
909
|
+
const fn = this.getIdText(idCx);
|
|
910
|
+
const pathCx = pcx.fieldPath();
|
|
911
|
+
const path = pathCx
|
|
912
|
+
? this.getFieldPath(pathCx, ast.ExpressionFieldReference)
|
|
913
|
+
: undefined;
|
|
914
|
+
const source = pathCx && path ? this.astAt(path, pathCx) : undefined;
|
|
915
|
+
if (ast.ExprTimeExtract.extractor(fn)) {
|
|
916
|
+
return this.astAt(new ast.ExprTimeExtract(fn, args), pcx);
|
|
917
|
+
}
|
|
918
|
+
return this.astAt(new ast.ExprFunc(fn, args, false, undefined, source), pcx);
|
|
919
|
+
}
|
|
894
920
|
visitExprFunc(pcx) {
|
|
921
|
+
var _a;
|
|
895
922
|
const argsCx = pcx.argumentList();
|
|
896
923
|
const args = argsCx ? this.allFieldExpressions(argsCx.fieldExpr()) : [];
|
|
924
|
+
const isRaw = pcx.EXCLAM() !== undefined;
|
|
925
|
+
const rawRawType = (_a = pcx.malloyType()) === null || _a === void 0 ? void 0 : _a.text;
|
|
926
|
+
let rawType = undefined;
|
|
927
|
+
if (rawRawType) {
|
|
928
|
+
if (ast.isCastType(rawRawType)) {
|
|
929
|
+
rawType = rawRawType;
|
|
930
|
+
}
|
|
931
|
+
else {
|
|
932
|
+
this.contextError(pcx, `'#' assertion for unknown type '${rawRawType}'`);
|
|
933
|
+
rawType = undefined;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
897
936
|
const idCx = pcx.id();
|
|
898
937
|
const dCx = pcx.timeframe();
|
|
899
938
|
let fn;
|
|
@@ -910,7 +949,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
910
949
|
if (ast.ExprTimeExtract.extractor(fn)) {
|
|
911
950
|
return this.astAt(new ast.ExprTimeExtract(fn, args), pcx);
|
|
912
951
|
}
|
|
913
|
-
return this.astAt(new ast.ExprFunc(fn, args), pcx);
|
|
952
|
+
return this.astAt(new ast.ExprFunc(fn, args, isRaw, rawType), pcx);
|
|
914
953
|
}
|
|
915
954
|
visitExprDuration(pcx) {
|
|
916
955
|
return new ast.ExprDuration(this.getFieldExpr(pcx.fieldExpr()), this.visitTimeframe(pcx.timeframe()).text);
|
|
@@ -118,10 +118,13 @@ class DocumentSymbolWalker {
|
|
|
118
118
|
parent.children.push(symbol);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
enterQueryFieldEntry(pcx) {
|
|
122
|
+
const fieldRef = pcx.fieldPath();
|
|
123
|
+
if (fieldRef === undefined)
|
|
124
|
+
return;
|
|
122
125
|
const symbol = {
|
|
123
126
|
range: this.translator.rangeFromContext(pcx),
|
|
124
|
-
name:
|
|
127
|
+
name: fieldRef.text,
|
|
125
128
|
type: 'field',
|
|
126
129
|
children: [],
|
|
127
130
|
};
|