@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
|
@@ -62,12 +62,14 @@ class Pick extends expression_def_1.ExpressionDef {
|
|
|
62
62
|
const caseValue = ['CASE'];
|
|
63
63
|
let returnType;
|
|
64
64
|
let anyExpressionType = 'scalar';
|
|
65
|
+
let anyEvalSpace = 'constant';
|
|
65
66
|
for (const choice of this.choices) {
|
|
66
67
|
const whenExpr = choice.when.apply(fs, '=', expr);
|
|
67
68
|
const thenExpr = choice.pick
|
|
68
69
|
? choice.pick.getExpression(fs)
|
|
69
70
|
: expr.getExpression(fs);
|
|
70
71
|
anyExpressionType = (0, malloy_types_1.maxExpressionType)(anyExpressionType, (0, malloy_types_1.maxExpressionType)(whenExpr.expressionType, thenExpr.expressionType));
|
|
72
|
+
anyEvalSpace = (0, malloy_types_1.mergeEvalSpaces)(anyEvalSpace, whenExpr.evalSpace, thenExpr.evalSpace);
|
|
71
73
|
if (returnType && !fragtype_utils_1.FT.typeEq(returnType, thenExpr, true)) {
|
|
72
74
|
const whenType = fragtype_utils_1.FT.inspect(thenExpr);
|
|
73
75
|
this.log(`pick type '${whenType}', expected '${returnType.dataType}'`);
|
|
@@ -87,6 +89,7 @@ class Pick extends expression_def_1.ExpressionDef {
|
|
|
87
89
|
return {
|
|
88
90
|
dataType: returnType.dataType,
|
|
89
91
|
expressionType: (0, malloy_types_1.maxExpressionType)(anyExpressionType, elseVal.expressionType),
|
|
92
|
+
evalSpace: (0, malloy_types_1.mergeEvalSpaces)(anyEvalSpace, elseVal.evalSpace),
|
|
90
93
|
value: (0, utils_1.compressExpr)([...caseValue, ' ELSE ', ...elseVal.value, ' END']),
|
|
91
94
|
};
|
|
92
95
|
}
|
|
@@ -114,6 +117,7 @@ class Pick extends expression_def_1.ExpressionDef {
|
|
|
114
117
|
let returnType;
|
|
115
118
|
const caseValue = ['CASE'];
|
|
116
119
|
let anyExpressionType = 'scalar';
|
|
120
|
+
let anyEvalSpace = 'constant';
|
|
117
121
|
for (const aChoice of choiceValues) {
|
|
118
122
|
if (!fragtype_utils_1.FT.typeEq(aChoice.when, fragtype_utils_1.FT.boolT)) {
|
|
119
123
|
this.log(`when expression must be boolean, not '${fragtype_utils_1.FT.inspect(aChoice.when)}`);
|
|
@@ -126,10 +130,12 @@ class Pick extends expression_def_1.ExpressionDef {
|
|
|
126
130
|
}
|
|
127
131
|
returnType = typeCoalesce(returnType, aChoice.pick);
|
|
128
132
|
anyExpressionType = (0, malloy_types_1.maxExpressionType)(anyExpressionType, (0, malloy_types_1.maxExpressionType)(aChoice.pick.expressionType, aChoice.when.expressionType));
|
|
133
|
+
anyEvalSpace = (0, malloy_types_1.mergeEvalSpaces)(anyEvalSpace, aChoice.pick.evalSpace, aChoice.when.evalSpace);
|
|
129
134
|
caseValue.push(' WHEN ', ...aChoice.when.value, ' THEN ', ...aChoice.pick.value);
|
|
130
135
|
}
|
|
131
136
|
const defVal = this.elsePick.getExpression(fs);
|
|
132
137
|
anyExpressionType = (0, malloy_types_1.maxExpressionType)(anyExpressionType, defVal.expressionType);
|
|
138
|
+
anyEvalSpace = (0, malloy_types_1.mergeEvalSpaces)(anyEvalSpace, defVal.evalSpace);
|
|
133
139
|
returnType = typeCoalesce(returnType, defVal);
|
|
134
140
|
if (!fragtype_utils_1.FT.typeEq(returnType, defVal, true)) {
|
|
135
141
|
this.elsePick.log(`else type '${fragtype_utils_1.FT.inspect(defVal)}', expected '${returnType.dataType}'`);
|
|
@@ -140,6 +146,7 @@ class Pick extends expression_def_1.ExpressionDef {
|
|
|
140
146
|
dataType: returnType.dataType,
|
|
141
147
|
expressionType: anyExpressionType,
|
|
142
148
|
value: (0, utils_1.compressExpr)(caseValue),
|
|
149
|
+
evalSpace: anyEvalSpace,
|
|
143
150
|
};
|
|
144
151
|
}
|
|
145
152
|
}
|
|
@@ -46,6 +46,7 @@ class Range extends expression_def_1.ExpressionDef {
|
|
|
46
46
|
return {
|
|
47
47
|
dataType: 'boolean',
|
|
48
48
|
expressionType: (0, malloy_types_1.maxExpressionType)(fromValue.expressionType, toValue.expressionType),
|
|
49
|
+
evalSpace: (0, malloy_types_1.mergeEvalSpaces)(fromValue.evalSpace, toValue.evalSpace),
|
|
49
50
|
value: (0, utils_1.compose)(fromValue.value, op2, toValue.value),
|
|
50
51
|
};
|
|
51
52
|
}
|
|
@@ -85,9 +85,15 @@ class TimeLiteral extends expression_def_1.ExpressionDef {
|
|
|
85
85
|
const expressionType = 'scalar';
|
|
86
86
|
const value = [timeFrag];
|
|
87
87
|
if (this.units) {
|
|
88
|
-
return {
|
|
88
|
+
return {
|
|
89
|
+
dataType,
|
|
90
|
+
expressionType,
|
|
91
|
+
value,
|
|
92
|
+
timeframe: this.units,
|
|
93
|
+
evalSpace: 'literal',
|
|
94
|
+
};
|
|
89
95
|
}
|
|
90
|
-
return { dataType, expressionType, value };
|
|
96
|
+
return { dataType, expressionType, value, evalSpace: 'literal' };
|
|
91
97
|
}
|
|
92
98
|
getExpression(_fs) {
|
|
93
99
|
return this.makeValue(this.literalPart, this.timeType);
|
|
@@ -211,7 +217,7 @@ class DateBasedLiteral extends GranularLiteral {
|
|
|
211
217
|
const timestamp = [
|
|
212
218
|
this.makeLiteral(`${this.literalPart} 00:00:00`, 'timestamp'),
|
|
213
219
|
];
|
|
214
|
-
return { ...dateValue, morphic: { timestamp } };
|
|
220
|
+
return { ...dateValue, morphic: { timestamp }, evalSpace: 'literal' };
|
|
215
221
|
}
|
|
216
222
|
getNext() {
|
|
217
223
|
const dateValue = this.makeValue(this.nextLit, 'date');
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { FieldDef, FieldTypeDef } from '../../../model/malloy_types';
|
|
1
|
+
import { FieldDef, FieldTypeDef, TypeDesc } from '../../../model/malloy_types';
|
|
2
2
|
import { SpaceField } from '../types/space-field';
|
|
3
|
-
import { TypeDesc } from '../types/type-desc';
|
|
4
3
|
export declare class ColumnSpaceField extends SpaceField {
|
|
5
4
|
protected def: FieldTypeDef;
|
|
6
5
|
constructor(def: FieldTypeDef);
|
|
@@ -112,7 +112,7 @@ class DynamicSpace extends static_space_1.StaticSpace {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
const reorderFields = [...fields, ...joins, ...turtles];
|
|
115
|
-
for (const [
|
|
115
|
+
for (const [, field] of reorderFields) {
|
|
116
116
|
if (field instanceof join_space_field_1.JoinSpaceField) {
|
|
117
117
|
const joinStruct = field.join.structDef();
|
|
118
118
|
if (!error_factory_1.ErrorFactory.isErrorStructDef(joinStruct)) {
|
|
@@ -125,9 +125,11 @@ class DynamicSpace extends static_space_1.StaticSpace {
|
|
|
125
125
|
if (fieldDef) {
|
|
126
126
|
this.final.fields.push(fieldDef);
|
|
127
127
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
// TODO I'm just removing this, but perhaps instead I should just filter
|
|
129
|
+
// out ReferenceFields and still make this check.
|
|
130
|
+
// else {
|
|
131
|
+
// throw new Error(`'${fieldName}' doesn't have a FieldDef`);
|
|
132
|
+
// }
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
135
|
if (Object.entries(parameters).length > 0) {
|
|
@@ -2,7 +2,7 @@ import * as model from '../../../model/malloy_types';
|
|
|
2
2
|
import { FieldDeclaration } from '../query-items/field-declaration';
|
|
3
3
|
import { FieldSpace } from '../types/field-space';
|
|
4
4
|
import { SpaceField } from '../types/space-field';
|
|
5
|
-
import { TypeDesc } from '
|
|
5
|
+
import { TypeDesc } from '../../../model/malloy_types';
|
|
6
6
|
export declare class FieldDefinitionValue extends SpaceField {
|
|
7
7
|
readonly space: FieldSpace;
|
|
8
8
|
readonly exprDef: FieldDeclaration;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TypeDesc } from '../../../model/malloy_types';
|
|
2
2
|
import { QuerySpace } from './query-spaces';
|
|
3
3
|
export declare class ProjectFieldSpace extends QuerySpace {
|
|
4
4
|
readonly segmentType = "project";
|
|
5
|
-
canContain(
|
|
5
|
+
canContain(typeDesc: TypeDesc): boolean;
|
|
6
6
|
}
|
|
@@ -30,19 +30,18 @@ class ProjectFieldSpace extends query_spaces_1.QuerySpace {
|
|
|
30
30
|
super(...arguments);
|
|
31
31
|
this.segmentType = 'project';
|
|
32
32
|
}
|
|
33
|
-
canContain(
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
33
|
+
canContain(typeDesc) {
|
|
34
|
+
if (typeDesc.dataType === 'turtle' ||
|
|
35
|
+
(0, malloy_types_1.expressionIsAggregate)(typeDesc.expressionType)) {
|
|
36
|
+
// We don't need to log here, because an error should have already been logged.
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
// TODO it would be really nice to attach this error message to the specific field,
|
|
40
|
+
// rather than the whole query.
|
|
41
|
+
if ((0, malloy_types_1.expressionInvolvesAggregate)(typeDesc.expressionType) &&
|
|
42
|
+
(0, malloy_types_1.expressionIsAnalytic)(typeDesc.expressionType)) {
|
|
43
|
+
this.log('Cannot add aggregate analyics to project');
|
|
44
|
+
return false;
|
|
46
45
|
}
|
|
47
46
|
return true;
|
|
48
47
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { FieldDef, QueryFieldDef } from '../../../model/malloy_types';
|
|
1
|
+
import { FieldDef, QueryFieldDef, TypeDesc } from '../../../model/malloy_types';
|
|
2
2
|
import { FieldSpace } from '../types/field-space';
|
|
3
3
|
import { SpaceField } from '../types/space-field';
|
|
4
|
-
import { TypeDesc } from '../types/type-desc';
|
|
5
4
|
export declare abstract class QueryField extends SpaceField {
|
|
6
5
|
protected inSpace: FieldSpace;
|
|
7
6
|
constructor(inSpace: FieldSpace);
|
|
@@ -30,7 +30,7 @@ class QueryField extends space_field_1.SpaceField {
|
|
|
30
30
|
this.inSpace = inSpace;
|
|
31
31
|
}
|
|
32
32
|
typeDesc() {
|
|
33
|
-
return { dataType: 'turtle', expressionType: 'scalar' };
|
|
33
|
+
return { dataType: 'turtle', expressionType: 'scalar', evalSpace: 'input' };
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
exports.QueryField = QueryField;
|
|
@@ -8,6 +8,8 @@ import { FieldReference, WildcardFieldReference } from '../query-items/field-ref
|
|
|
8
8
|
import { FieldCollectionMember } from '../types/field-collection-member';
|
|
9
9
|
import { QueryItem } from '../types/query-item';
|
|
10
10
|
import { RefinedSpace } from './refined-space';
|
|
11
|
+
import { LookupResult } from '../types/lookup-result';
|
|
12
|
+
import { SpaceEntry } from '../types/space-entry';
|
|
11
13
|
/**
|
|
12
14
|
* Unlike a source, which is a refinement of a namespace, a query
|
|
13
15
|
* is creating a new unrelated namespace. The query starts with a
|
|
@@ -21,13 +23,16 @@ export declare class QueryInputSpace extends RefinedSpace {
|
|
|
21
23
|
extendList: string[];
|
|
22
24
|
constructor(input: SourceSpec, result: QuerySpace);
|
|
23
25
|
extendSource(extendField: Join | FieldDeclaration): void;
|
|
26
|
+
isQueryFieldSpace(): boolean;
|
|
27
|
+
outputSpace(): QuerySpace;
|
|
24
28
|
}
|
|
25
29
|
export declare abstract class QuerySpace extends RefinedSpace {
|
|
26
30
|
readonly queryInputSpace: FieldSpace;
|
|
27
31
|
readonly exprSpace: QueryInputSpace;
|
|
28
32
|
astEl?: MalloyElement | undefined;
|
|
29
33
|
abstract readonly segmentType: 'reduce' | 'project' | 'index';
|
|
30
|
-
constructor(queryInputSpace: FieldSpace);
|
|
34
|
+
constructor(queryInputSpace: FieldSpace, refineThis: model.PipeSegment | undefined);
|
|
35
|
+
private addRefineFromFields;
|
|
31
36
|
log(s: string): void;
|
|
32
37
|
addMembers(members: FieldCollectionMember[]): void;
|
|
33
38
|
addReference(ref: FieldReference): void;
|
|
@@ -40,11 +45,20 @@ export declare abstract class QuerySpace extends RefinedSpace {
|
|
|
40
45
|
*/
|
|
41
46
|
checkUngroup(fn: FieldName, isExclude: boolean): void;
|
|
42
47
|
addQueryItems(...qiList: QueryItem[]): void;
|
|
43
|
-
canContain(
|
|
48
|
+
canContain(_typeDesc: model.TypeDesc): boolean;
|
|
44
49
|
protected queryFieldDefs(): model.QueryFieldDef[];
|
|
45
50
|
getQuerySegment(rf: model.QuerySegment | undefined): model.QuerySegment;
|
|
46
51
|
getPipeSegment(refineFrom: model.QuerySegment | undefined): model.PipeSegment;
|
|
52
|
+
lookup(path: FieldName[]): LookupResult;
|
|
53
|
+
isQueryFieldSpace(): boolean;
|
|
54
|
+
outputSpace(): this;
|
|
47
55
|
}
|
|
48
56
|
export declare class ReduceFieldSpace extends QuerySpace {
|
|
49
57
|
readonly segmentType = "reduce";
|
|
50
58
|
}
|
|
59
|
+
export declare class OutputSpaceEntry extends SpaceEntry {
|
|
60
|
+
readonly inputSpaceEntry: SpaceEntry;
|
|
61
|
+
refType: 'field' | 'parameter';
|
|
62
|
+
constructor(inputSpaceEntry: SpaceEntry);
|
|
63
|
+
typeDesc(): model.TypeDesc;
|
|
64
|
+
}
|
|
@@ -45,7 +45,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
45
45
|
return result;
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.ReduceFieldSpace = exports.QuerySpace = exports.QueryInputSpace = void 0;
|
|
48
|
+
exports.OutputSpaceEntry = exports.ReduceFieldSpace = exports.QuerySpace = exports.QueryInputSpace = void 0;
|
|
49
49
|
const model = __importStar(require("../../../model/malloy_types"));
|
|
50
50
|
const field_utils_1 = require("../../field-utils");
|
|
51
51
|
const field_declaration_1 = require("../query-items/field-declaration");
|
|
@@ -58,6 +58,9 @@ const field_references_1 = require("../query-items/field-references");
|
|
|
58
58
|
const reference_field_1 = require("./reference-field");
|
|
59
59
|
const wild_space_field_1 = require("./wild-space-field");
|
|
60
60
|
const refined_space_1 = require("./refined-space");
|
|
61
|
+
const space_entry_1 = require("../types/space-entry");
|
|
62
|
+
const column_space_field_1 = require("./column-space-field");
|
|
63
|
+
const static_space_1 = require("./static-space");
|
|
61
64
|
/**
|
|
62
65
|
* Unlike a source, which is a refinement of a namespace, a query
|
|
63
66
|
* is creating a new unrelated namespace. The query starts with a
|
|
@@ -81,13 +84,47 @@ class QueryInputSpace extends refined_space_1.RefinedSpace {
|
|
|
81
84
|
this.extendList.push(extendField.defineName);
|
|
82
85
|
}
|
|
83
86
|
}
|
|
87
|
+
isQueryFieldSpace() {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
outputSpace() {
|
|
91
|
+
return this.result;
|
|
92
|
+
}
|
|
84
93
|
}
|
|
85
94
|
exports.QueryInputSpace = QueryInputSpace;
|
|
95
|
+
// TODO maybe rename QueryOutputSpace
|
|
86
96
|
class QuerySpace extends refined_space_1.RefinedSpace {
|
|
87
|
-
constructor(queryInputSpace) {
|
|
97
|
+
constructor(queryInputSpace, refineThis) {
|
|
88
98
|
super(queryInputSpace.emptyStructDef());
|
|
89
99
|
this.queryInputSpace = queryInputSpace;
|
|
90
100
|
this.exprSpace = new QueryInputSpace(queryInputSpace, this);
|
|
101
|
+
if (refineThis)
|
|
102
|
+
this.addRefineFromFields(refineThis);
|
|
103
|
+
}
|
|
104
|
+
addRefineFromFields(refineThis) {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
for (const field of refineThis.fields) {
|
|
107
|
+
if (typeof field === 'string') {
|
|
108
|
+
const ent = this.exprSpace.entry(field);
|
|
109
|
+
if (ent) {
|
|
110
|
+
this.setEntry(field, ent);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else if (model.isFilteredAliasedName(field)) {
|
|
114
|
+
const name = (_a = field.as) !== null && _a !== void 0 ? _a : field.name;
|
|
115
|
+
const ent = this.exprSpace.entry(name);
|
|
116
|
+
if (ent) {
|
|
117
|
+
this.setEntry(name, ent);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
// TODO can you reference fields in a turtle as fields in the output space,
|
|
122
|
+
// e.g. order_by: my_turtle.foo, or lag(my_turtle.foo)
|
|
123
|
+
if (field.type !== 'turtle') {
|
|
124
|
+
this.setEntry((_b = field.as) !== null && _b !== void 0 ? _b : field.name, new column_space_field_1.ColumnSpaceField(field));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
91
128
|
}
|
|
92
129
|
log(s) {
|
|
93
130
|
if (this.astEl) {
|
|
@@ -117,7 +154,90 @@ class QuerySpace extends refined_space_1.RefinedSpace {
|
|
|
117
154
|
}
|
|
118
155
|
}
|
|
119
156
|
addWild(wild) {
|
|
120
|
-
|
|
157
|
+
let success = true;
|
|
158
|
+
let current = this.exprSpace;
|
|
159
|
+
const parts = wild.refString.split('.');
|
|
160
|
+
const conflictMap = {};
|
|
161
|
+
function logConflict(name, parentRef) {
|
|
162
|
+
const conflict = conflictMap[name];
|
|
163
|
+
wild.log(`Cannot expand '${name}'${parentRef ? ` in ${parentRef}` : ''} because a field with that name already exists${conflict ? ` (conflicts with ${conflict})` : ''}`);
|
|
164
|
+
success = false;
|
|
165
|
+
}
|
|
166
|
+
for (let pi = 0; pi < parts.length; pi++) {
|
|
167
|
+
const part = parts[pi];
|
|
168
|
+
const prevParts = parts.slice(0, pi);
|
|
169
|
+
const parentRef = pi > 0 ? prevParts.join('.') : undefined;
|
|
170
|
+
const fullName = [...prevParts.join('.'), part].join('.');
|
|
171
|
+
if (part === '*') {
|
|
172
|
+
for (const [name, entry] of current.entries()) {
|
|
173
|
+
if (this.entry(name)) {
|
|
174
|
+
logConflict(name, parentRef);
|
|
175
|
+
success = false;
|
|
176
|
+
}
|
|
177
|
+
if (model.expressionIsScalar(entry.typeDesc().expressionType)) {
|
|
178
|
+
this.setEntry(name, entry);
|
|
179
|
+
conflictMap[name] = fullName;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
else if (part === '**') {
|
|
184
|
+
// TODO actually handle **
|
|
185
|
+
wild.log('** is currently broken');
|
|
186
|
+
success = false;
|
|
187
|
+
// const spaces: {space: FieldSpace; ref: string | undefined}[] = [
|
|
188
|
+
// {space: current, ref: undefined},
|
|
189
|
+
// ];
|
|
190
|
+
// let toExpand: {space: FieldSpace; ref: string | undefined} | undefined;
|
|
191
|
+
// while ((toExpand = spaces.pop())) {
|
|
192
|
+
// for (const [name, entry] of toExpand.space.entries()) {
|
|
193
|
+
// if (this.entry(name)) {
|
|
194
|
+
// logConflict(name, toExpand.ref);
|
|
195
|
+
// success = false;
|
|
196
|
+
// }
|
|
197
|
+
// if (model.expressionIsScalar(entry.typeDesc().expressionType)) {
|
|
198
|
+
// this.setEntry(name, entry);
|
|
199
|
+
// conflictMap[name] = toExpand.ref
|
|
200
|
+
// ? `${toExpand.ref}.${name}`
|
|
201
|
+
// : name;
|
|
202
|
+
// }
|
|
203
|
+
// if (entry instanceof StructSpaceField) {
|
|
204
|
+
// spaces.push({
|
|
205
|
+
// space: entry.fieldSpace,
|
|
206
|
+
// ref: [
|
|
207
|
+
// ...(parentRef ? [parentRef] : []),
|
|
208
|
+
// ...(toExpand.ref ? [toExpand.ref] : []),
|
|
209
|
+
// name,
|
|
210
|
+
// ].join('.'),
|
|
211
|
+
// });
|
|
212
|
+
// }
|
|
213
|
+
// }
|
|
214
|
+
// }
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
const ent = current.entry(part);
|
|
218
|
+
if (ent) {
|
|
219
|
+
if (ent instanceof static_space_1.StructSpaceField) {
|
|
220
|
+
current = ent.fieldSpace;
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
wild.log(`Field '${part}'${parentRef ? ` in ${parentRef}` : ''} is not a struct`);
|
|
224
|
+
success = false;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
wild.log(`No such field '${part}'${parentRef ? ` in ${parentRef}` : ''}`);
|
|
229
|
+
success = false;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (success) {
|
|
234
|
+
// TODO perform the entire replacement of * and ** here in the parser.
|
|
235
|
+
// Today, we add all the fields to the output space, and then still add * to
|
|
236
|
+
// the query. The compiler then does a second * expansion. Instead, we should
|
|
237
|
+
// just add all the fields to the query here and then remove the code in the compiler
|
|
238
|
+
// for expanding the *.
|
|
239
|
+
this.setEntry(wild.refString, new wild_space_field_1.WildSpaceField(wild.refString));
|
|
240
|
+
}
|
|
121
241
|
}
|
|
122
242
|
/**
|
|
123
243
|
* Check for the definition of an ungrouping reference in the result space,
|
|
@@ -158,25 +278,39 @@ class QuerySpace extends refined_space_1.RefinedSpace {
|
|
|
158
278
|
}
|
|
159
279
|
}
|
|
160
280
|
}
|
|
161
|
-
canContain(
|
|
281
|
+
canContain(_typeDesc) {
|
|
162
282
|
return true;
|
|
163
283
|
}
|
|
164
284
|
queryFieldDefs() {
|
|
165
285
|
const fields = [];
|
|
166
|
-
for (const [
|
|
286
|
+
for (const [, field] of this.entries()) {
|
|
167
287
|
if (field instanceof space_field_1.SpaceField) {
|
|
168
288
|
const fieldQueryDef = field.getQueryFieldDef(this.exprSpace);
|
|
169
289
|
if (fieldQueryDef) {
|
|
170
|
-
if (
|
|
290
|
+
if (field instanceof wild_space_field_1.WildSpaceField) {
|
|
171
291
|
fields.push(fieldQueryDef);
|
|
172
292
|
}
|
|
173
293
|
else {
|
|
174
|
-
|
|
294
|
+
const typeDesc = field.typeDesc();
|
|
295
|
+
// Filter out fields whose type is unknown, which means that a totally bad field
|
|
296
|
+
// isn't sent to the compiler, where it will wig out. The downside is that in
|
|
297
|
+
// subsequent stages of a query, the field is not in the input struct. But since
|
|
298
|
+
// the error message says "Cannot define x which has unknown type", it makes sense
|
|
299
|
+
// that it wouldn't be "defined" in later stages.
|
|
300
|
+
// TODO Figure out how to make errors generated by `canContain` go in the right place,
|
|
301
|
+
// maybe by adding a logable element to SpaceFields.
|
|
302
|
+
if (typeDesc.dataType !== 'unknown' && this.canContain(typeDesc)) {
|
|
303
|
+
fields.push(fieldQueryDef);
|
|
304
|
+
}
|
|
175
305
|
}
|
|
176
306
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
307
|
+
// TODO I removed the error here because during calculation of the refinement space,
|
|
308
|
+
// (see creation of a QuerySpace) we add references to all the fields from
|
|
309
|
+
// the refinement, but they don't have definitions. So in the case where we
|
|
310
|
+
// don't have a field def, we "know" that that field is already in the query,
|
|
311
|
+
// and we don't need to worry about actually adding it. This is also true for
|
|
312
|
+
// project statements, where we add "*" as a field and also all the individuala
|
|
313
|
+
// fields, but the individual fields don't have field defs.
|
|
180
314
|
}
|
|
181
315
|
}
|
|
182
316
|
this.isComplete();
|
|
@@ -224,6 +358,22 @@ class QuerySpace extends refined_space_1.RefinedSpace {
|
|
|
224
358
|
this.isComplete();
|
|
225
359
|
return segment;
|
|
226
360
|
}
|
|
361
|
+
lookup(path) {
|
|
362
|
+
const result = super.lookup(path);
|
|
363
|
+
if (result.found) {
|
|
364
|
+
return {
|
|
365
|
+
error: undefined,
|
|
366
|
+
found: new OutputSpaceEntry(result.found),
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
return this.exprSpace.lookup(path);
|
|
370
|
+
}
|
|
371
|
+
isQueryFieldSpace() {
|
|
372
|
+
return true;
|
|
373
|
+
}
|
|
374
|
+
outputSpace() {
|
|
375
|
+
return this;
|
|
376
|
+
}
|
|
227
377
|
}
|
|
228
378
|
exports.QuerySpace = QuerySpace;
|
|
229
379
|
class ReduceFieldSpace extends QuerySpace {
|
|
@@ -233,4 +383,19 @@ class ReduceFieldSpace extends QuerySpace {
|
|
|
233
383
|
}
|
|
234
384
|
}
|
|
235
385
|
exports.ReduceFieldSpace = ReduceFieldSpace;
|
|
386
|
+
class OutputSpaceEntry extends space_entry_1.SpaceEntry {
|
|
387
|
+
constructor(inputSpaceEntry) {
|
|
388
|
+
super();
|
|
389
|
+
this.inputSpaceEntry = inputSpaceEntry;
|
|
390
|
+
this.refType = inputSpaceEntry.refType;
|
|
391
|
+
}
|
|
392
|
+
typeDesc() {
|
|
393
|
+
const type = this.inputSpaceEntry.typeDesc();
|
|
394
|
+
return {
|
|
395
|
+
...type,
|
|
396
|
+
evalSpace: type.evalSpace === 'constant' ? 'constant' : 'output',
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
exports.OutputSpaceEntry = OutputSpaceEntry;
|
|
236
401
|
//# sourceMappingURL=query-spaces.js.map
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { QueryFieldDef } from '../../../model/malloy_types';
|
|
1
|
+
import { QueryFieldDef, TypeDesc } from '../../../model/malloy_types';
|
|
2
2
|
import { FieldReference } from '../query-items/field-references';
|
|
3
3
|
import { FieldSpace } from '../types/field-space';
|
|
4
|
+
import { LookupResult } from '../types/lookup-result';
|
|
4
5
|
import { SpaceField } from '../types/space-field';
|
|
5
|
-
import { TypeDesc } from '../types/type-desc';
|
|
6
6
|
export declare class ReferenceField extends SpaceField {
|
|
7
7
|
readonly fieldRef: FieldReference;
|
|
8
|
+
res: LookupResult | undefined;
|
|
8
9
|
constructor(fieldRef: FieldReference);
|
|
9
10
|
getQueryFieldDef(fs: FieldSpace): QueryFieldDef | undefined;
|
|
10
11
|
typeDesc(): TypeDesc;
|
|
@@ -28,6 +28,7 @@ class ReferenceField extends space_field_1.SpaceField {
|
|
|
28
28
|
constructor(fieldRef) {
|
|
29
29
|
super();
|
|
30
30
|
this.fieldRef = fieldRef;
|
|
31
|
+
this.res = undefined;
|
|
31
32
|
}
|
|
32
33
|
getQueryFieldDef(fs) {
|
|
33
34
|
// Lookup string and generate error if it isn't defined.
|
|
@@ -35,10 +36,16 @@ class ReferenceField extends space_field_1.SpaceField {
|
|
|
35
36
|
if (check.error) {
|
|
36
37
|
this.fieldRef.log(check.error);
|
|
37
38
|
}
|
|
39
|
+
this.res = check;
|
|
38
40
|
return this.fieldRef.refString;
|
|
39
41
|
}
|
|
40
42
|
typeDesc() {
|
|
41
|
-
|
|
43
|
+
// Remember the actual type of the field that was looked up so it can be used for
|
|
44
|
+
// type checking.
|
|
45
|
+
if (this.res !== undefined && this.res.found) {
|
|
46
|
+
return this.res.found.typeDesc();
|
|
47
|
+
}
|
|
48
|
+
return { dataType: 'unknown', expressionType: 'scalar', evalSpace: 'input' };
|
|
42
49
|
}
|
|
43
50
|
}
|
|
44
51
|
exports.ReferenceField = ReferenceField;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { DocumentLocation, FieldDef } from '../../../model/malloy_types';
|
|
1
|
+
import { DocumentLocation, FieldDef, TypeDesc } from '../../../model/malloy_types';
|
|
2
2
|
import { SpaceField } from '../types/space-field';
|
|
3
|
-
import { TypeDesc } from '../types/type-desc';
|
|
4
3
|
export declare class RenameSpaceField extends SpaceField {
|
|
5
4
|
private readonly otherField;
|
|
6
5
|
private readonly newName;
|
|
@@ -2,7 +2,7 @@ import { Dialect } from '../../../dialect/dialect';
|
|
|
2
2
|
import { FieldDef, StructDef } from '../../../model/malloy_types';
|
|
3
3
|
import { SpaceEntry } from '../types/space-entry';
|
|
4
4
|
import { LookupResult } from '../types/lookup-result';
|
|
5
|
-
import { FieldName, FieldSpace } from '../types/field-space';
|
|
5
|
+
import { FieldName, FieldSpace, QueryFieldSpace } from '../types/field-space';
|
|
6
6
|
import { SpaceField } from '../types/space-field';
|
|
7
7
|
import { StructSpaceFieldBase } from './struct-space-field-base';
|
|
8
8
|
export declare class StaticSpace implements FieldSpace {
|
|
@@ -16,12 +16,13 @@ export declare class StaticSpace implements FieldSpace {
|
|
|
16
16
|
private get map();
|
|
17
17
|
protected dropEntries(): void;
|
|
18
18
|
protected dropEntry(name: string): void;
|
|
19
|
-
|
|
19
|
+
entry(name: string): SpaceEntry | undefined;
|
|
20
20
|
protected setEntry(name: string, value: SpaceEntry): void;
|
|
21
|
-
|
|
21
|
+
entries(): [string, SpaceEntry][];
|
|
22
22
|
structDef(): StructDef;
|
|
23
23
|
emptyStructDef(): StructDef;
|
|
24
24
|
lookup(path: FieldName[]): LookupResult;
|
|
25
|
+
isQueryFieldSpace(): this is QueryFieldSpace;
|
|
25
26
|
}
|
|
26
27
|
export declare class StructSpaceField extends StructSpaceFieldBase {
|
|
27
28
|
constructor(def: StructDef);
|
|
@@ -80,6 +80,7 @@ class StaticSpace {
|
|
|
80
80
|
dropEntry(name) {
|
|
81
81
|
delete this.map[name];
|
|
82
82
|
}
|
|
83
|
+
// TODO this was protected
|
|
83
84
|
entry(name) {
|
|
84
85
|
return this.map[name];
|
|
85
86
|
}
|
|
@@ -142,6 +143,9 @@ class StaticSpace {
|
|
|
142
143
|
}
|
|
143
144
|
return { found, error: undefined };
|
|
144
145
|
}
|
|
146
|
+
isQueryFieldSpace() {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
145
149
|
}
|
|
146
150
|
exports.StaticSpace = StaticSpace;
|
|
147
151
|
class StructSpaceField extends struct_space_field_base_1.StructSpaceFieldBase {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { FieldDef, StructDef } from '../../../model/malloy_types';
|
|
1
|
+
import { FieldDef, StructDef, TypeDesc } from '../../../model/malloy_types';
|
|
2
2
|
import { FieldSpace } from '../types/field-space';
|
|
3
3
|
import { SpaceField } from '../types/space-field';
|
|
4
|
-
import { TypeDesc } from '../types/type-desc';
|
|
5
4
|
export declare abstract class StructSpaceFieldBase extends SpaceField {
|
|
6
5
|
protected sourceDef: StructDef;
|
|
7
6
|
constructor(sourceDef: StructDef);
|
|
@@ -33,7 +33,7 @@ class StructSpaceFieldBase extends space_field_1.SpaceField {
|
|
|
33
33
|
return this.sourceDef;
|
|
34
34
|
}
|
|
35
35
|
typeDesc() {
|
|
36
|
-
return { dataType: 'struct', expressionType: 'scalar' };
|
|
36
|
+
return { dataType: 'struct', expressionType: 'scalar', evalSpace: 'input' };
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
exports.StructSpaceFieldBase = StructSpaceFieldBase;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { QueryFieldDef } from '../../../model/malloy_types';
|
|
1
|
+
import { QueryFieldDef, TypeDesc } from '../../../model/malloy_types';
|
|
2
2
|
import { FieldSpace } from '../types/field-space';
|
|
3
3
|
import { SpaceField } from '../types/space-field';
|
|
4
|
-
import { TypeDesc } from '../types/type-desc';
|
|
5
4
|
export declare class WildSpaceField extends SpaceField {
|
|
6
5
|
readonly wildText: string;
|
|
7
6
|
constructor(wildText: string);
|
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.FT = void 0;
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const model_1 = require("../../model");
|
|
27
|
+
function mkFragType(dataType, expressionType = 'scalar', evalSpace = 'constant') {
|
|
28
|
+
return { dataType, expressionType, evalSpace };
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* Collects functions which operate on fragtype compatible objects
|
|
@@ -73,7 +74,7 @@ class FT {
|
|
|
73
74
|
const strings = types.map(type => {
|
|
74
75
|
if (type) {
|
|
75
76
|
let inspected = type.dataType;
|
|
76
|
-
if (type.expressionType
|
|
77
|
+
if (!(0, model_1.expressionIsScalar)(type.expressionType)) {
|
|
77
78
|
inspected = `${type.expressionType} ${inspected}`;
|
|
78
79
|
}
|
|
79
80
|
return inspected;
|