@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
package/dist/lang/ast/index.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export * from './query-elements/full-query';
|
|
|
58
58
|
export * from './query-items/field-declaration';
|
|
59
59
|
export * from './query-items/field-references';
|
|
60
60
|
export * from './query-properties/aggregate';
|
|
61
|
+
export * from './query-properties/calculate';
|
|
61
62
|
export * from './query-properties/declare-fields';
|
|
62
63
|
export * from './query-properties/dimmensions';
|
|
63
64
|
export * from './query-properties/filters';
|
package/dist/lang/ast/index.js
CHANGED
|
@@ -96,6 +96,7 @@ __exportStar(require("./query-elements/full-query"), exports);
|
|
|
96
96
|
__exportStar(require("./query-items/field-declaration"), exports);
|
|
97
97
|
__exportStar(require("./query-items/field-references"), exports);
|
|
98
98
|
__exportStar(require("./query-properties/aggregate"), exports);
|
|
99
|
+
__exportStar(require("./query-properties/calculate"), exports);
|
|
99
100
|
__exportStar(require("./query-properties/declare-fields"), exports);
|
|
100
101
|
__exportStar(require("./query-properties/dimmensions"), exports);
|
|
101
102
|
__exportStar(require("./query-properties/filters"), exports);
|
|
@@ -1,19 +1,51 @@
|
|
|
1
1
|
import { Dialect } from '../../../dialect/dialect';
|
|
2
2
|
import { FieldTypeDef, StructDef } from '../../../model/malloy_types';
|
|
3
|
+
import { ExprValue } from '../types/expr-value';
|
|
3
4
|
import { ExpressionDef } from '../types/expression-def';
|
|
4
|
-
import { FieldName, FieldSpace } from '../types/field-space';
|
|
5
|
+
import { FieldName, FieldSpace, QueryFieldSpace } from '../types/field-space';
|
|
5
6
|
import { LookupResult } from '../types/lookup-result';
|
|
6
7
|
import { MalloyElement } from '../types/malloy-element';
|
|
7
|
-
|
|
8
|
+
import { SpaceEntry } from '../types/space-entry';
|
|
9
|
+
export declare type FieldDeclarationConstructor = new (expr: ExpressionDef, defineName: string, exprSrc?: string) => FieldDeclaration;
|
|
10
|
+
export declare abstract class FieldDeclaration extends MalloyElement {
|
|
8
11
|
readonly expr: ExpressionDef;
|
|
9
12
|
readonly defineName: string;
|
|
10
13
|
readonly exprSrc?: string | undefined;
|
|
11
|
-
elementType: string;
|
|
12
|
-
isMeasure?: boolean;
|
|
13
14
|
constructor(expr: ExpressionDef, defineName: string, exprSrc?: string | undefined);
|
|
14
15
|
fieldDef(fs: FieldSpace, exprName: string): FieldTypeDef;
|
|
16
|
+
abstract typecheckExprValue(expr: ExprValue): void;
|
|
17
|
+
executesInOutputSpace(): boolean;
|
|
15
18
|
queryFieldDef(exprFS: FieldSpace, exprName: string): FieldTypeDef;
|
|
16
19
|
}
|
|
20
|
+
export declare class CalculateFieldDeclaration extends FieldDeclaration {
|
|
21
|
+
elementType: string;
|
|
22
|
+
typecheckExprValue(expr: ExprValue): void;
|
|
23
|
+
executesInOutputSpace(): boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare class AggregateFieldDeclaration extends FieldDeclaration {
|
|
26
|
+
elementType: string;
|
|
27
|
+
typecheckExprValue(expr: ExprValue): void;
|
|
28
|
+
}
|
|
29
|
+
export declare class GroupByFieldDeclaration extends FieldDeclaration {
|
|
30
|
+
elementType: string;
|
|
31
|
+
typecheckExprValue(expr: ExprValue): void;
|
|
32
|
+
}
|
|
33
|
+
export declare class ProjectFieldDeclaration extends FieldDeclaration {
|
|
34
|
+
elementType: string;
|
|
35
|
+
typecheckExprValue(expr: ExprValue): void;
|
|
36
|
+
}
|
|
37
|
+
export declare class DeclareFieldDeclaration extends FieldDeclaration {
|
|
38
|
+
elementType: string;
|
|
39
|
+
typecheckExprValue(expr: ExprValue): void;
|
|
40
|
+
}
|
|
41
|
+
export declare class MeasureFieldDeclaration extends FieldDeclaration {
|
|
42
|
+
elementType: string;
|
|
43
|
+
typecheckExprValue(expr: ExprValue): void;
|
|
44
|
+
}
|
|
45
|
+
export declare class DimensionFieldDeclaration extends FieldDeclaration {
|
|
46
|
+
elementType: string;
|
|
47
|
+
typecheckExprValue(expr: ExprValue): void;
|
|
48
|
+
}
|
|
17
49
|
/**
|
|
18
50
|
* Used to detect references to fields in the statement which defines them
|
|
19
51
|
*/
|
|
@@ -25,7 +57,11 @@ export declare class DefSpace implements FieldSpace {
|
|
|
25
57
|
constructor(realFS: FieldSpace, circular: FieldDeclaration);
|
|
26
58
|
structDef(): StructDef;
|
|
27
59
|
emptyStructDef(): StructDef;
|
|
60
|
+
entry(name: string): SpaceEntry | undefined;
|
|
28
61
|
lookup(symbol: FieldName[]): LookupResult;
|
|
62
|
+
entries(): [string, SpaceEntry][];
|
|
29
63
|
dialectObj(): Dialect | undefined;
|
|
30
64
|
whenComplete(step: () => void): void;
|
|
65
|
+
isQueryFieldSpace(): this is QueryFieldSpace;
|
|
66
|
+
outputSpace(): FieldSpace;
|
|
31
67
|
}
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.DefSpace = exports.FieldDeclaration = void 0;
|
|
25
|
+
exports.DefSpace = exports.DimensionFieldDeclaration = exports.MeasureFieldDeclaration = exports.DeclareFieldDeclaration = exports.ProjectFieldDeclaration = exports.GroupByFieldDeclaration = exports.AggregateFieldDeclaration = exports.CalculateFieldDeclaration = exports.FieldDeclaration = void 0;
|
|
26
26
|
const malloy_types_1 = require("../../../model/malloy_types");
|
|
27
27
|
const utils_1 = require("../expressions/utils");
|
|
28
28
|
const fragtype_utils_1 = require("../fragtype-utils");
|
|
29
29
|
const granular_result_1 = require("../types/granular-result");
|
|
30
30
|
const malloy_element_1 = require("../types/malloy-element");
|
|
31
|
+
const typecheck_utils_1 = require("./typecheck_utils");
|
|
31
32
|
class FieldDeclaration extends malloy_element_1.MalloyElement {
|
|
32
33
|
constructor(expr, defineName, exprSrc) {
|
|
33
34
|
super({ expr: expr });
|
|
34
35
|
this.expr = expr;
|
|
35
36
|
this.defineName = defineName;
|
|
36
37
|
this.exprSrc = exprSrc;
|
|
37
|
-
this.elementType = 'fieldDeclaration';
|
|
38
38
|
}
|
|
39
39
|
fieldDef(fs, exprName) {
|
|
40
40
|
/*
|
|
@@ -48,10 +48,20 @@ class FieldDeclaration extends malloy_element_1.MalloyElement {
|
|
|
48
48
|
*/
|
|
49
49
|
return this.queryFieldDef(new DefSpace(fs, this), exprName);
|
|
50
50
|
}
|
|
51
|
+
executesInOutputSpace() {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
51
54
|
queryFieldDef(exprFS, exprName) {
|
|
52
55
|
let exprValue;
|
|
56
|
+
function getOutputFS() {
|
|
57
|
+
if (exprFS.isQueryFieldSpace()) {
|
|
58
|
+
return exprFS.outputSpace();
|
|
59
|
+
}
|
|
60
|
+
throw new Error('must be in a query -- weird internal error');
|
|
61
|
+
}
|
|
53
62
|
try {
|
|
54
|
-
|
|
63
|
+
const fs = this.executesInOutputSpace() ? getOutputFS() : exprFS;
|
|
64
|
+
exprValue = this.expr.getExpression(fs);
|
|
55
65
|
}
|
|
56
66
|
catch (error) {
|
|
57
67
|
this.log(`Cannot define '${exprName}', ${error.message}`);
|
|
@@ -74,6 +84,7 @@ class FieldDeclaration extends malloy_element_1.MalloyElement {
|
|
|
74
84
|
if (exprValue.expressionType) {
|
|
75
85
|
template.expressionType = exprValue.expressionType;
|
|
76
86
|
}
|
|
87
|
+
this.typecheckExprValue(exprValue);
|
|
77
88
|
if (this.exprSrc) {
|
|
78
89
|
template.code = this.exprSrc;
|
|
79
90
|
}
|
|
@@ -100,6 +111,79 @@ class FieldDeclaration extends malloy_element_1.MalloyElement {
|
|
|
100
111
|
}
|
|
101
112
|
}
|
|
102
113
|
exports.FieldDeclaration = FieldDeclaration;
|
|
114
|
+
class CalculateFieldDeclaration extends FieldDeclaration {
|
|
115
|
+
constructor() {
|
|
116
|
+
super(...arguments);
|
|
117
|
+
this.elementType = 'calculateFieldDeclaration';
|
|
118
|
+
}
|
|
119
|
+
typecheckExprValue(expr) {
|
|
120
|
+
(0, typecheck_utils_1.typecheckCalculate)(expr, this);
|
|
121
|
+
}
|
|
122
|
+
executesInOutputSpace() {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.CalculateFieldDeclaration = CalculateFieldDeclaration;
|
|
127
|
+
class AggregateFieldDeclaration extends FieldDeclaration {
|
|
128
|
+
constructor() {
|
|
129
|
+
super(...arguments);
|
|
130
|
+
this.elementType = 'aggregateFieldDeclaration';
|
|
131
|
+
}
|
|
132
|
+
typecheckExprValue(expr) {
|
|
133
|
+
(0, typecheck_utils_1.typecheckAggregate)(expr, this);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.AggregateFieldDeclaration = AggregateFieldDeclaration;
|
|
137
|
+
class GroupByFieldDeclaration extends FieldDeclaration {
|
|
138
|
+
constructor() {
|
|
139
|
+
super(...arguments);
|
|
140
|
+
this.elementType = 'groupByFieldDeclaration';
|
|
141
|
+
}
|
|
142
|
+
typecheckExprValue(expr) {
|
|
143
|
+
(0, typecheck_utils_1.typecheckGroupBy)(expr, this);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.GroupByFieldDeclaration = GroupByFieldDeclaration;
|
|
147
|
+
class ProjectFieldDeclaration extends FieldDeclaration {
|
|
148
|
+
constructor() {
|
|
149
|
+
super(...arguments);
|
|
150
|
+
this.elementType = 'projectFieldDeclaration';
|
|
151
|
+
}
|
|
152
|
+
typecheckExprValue(expr) {
|
|
153
|
+
(0, typecheck_utils_1.typecheckProject)(expr, this);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.ProjectFieldDeclaration = ProjectFieldDeclaration;
|
|
157
|
+
class DeclareFieldDeclaration extends FieldDeclaration {
|
|
158
|
+
constructor() {
|
|
159
|
+
super(...arguments);
|
|
160
|
+
this.elementType = 'declareFieldDeclaration';
|
|
161
|
+
}
|
|
162
|
+
typecheckExprValue(expr) {
|
|
163
|
+
(0, typecheck_utils_1.typecheckDeclare)(expr, this);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.DeclareFieldDeclaration = DeclareFieldDeclaration;
|
|
167
|
+
class MeasureFieldDeclaration extends FieldDeclaration {
|
|
168
|
+
constructor() {
|
|
169
|
+
super(...arguments);
|
|
170
|
+
this.elementType = 'measureFieldDeclaration';
|
|
171
|
+
}
|
|
172
|
+
typecheckExprValue(expr) {
|
|
173
|
+
(0, typecheck_utils_1.typecheckMeasure)(expr, this);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
exports.MeasureFieldDeclaration = MeasureFieldDeclaration;
|
|
177
|
+
class DimensionFieldDeclaration extends FieldDeclaration {
|
|
178
|
+
constructor() {
|
|
179
|
+
super(...arguments);
|
|
180
|
+
this.elementType = 'dimensionFieldDeclaration';
|
|
181
|
+
}
|
|
182
|
+
typecheckExprValue(expr) {
|
|
183
|
+
(0, typecheck_utils_1.typecheckDimension)(expr, this);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
exports.DimensionFieldDeclaration = DimensionFieldDeclaration;
|
|
103
187
|
/**
|
|
104
188
|
* Used to detect references to fields in the statement which defines them
|
|
105
189
|
*/
|
|
@@ -116,6 +200,9 @@ class DefSpace {
|
|
|
116
200
|
emptyStructDef() {
|
|
117
201
|
return this.realFS.emptyStructDef();
|
|
118
202
|
}
|
|
203
|
+
entry(name) {
|
|
204
|
+
return this.realFS.entry(name);
|
|
205
|
+
}
|
|
119
206
|
lookup(symbol) {
|
|
120
207
|
if (symbol[0] && symbol[0].refString === this.circular.defineName) {
|
|
121
208
|
this.foundCircle = true;
|
|
@@ -126,12 +213,24 @@ class DefSpace {
|
|
|
126
213
|
}
|
|
127
214
|
return this.realFS.lookup(symbol);
|
|
128
215
|
}
|
|
216
|
+
entries() {
|
|
217
|
+
return this.realFS.entries();
|
|
218
|
+
}
|
|
129
219
|
dialectObj() {
|
|
130
220
|
return this.realFS.dialectObj();
|
|
131
221
|
}
|
|
132
222
|
whenComplete(step) {
|
|
133
223
|
this.realFS.whenComplete(step);
|
|
134
224
|
}
|
|
225
|
+
isQueryFieldSpace() {
|
|
226
|
+
return this.realFS.isQueryFieldSpace();
|
|
227
|
+
}
|
|
228
|
+
outputSpace() {
|
|
229
|
+
if (this.realFS.isQueryFieldSpace()) {
|
|
230
|
+
return this.realFS.outputSpace();
|
|
231
|
+
}
|
|
232
|
+
throw new Error('Not a query field space');
|
|
233
|
+
}
|
|
135
234
|
}
|
|
136
235
|
exports.DefSpace = DefSpace;
|
|
137
236
|
//# sourceMappingURL=field-declaration.js.map
|
|
@@ -1,16 +1,58 @@
|
|
|
1
|
-
import { FieldDef } from '../../../model/malloy_types';
|
|
1
|
+
import { FieldDef, TypeDesc } from '../../../model/malloy_types';
|
|
2
2
|
import { FieldName, FieldSpace } from '../types/field-space';
|
|
3
3
|
import { LookupResult } from '../types/lookup-result';
|
|
4
4
|
import { ListOf, MalloyElement } from '../types/malloy-element';
|
|
5
|
-
export declare
|
|
5
|
+
export declare type FieldReferenceConstructor = new (names: FieldName[]) => FieldReference;
|
|
6
|
+
export declare abstract class FieldReference extends ListOf<FieldName> {
|
|
6
7
|
elementType: string;
|
|
7
8
|
constructor(names: FieldName[]);
|
|
8
9
|
get refString(): string;
|
|
9
10
|
get outputName(): string;
|
|
10
11
|
get sourceString(): string | undefined;
|
|
11
12
|
get nameString(): string;
|
|
13
|
+
abstract typecheck(type: TypeDesc): any;
|
|
12
14
|
getField(fs: FieldSpace): LookupResult;
|
|
13
15
|
}
|
|
16
|
+
export declare class AcceptExceptFieldReference extends FieldReference {
|
|
17
|
+
elementType: string;
|
|
18
|
+
typecheck(): void;
|
|
19
|
+
}
|
|
20
|
+
export declare class ExpressionFieldReference extends FieldReference {
|
|
21
|
+
elementType: string;
|
|
22
|
+
typecheck(): void;
|
|
23
|
+
}
|
|
24
|
+
export declare class CalculateFieldReference extends FieldReference {
|
|
25
|
+
elementType: string;
|
|
26
|
+
typecheck(type: TypeDesc): void;
|
|
27
|
+
}
|
|
28
|
+
export declare class IndexFieldReference extends FieldReference {
|
|
29
|
+
elementType: string;
|
|
30
|
+
typecheck(type: TypeDesc): void;
|
|
31
|
+
}
|
|
32
|
+
export declare class AggregateFieldReference extends FieldReference {
|
|
33
|
+
elementType: string;
|
|
34
|
+
typecheck(type: TypeDesc): void;
|
|
35
|
+
}
|
|
36
|
+
export declare class GroupByFieldReference extends FieldReference {
|
|
37
|
+
elementType: string;
|
|
38
|
+
typecheck(type: TypeDesc): void;
|
|
39
|
+
}
|
|
40
|
+
export declare class ProjectFieldReference extends FieldReference {
|
|
41
|
+
elementType: string;
|
|
42
|
+
typecheck(type: TypeDesc): void;
|
|
43
|
+
}
|
|
44
|
+
export declare class DeclareFieldReference extends FieldReference {
|
|
45
|
+
elementType: string;
|
|
46
|
+
typecheck(type: TypeDesc): void;
|
|
47
|
+
}
|
|
48
|
+
export declare class MeasureFieldReference extends FieldReference {
|
|
49
|
+
elementType: string;
|
|
50
|
+
typecheck(type: TypeDesc): void;
|
|
51
|
+
}
|
|
52
|
+
export declare class DimensionFieldReference extends FieldReference {
|
|
53
|
+
elementType: string;
|
|
54
|
+
typecheck(type: TypeDesc): void;
|
|
55
|
+
}
|
|
14
56
|
export declare class WildcardFieldReference extends MalloyElement {
|
|
15
57
|
readonly joinPath: FieldReference | undefined;
|
|
16
58
|
readonly star: '*' | '**';
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.FieldReferences = exports.WildcardFieldReference = exports.FieldReference = void 0;
|
|
25
|
+
exports.FieldReferences = exports.WildcardFieldReference = exports.DimensionFieldReference = exports.MeasureFieldReference = exports.DeclareFieldReference = exports.ProjectFieldReference = exports.GroupByFieldReference = exports.AggregateFieldReference = exports.IndexFieldReference = exports.CalculateFieldReference = exports.ExpressionFieldReference = exports.AcceptExceptFieldReference = exports.FieldReference = void 0;
|
|
26
26
|
const malloy_element_1 = require("../types/malloy-element");
|
|
27
|
+
const typecheck_utils_1 = require("./typecheck_utils");
|
|
27
28
|
class FieldReference extends malloy_element_1.ListOf {
|
|
28
29
|
constructor(names) {
|
|
29
30
|
super('fieldReference', names);
|
|
@@ -49,10 +50,117 @@ class FieldReference extends malloy_element_1.ListOf {
|
|
|
49
50
|
return this.list[this.list.length - 1].refString;
|
|
50
51
|
}
|
|
51
52
|
getField(fs) {
|
|
52
|
-
|
|
53
|
+
const result = fs.lookup(this.list);
|
|
54
|
+
if (result.found) {
|
|
55
|
+
const actualType = result.found.typeDesc();
|
|
56
|
+
this.typecheck(actualType);
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
exports.FieldReference = FieldReference;
|
|
62
|
+
class AcceptExceptFieldReference extends FieldReference {
|
|
63
|
+
constructor() {
|
|
64
|
+
super(...arguments);
|
|
65
|
+
this.elementType = 'acceptExceptFieldReference';
|
|
66
|
+
}
|
|
67
|
+
// Nothing to typecheck here
|
|
68
|
+
typecheck() {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.AcceptExceptFieldReference = AcceptExceptFieldReference;
|
|
73
|
+
class ExpressionFieldReference extends FieldReference {
|
|
74
|
+
constructor() {
|
|
75
|
+
super(...arguments);
|
|
76
|
+
this.elementType = 'expressionFieldReference';
|
|
77
|
+
}
|
|
78
|
+
// We assume that the outer expression will typecheck this
|
|
79
|
+
typecheck() {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.ExpressionFieldReference = ExpressionFieldReference;
|
|
84
|
+
class CalculateFieldReference extends FieldReference {
|
|
85
|
+
constructor() {
|
|
86
|
+
super(...arguments);
|
|
87
|
+
this.elementType = 'calculateFieldReference';
|
|
88
|
+
}
|
|
89
|
+
typecheck(type) {
|
|
90
|
+
(0, typecheck_utils_1.typecheckCalculate)(type, this);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.CalculateFieldReference = CalculateFieldReference;
|
|
94
|
+
class IndexFieldReference extends FieldReference {
|
|
95
|
+
constructor() {
|
|
96
|
+
super(...arguments);
|
|
97
|
+
this.elementType = 'indexFieldReference';
|
|
98
|
+
}
|
|
99
|
+
typecheck(type) {
|
|
100
|
+
(0, typecheck_utils_1.typecheckIndex)(type, this);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.IndexFieldReference = IndexFieldReference;
|
|
104
|
+
class AggregateFieldReference extends FieldReference {
|
|
105
|
+
constructor() {
|
|
106
|
+
super(...arguments);
|
|
107
|
+
this.elementType = 'aggregateFieldReference';
|
|
108
|
+
}
|
|
109
|
+
typecheck(type) {
|
|
110
|
+
(0, typecheck_utils_1.typecheckAggregate)(type, this);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.AggregateFieldReference = AggregateFieldReference;
|
|
114
|
+
class GroupByFieldReference extends FieldReference {
|
|
115
|
+
constructor() {
|
|
116
|
+
super(...arguments);
|
|
117
|
+
this.elementType = 'groupByFieldReference';
|
|
118
|
+
}
|
|
119
|
+
typecheck(type) {
|
|
120
|
+
(0, typecheck_utils_1.typecheckGroupBy)(type, this);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.GroupByFieldReference = GroupByFieldReference;
|
|
124
|
+
class ProjectFieldReference extends FieldReference {
|
|
125
|
+
constructor() {
|
|
126
|
+
super(...arguments);
|
|
127
|
+
this.elementType = 'projectFieldReference';
|
|
128
|
+
}
|
|
129
|
+
typecheck(type) {
|
|
130
|
+
(0, typecheck_utils_1.typecheckProject)(type, this);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.ProjectFieldReference = ProjectFieldReference;
|
|
134
|
+
class DeclareFieldReference extends FieldReference {
|
|
135
|
+
constructor() {
|
|
136
|
+
super(...arguments);
|
|
137
|
+
this.elementType = 'declareFieldReference';
|
|
138
|
+
}
|
|
139
|
+
typecheck(type) {
|
|
140
|
+
(0, typecheck_utils_1.typecheckDeclare)(type, this);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.DeclareFieldReference = DeclareFieldReference;
|
|
144
|
+
class MeasureFieldReference extends FieldReference {
|
|
145
|
+
constructor() {
|
|
146
|
+
super(...arguments);
|
|
147
|
+
this.elementType = 'measureFieldReference';
|
|
148
|
+
}
|
|
149
|
+
typecheck(type) {
|
|
150
|
+
(0, typecheck_utils_1.typecheckMeasure)(type, this);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.MeasureFieldReference = MeasureFieldReference;
|
|
154
|
+
class DimensionFieldReference extends FieldReference {
|
|
155
|
+
constructor() {
|
|
156
|
+
super(...arguments);
|
|
157
|
+
this.elementType = 'dimensionFieldReference';
|
|
158
|
+
}
|
|
159
|
+
typecheck(type) {
|
|
160
|
+
(0, typecheck_utils_1.typecheckDimension)(type, this);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
exports.DimensionFieldReference = DimensionFieldReference;
|
|
56
164
|
class WildcardFieldReference extends malloy_element_1.MalloyElement {
|
|
57
165
|
constructor(joinPath, star) {
|
|
58
166
|
super();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TypeDesc } from '../../../model';
|
|
2
|
+
import { MalloyElement } from '../types/malloy-element';
|
|
3
|
+
export declare function typecheckProject(type: TypeDesc, logTo: MalloyElement): void;
|
|
4
|
+
export declare function typecheckIndex(type: TypeDesc, logTo: MalloyElement): void;
|
|
5
|
+
export declare function typecheckDimension(type: TypeDesc, logTo: MalloyElement): void;
|
|
6
|
+
export declare function typecheckMeasure(type: TypeDesc, logTo: MalloyElement): void;
|
|
7
|
+
export declare function typecheckDeclare(type: TypeDesc, logTo: MalloyElement): void;
|
|
8
|
+
export declare function typecheckCalculate(type: TypeDesc, logTo: MalloyElement): void;
|
|
9
|
+
export declare function typecheckAggregate(type: TypeDesc, logTo: MalloyElement): void;
|
|
10
|
+
export declare function typecheckGroupBy(type: TypeDesc, logTo: MalloyElement): void;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
* a copy of this software and associated documentation files
|
|
7
|
+
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
+
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
* subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be
|
|
14
|
+
* included in all copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.typecheckGroupBy = exports.typecheckAggregate = exports.typecheckCalculate = exports.typecheckDeclare = exports.typecheckMeasure = exports.typecheckDimension = exports.typecheckIndex = exports.typecheckProject = void 0;
|
|
26
|
+
const model_1 = require("../../../model");
|
|
27
|
+
function typecheckProject(type, logTo) {
|
|
28
|
+
if (type.dataType === 'turtle' || !(0, model_1.expressionIsScalar)(type.expressionType)) {
|
|
29
|
+
let useInstead;
|
|
30
|
+
let kind;
|
|
31
|
+
if (type.dataType === 'turtle') {
|
|
32
|
+
useInstead = 'a nest';
|
|
33
|
+
kind = 'a query';
|
|
34
|
+
}
|
|
35
|
+
else if ((0, model_1.expressionIsAnalytic)(type.expressionType)) {
|
|
36
|
+
useInstead = 'a calculate';
|
|
37
|
+
kind = 'an analytic';
|
|
38
|
+
}
|
|
39
|
+
else if ((0, model_1.expressionIsAggregate)(type.expressionType)) {
|
|
40
|
+
useInstead = 'an aggregate';
|
|
41
|
+
kind = 'an aggregate';
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
throw new Error(`Unexpected expression type ${type.expressionType} not handled here`);
|
|
45
|
+
}
|
|
46
|
+
logTo.log(`Cannot use ${kind} field in a project operation, did you mean to use ${useInstead} operation instead?`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.typecheckProject = typecheckProject;
|
|
50
|
+
function typecheckIndex(type, logTo) {
|
|
51
|
+
if (type.dataType === 'turtle' || !(0, model_1.expressionIsScalar)(type.expressionType)) {
|
|
52
|
+
let kind;
|
|
53
|
+
if (type.dataType === 'turtle') {
|
|
54
|
+
kind = 'a query';
|
|
55
|
+
}
|
|
56
|
+
else if ((0, model_1.expressionIsAnalytic)(type.expressionType)) {
|
|
57
|
+
kind = 'an analytic';
|
|
58
|
+
}
|
|
59
|
+
else if ((0, model_1.expressionIsAggregate)(type.expressionType)) {
|
|
60
|
+
kind = 'an aggregate';
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
throw new Error(`Unexpected expression type ${type.expressionType} not handled here`);
|
|
64
|
+
}
|
|
65
|
+
logTo.log(`Cannot use ${kind} field in an index operation`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.typecheckIndex = typecheckIndex;
|
|
69
|
+
function typecheckDimension(type, logTo) {
|
|
70
|
+
if (!(0, model_1.expressionIsScalar)(type.expressionType)) {
|
|
71
|
+
if ((0, model_1.expressionIsAggregate)(type.expressionType)) {
|
|
72
|
+
logTo.log('Cannot use an aggregate field in a dimension declaration, did you mean to use a measure declaration instead?');
|
|
73
|
+
}
|
|
74
|
+
else if ((0, model_1.expressionIsAnalytic)(type.expressionType)) {
|
|
75
|
+
logTo.log('Cannot use an analytic field in a dimension declaration');
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
throw new Error(`Unexpected expression type ${type.expressionType} not handled here`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.typecheckDimension = typecheckDimension;
|
|
83
|
+
function typecheckMeasure(type, logTo) {
|
|
84
|
+
if (!(0, model_1.expressionIsAggregate)(type.expressionType)) {
|
|
85
|
+
if ((0, model_1.expressionIsScalar)(type.expressionType)) {
|
|
86
|
+
logTo.log('Cannot use a scalar field in a measure declaration, did you mean to use a dimension declaration instead?');
|
|
87
|
+
}
|
|
88
|
+
else if ((0, model_1.expressionIsAnalytic)(type.expressionType)) {
|
|
89
|
+
logTo.log('Cannot use an analytic field in a measure declaration');
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
throw new Error(`Unexpected expression type ${type.expressionType} not handled here`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.typecheckMeasure = typecheckMeasure;
|
|
97
|
+
function typecheckDeclare(type, logTo) {
|
|
98
|
+
if (type.dataType === 'turtle') {
|
|
99
|
+
logTo.log('Query fields cannot be used in a declare block');
|
|
100
|
+
}
|
|
101
|
+
else if ((0, model_1.expressionIsAnalytic)(type.expressionType)) {
|
|
102
|
+
logTo.log('Analytic expressions can not be used in a declare block');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.typecheckDeclare = typecheckDeclare;
|
|
106
|
+
function typecheckCalculate(type, logTo) {
|
|
107
|
+
if (type.dataType === 'turtle' ||
|
|
108
|
+
!(0, model_1.expressionIsAnalytic)(type.expressionType)) {
|
|
109
|
+
let useInstead;
|
|
110
|
+
let kind;
|
|
111
|
+
if (type.dataType === 'turtle') {
|
|
112
|
+
useInstead = 'a nest';
|
|
113
|
+
kind = 'a query';
|
|
114
|
+
}
|
|
115
|
+
else if ((0, model_1.expressionIsAggregate)(type.expressionType)) {
|
|
116
|
+
useInstead = 'an aggregate';
|
|
117
|
+
kind = 'an aggregate';
|
|
118
|
+
}
|
|
119
|
+
else if ((0, model_1.expressionIsScalar)(type.expressionType)) {
|
|
120
|
+
useInstead = 'a group_by or project';
|
|
121
|
+
kind = 'a scalar';
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
throw new Error(`Unexpected expression type ${type.expressionType} not handled here`);
|
|
125
|
+
}
|
|
126
|
+
logTo.log(`Cannot use ${kind} field in a calculate operation, did you mean to use ${useInstead} operation instead?`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.typecheckCalculate = typecheckCalculate;
|
|
130
|
+
function typecheckAggregate(type, logTo) {
|
|
131
|
+
if (type.dataType === 'turtle' ||
|
|
132
|
+
!(0, model_1.expressionIsAggregate)(type.expressionType)) {
|
|
133
|
+
let useInstead;
|
|
134
|
+
let kind;
|
|
135
|
+
if (type.dataType === 'turtle') {
|
|
136
|
+
useInstead = 'a nest';
|
|
137
|
+
kind = 'a query';
|
|
138
|
+
}
|
|
139
|
+
else if ((0, model_1.expressionIsAnalytic)(type.expressionType)) {
|
|
140
|
+
useInstead = 'a calculate';
|
|
141
|
+
kind = 'an analytic';
|
|
142
|
+
}
|
|
143
|
+
else if ((0, model_1.expressionIsScalar)(type.expressionType)) {
|
|
144
|
+
useInstead = 'a group_by or project';
|
|
145
|
+
kind = 'a scalar';
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
throw new Error(`Unexpected expression type ${type} not handled here`);
|
|
149
|
+
}
|
|
150
|
+
logTo.log(`Cannot use ${kind} field in an aggregate operation, did you mean to use ${useInstead} operation instead?`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.typecheckAggregate = typecheckAggregate;
|
|
154
|
+
function typecheckGroupBy(type, logTo) {
|
|
155
|
+
if (type.dataType === 'turtle' || !(0, model_1.expressionIsScalar)(type.expressionType)) {
|
|
156
|
+
let useInstead;
|
|
157
|
+
let kind;
|
|
158
|
+
if (type.dataType === 'turtle') {
|
|
159
|
+
useInstead = 'a nest';
|
|
160
|
+
kind = 'a query';
|
|
161
|
+
}
|
|
162
|
+
else if ((0, model_1.expressionIsAnalytic)(type.expressionType)) {
|
|
163
|
+
useInstead = 'a calculate';
|
|
164
|
+
kind = 'an analytic';
|
|
165
|
+
}
|
|
166
|
+
else if ((0, model_1.expressionIsAggregate)(type.expressionType)) {
|
|
167
|
+
useInstead = 'an aggregate';
|
|
168
|
+
kind = 'an aggregate';
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
throw new Error(`Unexpected expression type ${type.expressionType} not handled here`);
|
|
172
|
+
}
|
|
173
|
+
logTo.log(`Cannot use ${kind} field in a group_by operation, did you mean to use ${useInstead} operation instead?`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
exports.typecheckGroupBy = typecheckGroupBy;
|
|
177
|
+
//# sourceMappingURL=typecheck_utils.js.map
|
|
@@ -23,16 +23,10 @@
|
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.Aggregate = void 0;
|
|
26
|
-
const field_declaration_1 = require("../query-items/field-declaration");
|
|
27
26
|
const malloy_element_1 = require("../types/malloy-element");
|
|
28
27
|
class Aggregate extends malloy_element_1.ListOf {
|
|
29
28
|
constructor(members) {
|
|
30
29
|
super('aggregate', members);
|
|
31
|
-
for (const el of members) {
|
|
32
|
-
if (el instanceof field_declaration_1.FieldDeclaration) {
|
|
33
|
-
el.isMeasure = true;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
30
|
}
|
|
37
31
|
}
|
|
38
32
|
exports.Aggregate = Aggregate;
|