@malloydata/malloy 0.0.22-dev230207182613 → 0.0.22-dev230207183024
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/connection_utils.js +7 -7
- package/dist/dialect/dialect.d.ts +1 -1
- package/dist/dialect/duckdb.d.ts +1 -1
- package/dist/dialect/duckdb.js +9 -9
- package/dist/dialect/postgres.d.ts +1 -1
- package/dist/dialect/postgres.js +16 -16
- package/dist/dialect/standardsql.d.ts +1 -1
- package/dist/dialect/standardsql.js +8 -8
- package/dist/index.d.ts +6 -6
- package/dist/lang/ast/ast-utils.js +3 -3
- package/dist/lang/ast/elements/define-query.js +4 -4
- package/dist/lang/ast/elements/define-source.d.ts +1 -1
- package/dist/lang/ast/elements/define-source.js +8 -8
- package/dist/lang/ast/elements/import-statement.js +2 -2
- package/dist/lang/ast/elements/pipeline-desc.d.ts +1 -1
- package/dist/lang/ast/elements/pipeline-desc.js +7 -7
- package/dist/lang/ast/elements/refined-source.d.ts +1 -1
- package/dist/lang/ast/elements/refined-source.js +5 -5
- package/dist/lang/ast/elements/source.js +1 -1
- package/dist/lang/ast/error-factory.js +16 -13
- package/dist/lang/ast/expressions/binary-boolean.d.ts +1 -1
- package/dist/lang/ast/expressions/binary-boolean.js +4 -4
- package/dist/lang/ast/expressions/binary-numeric.d.ts +1 -1
- package/dist/lang/ast/expressions/binary-numeric.js +1 -1
- package/dist/lang/ast/expressions/boolean.js +1 -1
- package/dist/lang/ast/expressions/constant-sub-expression.js +7 -7
- package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +3 -3
- package/dist/lang/ast/expressions/expr-aggregate-function.js +12 -12
- package/dist/lang/ast/expressions/expr-alternation-tree.js +3 -3
- package/dist/lang/ast/expressions/expr-asymmetric.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-asymmetric.js +1 -1
- package/dist/lang/ast/expressions/expr-avg.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-avg.js +1 -1
- package/dist/lang/ast/expressions/expr-cast.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-cast.js +26 -4
- package/dist/lang/ast/expressions/expr-compare.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-compare.js +3 -3
- package/dist/lang/ast/expressions/expr-count.js +6 -6
- package/dist/lang/ast/expressions/expr-filter.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-filter.js +8 -8
- package/dist/lang/ast/expressions/expr-func.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-func.js +3 -3
- package/dist/lang/ast/expressions/expr-granular-time.js +7 -7
- package/dist/lang/ast/expressions/expr-id-reference.js +11 -11
- package/dist/lang/ast/expressions/expr-logical-op.js +1 -1
- package/dist/lang/ast/expressions/expr-minus.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-minus.js +3 -3
- package/dist/lang/ast/expressions/expr-not.js +2 -2
- package/dist/lang/ast/expressions/expr-now.js +7 -7
- package/dist/lang/ast/expressions/expr-null.js +3 -3
- package/dist/lang/ast/expressions/expr-number.js +1 -1
- package/dist/lang/ast/expressions/expr-parens.js +2 -2
- package/dist/lang/ast/expressions/expr-regex.js +3 -3
- package/dist/lang/ast/expressions/expr-string.js +6 -6
- package/dist/lang/ast/expressions/expr-sum.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-sum.js +1 -1
- package/dist/lang/ast/expressions/expr-time-extract.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-time-extract.js +29 -29
- package/dist/lang/ast/expressions/expr-time.js +7 -7
- package/dist/lang/ast/expressions/expr-ungroup.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-ungroup.js +11 -8
- package/dist/lang/ast/expressions/for-range.d.ts +1 -1
- package/dist/lang/ast/expressions/for-range.js +1 -1
- package/dist/lang/ast/expressions/granular-literal.js +12 -12
- package/dist/lang/ast/expressions/partial-compare.d.ts +1 -1
- package/dist/lang/ast/expressions/partial-compare.js +1 -1
- package/dist/lang/ast/expressions/pick-when.d.ts +1 -1
- package/dist/lang/ast/expressions/pick-when.js +11 -11
- package/dist/lang/ast/expressions/range.js +4 -4
- package/dist/lang/ast/expressions/top-by.d.ts +1 -1
- package/dist/lang/ast/expressions/top-by.js +4 -4
- package/dist/lang/ast/expressions/unary.js +1 -1
- package/dist/lang/ast/field-space/dynamic-space.d.ts +1 -1
- package/dist/lang/ast/field-space/dynamic-space.js +1 -1
- package/dist/lang/ast/field-space/index-field-space.js +2 -2
- package/dist/lang/ast/field-space/query-field-struct.js +1 -1
- package/dist/lang/ast/field-space/query-space-field.js +1 -1
- package/dist/lang/ast/field-space/query-spaces.js +2 -2
- package/dist/lang/ast/field-space/reference-field.js +1 -1
- package/dist/lang/ast/field-space/rename-space-field.js +2 -2
- package/dist/lang/ast/field-space/static-space.js +8 -8
- package/dist/lang/ast/field-space/struct-space-field-base.js +1 -1
- package/dist/lang/ast/fragtype-utils.js +2 -2
- package/dist/lang/ast/parameters/constant-parameter.js +9 -9
- package/dist/lang/ast/parameters/has-parameter.js +5 -5
- package/dist/lang/ast/query-elements/anonymous-query.js +1 -1
- package/dist/lang/ast/query-elements/existing-query.d.ts +1 -1
- package/dist/lang/ast/query-elements/existing-query.js +11 -11
- package/dist/lang/ast/query-elements/full-query.js +11 -11
- package/dist/lang/ast/query-elements/query-head-struct.js +1 -1
- package/dist/lang/ast/query-items/field-declaration.d.ts +1 -1
- package/dist/lang/ast/query-items/field-declaration.js +11 -11
- package/dist/lang/ast/query-items/field-references.d.ts +1 -1
- package/dist/lang/ast/query-items/field-references.js +1 -1
- package/dist/lang/ast/query-properties/filters.d.ts +1 -1
- package/dist/lang/ast/query-properties/filters.js +7 -7
- package/dist/lang/ast/query-properties/indexing.d.ts +1 -1
- package/dist/lang/ast/query-properties/indexing.js +2 -2
- package/dist/lang/ast/query-properties/joins.d.ts +1 -1
- package/dist/lang/ast/query-properties/joins.js +17 -14
- package/dist/lang/ast/query-properties/nest.js +4 -4
- package/dist/lang/ast/query-properties/ordering.js +2 -2
- package/dist/lang/ast/query-properties/qop-desc.js +1 -1
- package/dist/lang/ast/query-properties/top.js +3 -3
- package/dist/lang/ast/source-properties/field-list-edit.js +1 -1
- package/dist/lang/ast/source-properties/primary-key.js +1 -1
- package/dist/lang/ast/source-properties/renames.js +1 -1
- package/dist/lang/ast/sources/named-source.d.ts +2 -2
- package/dist/lang/ast/sources/named-source.js +6 -6
- package/dist/lang/ast/sources/query-source.d.ts +1 -1
- package/dist/lang/ast/sources/query-source.js +2 -2
- package/dist/lang/ast/sources/table-source.js +7 -5
- package/dist/lang/ast/space-seed.d.ts +1 -1
- package/dist/lang/ast/sql-elements/sql-statement.js +5 -5
- package/dist/lang/ast/sql-elements/sql-string.js +1 -1
- package/dist/lang/ast/struct-utils.js +2 -2
- package/dist/lang/ast/time-utils.js +32 -32
- package/dist/lang/ast/types/expression-def.js +34 -34
- package/dist/lang/ast/types/malloy-element.d.ts +4 -4
- package/dist/lang/ast/types/malloy-element.js +27 -27
- package/dist/lang/ast/types/query-comp.d.ts +1 -1
- package/dist/lang/ast/types/space-field.js +1 -1
- package/dist/lang/ast/types/space-param.js +2 -2
- package/dist/lang/ast/types/turtle-headed-pipe.d.ts +1 -1
- package/dist/lang/ast/types/turtle-headed-pipe.js +1 -1
- package/dist/lang/ast/types/type-desc.d.ts +1 -1
- package/dist/lang/field-utils.d.ts +1 -1
- package/dist/lang/index.d.ts +1 -1
- package/dist/lang/malloy-to-ast.d.ts +1 -1
- package/dist/lang/malloy-to-ast.js +11 -11
- package/dist/lang/parse-error-handler.js +4 -4
- package/dist/lang/parse-malloy.d.ts +4 -4
- package/dist/lang/parse-malloy.js +61 -61
- package/dist/lang/parse-tree-walkers/document-completion-walker.js +16 -16
- package/dist/lang/parse-tree-walkers/document-help-context-walker.js +10 -10
- package/dist/lang/parse-tree-walkers/document-highlight-walker.js +85 -82
- package/dist/lang/parse-tree-walkers/document-symbol-walker.js +40 -40
- package/dist/lang/parse-tree-walkers/find-external-references.d.ts +1 -1
- package/dist/lang/parse-tree-walkers/find-external-references.js +2 -2
- package/dist/lang/reference-list.d.ts +1 -1
- package/dist/lang/test/document-help-context-walker.spec.js +6 -6
- package/dist/lang/test/document-symbol-walker.spec.js +3 -3
- package/dist/lang/test/field-symbols.spec.js +62 -58
- package/dist/lang/test/parse.spec.js +262 -260
- package/dist/lang/test/test-translator.d.ts +1 -1
- package/dist/lang/test/test-translator.js +139 -139
- package/dist/lang/translate-response.d.ts +1 -1
- package/dist/lang/zone.js +5 -5
- package/dist/malloy.d.ts +5 -5
- package/dist/malloy.js +72 -72
- package/dist/model/malloy_query.d.ts +2 -2
- package/dist/model/malloy_query.js +179 -176
- package/dist/model/malloy_types.js +41 -41
- package/dist/model/sql_block.js +2 -2
- package/package.json +1 -1
|
@@ -25,11 +25,11 @@ exports.ExprTimeExtract = void 0;
|
|
|
25
25
|
*/
|
|
26
26
|
const malloy_types_1 = require("../../../model/malloy_types");
|
|
27
27
|
const ast_utils_1 = require("../ast-utils");
|
|
28
|
-
const range_1 = require("./range");
|
|
29
28
|
const expression_def_1 = require("../types/expression-def");
|
|
29
|
+
const range_1 = require("./range");
|
|
30
30
|
class ExprTimeExtract extends expression_def_1.ExpressionDef {
|
|
31
31
|
constructor(extractText, args) {
|
|
32
|
-
super({ args });
|
|
32
|
+
super({ "args": args });
|
|
33
33
|
this.extractText = extractText;
|
|
34
34
|
this.args = args;
|
|
35
35
|
this.elementType = "timeExtract";
|
|
@@ -67,33 +67,33 @@ class ExprTimeExtract extends expression_def_1.ExpressionDef {
|
|
|
67
67
|
return (0, ast_utils_1.errorFor)(`${extractTo} bad extraction`);
|
|
68
68
|
}
|
|
69
69
|
return {
|
|
70
|
-
dataType: "number",
|
|
71
|
-
expressionType: (0, malloy_types_1.maxExpressionType)(first.expressionType, last.expressionType),
|
|
72
|
-
value: [
|
|
70
|
+
"dataType": "number",
|
|
71
|
+
"expressionType": (0, malloy_types_1.maxExpressionType)(first.expressionType, last.expressionType),
|
|
72
|
+
"value": [
|
|
73
73
|
{
|
|
74
|
-
type: "dialect",
|
|
75
|
-
function: "timeDiff",
|
|
76
|
-
units: extractTo,
|
|
77
|
-
left: { valueType: first.dataType, value: first.value },
|
|
78
|
-
right: { valueType: last.dataType, value: last.value }
|
|
79
|
-
}
|
|
80
|
-
]
|
|
74
|
+
"type": "dialect",
|
|
75
|
+
"function": "timeDiff",
|
|
76
|
+
"units": extractTo,
|
|
77
|
+
"left": { "valueType": first.dataType, "value": first.value },
|
|
78
|
+
"right": { "valueType": last.dataType, "value": last.value }
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
84
84
|
const argV = from.getExpression(fs);
|
|
85
85
|
if ((0, malloy_types_1.isTimeFieldType)(argV.dataType)) {
|
|
86
86
|
return {
|
|
87
|
-
dataType: "number",
|
|
88
|
-
expressionType: argV.expressionType,
|
|
89
|
-
value: [
|
|
87
|
+
"dataType": "number",
|
|
88
|
+
"expressionType": argV.expressionType,
|
|
89
|
+
"value": [
|
|
90
90
|
{
|
|
91
|
-
type: "dialect",
|
|
92
|
-
function: "extract",
|
|
93
|
-
expr: { value: argV.value, valueType: argV.dataType },
|
|
94
|
-
units: extractTo
|
|
95
|
-
}
|
|
96
|
-
]
|
|
91
|
+
"type": "dialect",
|
|
92
|
+
"function": "extract",
|
|
93
|
+
"expr": { "value": argV.value, "valueType": argV.dataType },
|
|
94
|
+
"units": extractTo
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
this.log(`${this.extractText}() requires time type, not '${argV.dataType}'`);
|
|
@@ -105,13 +105,13 @@ class ExprTimeExtract extends expression_def_1.ExpressionDef {
|
|
|
105
105
|
}
|
|
106
106
|
exports.ExprTimeExtract = ExprTimeExtract;
|
|
107
107
|
ExprTimeExtract.pluralMap = {
|
|
108
|
-
years: "year",
|
|
109
|
-
quarters: "quarter",
|
|
110
|
-
months: "month",
|
|
111
|
-
weeks: "week",
|
|
112
|
-
days: "day",
|
|
113
|
-
hours: "hour",
|
|
114
|
-
minutes: "minute",
|
|
115
|
-
seconds: "second"
|
|
108
|
+
"years": "year",
|
|
109
|
+
"quarters": "quarter",
|
|
110
|
+
"months": "month",
|
|
111
|
+
"weeks": "week",
|
|
112
|
+
"days": "day",
|
|
113
|
+
"hours": "hour",
|
|
114
|
+
"minutes": "minute",
|
|
115
|
+
"seconds": "second"
|
|
116
116
|
};
|
|
117
117
|
//# sourceMappingURL=expr-time-extract.js.map
|
|
@@ -32,9 +32,9 @@ class ExprTime extends expression_def_1.ExpressionDef {
|
|
|
32
32
|
this.elementType = "timestampOrDate";
|
|
33
33
|
this.elementType = timeType;
|
|
34
34
|
this.translationValue = {
|
|
35
|
-
dataType: timeType,
|
|
35
|
+
"dataType": timeType,
|
|
36
36
|
expressionType,
|
|
37
|
-
value: typeof value === "string" ? [value] : value
|
|
37
|
+
"value": typeof value === "string" ? [value] : value
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
getExpression(_fs) {
|
|
@@ -44,11 +44,11 @@ class ExprTime extends expression_def_1.ExpressionDef {
|
|
|
44
44
|
let value = expr.value;
|
|
45
45
|
if (timeType != expr.dataType) {
|
|
46
46
|
const toTs = {
|
|
47
|
-
type: "dialect",
|
|
48
|
-
function: "cast",
|
|
49
|
-
safe: false,
|
|
50
|
-
dstType: timeType,
|
|
51
|
-
expr: expr.value
|
|
47
|
+
"type": "dialect",
|
|
48
|
+
"function": "cast",
|
|
49
|
+
"safe": false,
|
|
50
|
+
"dstType": timeType,
|
|
51
|
+
"expr": expr.value
|
|
52
52
|
};
|
|
53
53
|
if ((0, malloy_types_1.isTimeFieldType)(expr.dataType)) {
|
|
54
54
|
toTs.srcType = expr.dataType;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ExprValue } from "../types/expr-value";
|
|
2
|
-
import { FieldValueType } from "../types/type-desc";
|
|
3
|
-
import { FieldName, FieldSpace } from "../types/field-space";
|
|
4
2
|
import { ExpressionDef } from "../types/expression-def";
|
|
3
|
+
import { FieldName, FieldSpace } from "../types/field-space";
|
|
4
|
+
import { FieldValueType } from "../types/type-desc";
|
|
5
5
|
export declare class ExprUngroup extends ExpressionDef {
|
|
6
6
|
readonly control: "all" | "exclude";
|
|
7
7
|
readonly expr: ExpressionDef;
|
|
@@ -24,14 +24,14 @@ exports.ExprUngroup = void 0;
|
|
|
24
24
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
25
25
|
*/
|
|
26
26
|
const malloy_types_1 = require("../../../model/malloy_types");
|
|
27
|
-
const query_spaces_1 = require("../field-space/query-spaces");
|
|
28
27
|
const ast_utils_1 = require("../ast-utils");
|
|
29
|
-
const
|
|
28
|
+
const query_spaces_1 = require("../field-space/query-spaces");
|
|
30
29
|
const fragtype_utils_1 = require("../fragtype-utils");
|
|
30
|
+
const field_declaration_1 = require("../query-items/field-declaration");
|
|
31
31
|
const expression_def_1 = require("../types/expression-def");
|
|
32
32
|
class ExprUngroup extends expression_def_1.ExpressionDef {
|
|
33
33
|
constructor(control, expr, fields) {
|
|
34
|
-
super({ expr, fields });
|
|
34
|
+
super({ "expr": expr, "fields": fields });
|
|
35
35
|
this.control = control;
|
|
36
36
|
this.expr = expr;
|
|
37
37
|
this.fields = fields;
|
|
@@ -47,8 +47,11 @@ class ExprUngroup extends expression_def_1.ExpressionDef {
|
|
|
47
47
|
this.expr.log(`${this.control}() expression must be an aggregate`);
|
|
48
48
|
return (0, ast_utils_1.errorFor)("ungrouped scalar");
|
|
49
49
|
}
|
|
50
|
-
const ungroup = {
|
|
51
|
-
|
|
50
|
+
const ungroup = {
|
|
51
|
+
"type": this.control,
|
|
52
|
+
"e": exprVal.value
|
|
53
|
+
};
|
|
54
|
+
if (this.typeCheck(this.expr, { ...exprVal, "expressionType": "scalar" })) {
|
|
52
55
|
if (this.fields.length > 0) {
|
|
53
56
|
let qs = fs;
|
|
54
57
|
if (fs instanceof field_declaration_1.DefSpace) {
|
|
@@ -70,9 +73,9 @@ class ExprUngroup extends expression_def_1.ExpressionDef {
|
|
|
70
73
|
ungroup.fields = dstFields;
|
|
71
74
|
}
|
|
72
75
|
return {
|
|
73
|
-
dataType: this.returns(exprVal),
|
|
74
|
-
expressionType: "analytic",
|
|
75
|
-
value: [ungroup]
|
|
76
|
+
"dataType": this.returns(exprVal),
|
|
77
|
+
"expressionType": "analytic",
|
|
78
|
+
"value": [ungroup]
|
|
76
79
|
};
|
|
77
80
|
}
|
|
78
81
|
this.log(`${this.control}() incompatible type`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FieldSpace } from "../types/field-space";
|
|
2
1
|
import { ExprValue } from "../types/expr-value";
|
|
3
2
|
import { ExpressionDef } from "../types/expression-def";
|
|
3
|
+
import { FieldSpace } from "../types/field-space";
|
|
4
4
|
import { Timeframe } from "./time-frame";
|
|
5
5
|
/**
|
|
6
6
|
* TODO: This is sort of a hand clone of the "Range" class, they should
|
|
@@ -36,7 +36,7 @@ const range_1 = require("./range");
|
|
|
36
36
|
*/
|
|
37
37
|
class ForRange extends expression_def_1.ExpressionDef {
|
|
38
38
|
constructor(from, duration, timeframe) {
|
|
39
|
-
super({ from, duration, timeframe });
|
|
39
|
+
super({ "from": from, "duration": duration, "timeframe": timeframe });
|
|
40
40
|
this.from = from;
|
|
41
41
|
this.duration = duration;
|
|
42
42
|
this.timeframe = timeframe;
|
|
@@ -53,7 +53,7 @@ class GranularLiteral extends expression_def_1.ExpressionDef {
|
|
|
53
53
|
const fSecond = `${fMinute}:ss`;
|
|
54
54
|
const tss = luxon_1.DateTime.fromFormat(s, fSecond);
|
|
55
55
|
if (tss.isValid) {
|
|
56
|
-
const nextSecond = tss.plus({ second: 1 }).toFormat(fSecond);
|
|
56
|
+
const nextSecond = tss.plus({ "second": 1 }).toFormat(fSecond);
|
|
57
57
|
const tsLit = new GranularLiteral(s, nextSecond, "second");
|
|
58
58
|
tsLit.timeType = "timestamp";
|
|
59
59
|
return tsLit;
|
|
@@ -62,7 +62,7 @@ class GranularLiteral extends expression_def_1.ExpressionDef {
|
|
|
62
62
|
if (tsm.isValid) {
|
|
63
63
|
// working around a weird bigquery bug ...
|
|
64
64
|
const thisMin = s + ":00";
|
|
65
|
-
const nextMinute = tsm.plus({ minute: 1 }).toFormat(fMinute) + ":00";
|
|
65
|
+
const nextMinute = tsm.plus({ "minute": 1 }).toFormat(fMinute) + ":00";
|
|
66
66
|
const tsLit = new GranularLiteral(thisMin, nextMinute, "minute");
|
|
67
67
|
tsLit.timeType = "timestamp";
|
|
68
68
|
return tsLit;
|
|
@@ -72,25 +72,25 @@ class GranularLiteral extends expression_def_1.ExpressionDef {
|
|
|
72
72
|
const qplus = Number.parseInt(quarter[2]) - 1;
|
|
73
73
|
let qstart = luxon_1.DateTime.fromFormat(quarter[1], "yyyy");
|
|
74
74
|
if (qplus > 0) {
|
|
75
|
-
qstart = qstart.plus({ quarters: qplus });
|
|
75
|
+
qstart = qstart.plus({ "quarters": qplus });
|
|
76
76
|
}
|
|
77
|
-
const qend = qstart.plus({ quarter: 1 });
|
|
77
|
+
const qend = qstart.plus({ "quarter": 1 });
|
|
78
78
|
return new GranularLiteral(`${qstart.toFormat(fDay)}`, `${qend.toFormat(fDay)}`, "quarter");
|
|
79
79
|
}
|
|
80
80
|
const yyyymmdd = luxon_1.DateTime.fromFormat(s, fDay);
|
|
81
81
|
if (yyyymmdd.isValid) {
|
|
82
|
-
const next = yyyymmdd.plus({ days: 1 });
|
|
82
|
+
const next = yyyymmdd.plus({ "days": 1 });
|
|
83
83
|
return new GranularLiteral(`${yyyymmdd.toFormat(fDay)}`, `${next.toFormat(fDay)}`, "day");
|
|
84
84
|
}
|
|
85
85
|
const yyyymm = luxon_1.DateTime.fromFormat(s, fMonth);
|
|
86
86
|
if (yyyymm.isValid) {
|
|
87
|
-
const next = yyyymm.plus({ months: 1 });
|
|
87
|
+
const next = yyyymm.plus({ "months": 1 });
|
|
88
88
|
return new GranularLiteral(`${yyyymm.toFormat(fDay)}`, `${next.toFormat(fDay)}`, "month");
|
|
89
89
|
}
|
|
90
90
|
const yyyy = luxon_1.DateTime.fromFormat(s, fYear);
|
|
91
91
|
if (yyyy.isValid) {
|
|
92
92
|
const year = yyyy.toFormat(`yyyy-01-01`);
|
|
93
|
-
const nextYear = yyyy.plus({ year: 1 }).toFormat(`yyyy-01-01`);
|
|
93
|
+
const nextYear = yyyy.plus({ "year": 1 }).toFormat(`yyyy-01-01`);
|
|
94
94
|
return new GranularLiteral(year, nextYear, "year");
|
|
95
95
|
}
|
|
96
96
|
if (s.startsWith("WK")) {
|
|
@@ -99,9 +99,9 @@ class GranularLiteral extends expression_def_1.ExpressionDef {
|
|
|
99
99
|
// wonky because luxon uses monday weeks and bigquery uses sunday weeks
|
|
100
100
|
let sunday = yyyymmdd;
|
|
101
101
|
if (yyyymmdd.weekday !== 7) {
|
|
102
|
-
sunday = yyyymmdd.startOf("week").minus({ day: 1 });
|
|
102
|
+
sunday = yyyymmdd.startOf("week").minus({ "day": 1 });
|
|
103
103
|
}
|
|
104
|
-
const next = sunday.plus({ days: 7 });
|
|
104
|
+
const next = sunday.plus({ "days": 7 });
|
|
105
105
|
return new GranularLiteral(`${sunday.toFormat(fDay)}`, `${next.toFormat(fDay)}`, "week");
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -123,8 +123,8 @@ class GranularLiteral extends expression_def_1.ExpressionDef {
|
|
|
123
123
|
const dataType = this.timeType || "date";
|
|
124
124
|
const value = {
|
|
125
125
|
dataType,
|
|
126
|
-
expressionType: "scalar",
|
|
127
|
-
value: (0, time_utils_1.timeLiteral)(this.moment, dataType, "UTC")
|
|
126
|
+
"expressionType": "scalar",
|
|
127
|
+
"value": (0, time_utils_1.timeLiteral)(this.moment, dataType, "UTC")
|
|
128
128
|
};
|
|
129
129
|
// Literals with date resolution can be used as timestamps or dates,
|
|
130
130
|
// this is the third attempt to make that work. It still feels like
|
|
@@ -138,7 +138,7 @@ class GranularLiteral extends expression_def_1.ExpressionDef {
|
|
|
138
138
|
if (this.units != "second") {
|
|
139
139
|
return {
|
|
140
140
|
...value,
|
|
141
|
-
timeframe: this.units
|
|
141
|
+
"timeframe": this.units
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
return value;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Comparison } from "../types/comparison";
|
|
2
2
|
import { ExprValue } from "../types/expr-value";
|
|
3
|
-
import { FieldSpace } from "../types/field-space";
|
|
4
3
|
import { ExpressionDef } from "../types/expression-def";
|
|
4
|
+
import { FieldSpace } from "../types/field-space";
|
|
5
5
|
export declare class PartialCompare extends ExpressionDef {
|
|
6
6
|
readonly op: Comparison;
|
|
7
7
|
readonly right: ExpressionDef;
|
|
@@ -27,7 +27,7 @@ const ast_utils_1 = require("../ast-utils");
|
|
|
27
27
|
const expression_def_1 = require("../types/expression-def");
|
|
28
28
|
class PartialCompare extends expression_def_1.ExpressionDef {
|
|
29
29
|
constructor(op, right) {
|
|
30
|
-
super({ right });
|
|
30
|
+
super({ "right": right });
|
|
31
31
|
this.op = op;
|
|
32
32
|
this.right = right;
|
|
33
33
|
this.elementType = "<=> a";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ExprValue } from "../types/expr-value";
|
|
2
|
+
import { ExpressionDef } from "../types/expression-def";
|
|
2
3
|
import { FieldSpace } from "../types/field-space";
|
|
3
4
|
import { MalloyElement } from "../types/malloy-element";
|
|
4
|
-
import { ExpressionDef } from "../types/expression-def";
|
|
5
5
|
export declare class Pick extends ExpressionDef {
|
|
6
6
|
readonly choices: PickWhen[];
|
|
7
7
|
readonly elsePick?: ExpressionDef | undefined;
|
|
@@ -26,8 +26,8 @@ exports.PickWhen = exports.Pick = void 0;
|
|
|
26
26
|
const malloy_types_1 = require("../../../model/malloy_types");
|
|
27
27
|
const ast_utils_1 = require("../ast-utils");
|
|
28
28
|
const fragtype_utils_1 = require("../fragtype-utils");
|
|
29
|
-
const malloy_element_1 = require("../types/malloy-element");
|
|
30
29
|
const expression_def_1 = require("../types/expression-def");
|
|
30
|
+
const malloy_element_1 = require("../types/malloy-element");
|
|
31
31
|
const utils_1 = require("./utils");
|
|
32
32
|
class Pick extends expression_def_1.ExpressionDef {
|
|
33
33
|
constructor(choices, elsePick) {
|
|
@@ -86,9 +86,9 @@ class Pick extends expression_def_1.ExpressionDef {
|
|
|
86
86
|
return (0, ast_utils_1.errorFor)("pick else type");
|
|
87
87
|
}
|
|
88
88
|
return {
|
|
89
|
-
dataType: returnType.dataType,
|
|
90
|
-
expressionType: (0, malloy_types_1.maxExpressionType)(anyExpressionType, elseVal.expressionType),
|
|
91
|
-
value: (0, utils_1.compressExpr)([...caseValue, " ELSE ", ...elseVal.value, " END"])
|
|
89
|
+
"dataType": returnType.dataType,
|
|
90
|
+
"expressionType": (0, malloy_types_1.maxExpressionType)(anyExpressionType, elseVal.expressionType),
|
|
91
|
+
"value": (0, utils_1.compressExpr)([...caseValue, " ELSE ", ...elseVal.value, " END"])
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
getExpression(fs) {
|
|
@@ -108,8 +108,8 @@ class Pick extends expression_def_1.ExpressionDef {
|
|
|
108
108
|
return (0, ast_utils_1.errorFor)("partial when");
|
|
109
109
|
}
|
|
110
110
|
choiceValues.push({
|
|
111
|
-
pick: c.pick.getExpression(fs),
|
|
112
|
-
when: c.when.getExpression(fs)
|
|
111
|
+
"pick": c.pick.getExpression(fs),
|
|
112
|
+
"when": c.when.getExpression(fs)
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
const returnType = choiceValues[0].pick;
|
|
@@ -136,20 +136,20 @@ class Pick extends expression_def_1.ExpressionDef {
|
|
|
136
136
|
}
|
|
137
137
|
caseValue.push(" ELSE ", ...defVal.value, " END");
|
|
138
138
|
return {
|
|
139
|
-
dataType: returnType.dataType,
|
|
140
|
-
expressionType: anyExpressionType,
|
|
141
|
-
value: (0, utils_1.compressExpr)(caseValue)
|
|
139
|
+
"dataType": returnType.dataType,
|
|
140
|
+
"expressionType": anyExpressionType,
|
|
141
|
+
"value": (0, utils_1.compressExpr)(caseValue)
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
exports.Pick = Pick;
|
|
146
146
|
class PickWhen extends malloy_element_1.MalloyElement {
|
|
147
147
|
constructor(pick, when) {
|
|
148
|
-
super({ when });
|
|
148
|
+
super({ "when": when });
|
|
149
149
|
this.pick = pick;
|
|
150
150
|
this.when = when;
|
|
151
151
|
this.elementType = "pickWhen";
|
|
152
|
-
this.has({ pick });
|
|
152
|
+
this.has({ "pick": pick });
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
exports.PickWhen = PickWhen;
|
|
@@ -29,7 +29,7 @@ const expression_def_1 = require("../types/expression-def");
|
|
|
29
29
|
const utils_1 = require("./utils");
|
|
30
30
|
class Range extends expression_def_1.ExpressionDef {
|
|
31
31
|
constructor(first, last) {
|
|
32
|
-
super({ first, last });
|
|
32
|
+
super({ "first": first, "last": last });
|
|
33
33
|
this.first = first;
|
|
34
34
|
this.last = last;
|
|
35
35
|
this.elementType = "range";
|
|
@@ -44,9 +44,9 @@ class Range extends expression_def_1.ExpressionDef {
|
|
|
44
44
|
const fromValue = this.first.apply(fs, op1, expr);
|
|
45
45
|
const toValue = this.last.apply(fs, op3, expr);
|
|
46
46
|
return {
|
|
47
|
-
dataType: "boolean",
|
|
48
|
-
expressionType: (0, malloy_types_1.maxExpressionType)(fromValue.expressionType, toValue.expressionType),
|
|
49
|
-
value: (0, utils_1.compose)(fromValue.value, op2, toValue.value)
|
|
47
|
+
"dataType": "boolean",
|
|
48
|
+
"expressionType": (0, malloy_types_1.maxExpressionType)(fromValue.expressionType, toValue.expressionType),
|
|
49
|
+
"value": (0, utils_1.compose)(fromValue.value, op2, toValue.value)
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { By } from "../../../model/malloy_types";
|
|
2
|
+
import { ExpressionDef } from "../types/expression-def";
|
|
2
3
|
import { FieldSpace } from "../types/field-space";
|
|
3
4
|
import { MalloyElement } from "../types/malloy-element";
|
|
4
|
-
import { ExpressionDef } from "../types/expression-def";
|
|
5
5
|
export declare class TopBy extends MalloyElement {
|
|
6
6
|
readonly by: string | ExpressionDef;
|
|
7
7
|
elementType: string;
|
|
@@ -24,8 +24,8 @@ exports.TopBy = void 0;
|
|
|
24
24
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
25
25
|
*/
|
|
26
26
|
const malloy_types_1 = require("../../../model/malloy_types");
|
|
27
|
-
const malloy_element_1 = require("../types/malloy-element");
|
|
28
27
|
const expression_def_1 = require("../types/expression-def");
|
|
28
|
+
const malloy_element_1 = require("../types/malloy-element");
|
|
29
29
|
const utils_1 = require("./utils");
|
|
30
30
|
class TopBy extends malloy_element_1.MalloyElement {
|
|
31
31
|
constructor(by) {
|
|
@@ -33,7 +33,7 @@ class TopBy extends malloy_element_1.MalloyElement {
|
|
|
33
33
|
this.by = by;
|
|
34
34
|
this.elementType = "topBy";
|
|
35
35
|
if (by instanceof expression_def_1.ExpressionDef) {
|
|
36
|
-
this.has({ by });
|
|
36
|
+
this.has({ "by": by });
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
getBy(fs) {
|
|
@@ -42,9 +42,9 @@ class TopBy extends malloy_element_1.MalloyElement {
|
|
|
42
42
|
if (!(0, malloy_types_1.expressionIsAggregate)(byExpr.expressionType)) {
|
|
43
43
|
this.log("top by expression must be an aggregate");
|
|
44
44
|
}
|
|
45
|
-
return { by: "expression", e: (0, utils_1.compressExpr)(byExpr.value) };
|
|
45
|
+
return { "by": "expression", "e": (0, utils_1.compressExpr)(byExpr.value) };
|
|
46
46
|
}
|
|
47
|
-
return { by: "name", name: this.by };
|
|
47
|
+
return { "by": "name", "name": this.by };
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
exports.TopBy = TopBy;
|
|
@@ -3,7 +3,7 @@ import { SpaceEntry } from "../types/space-entry";
|
|
|
3
3
|
import { FieldSpace } from "../types/field-space";
|
|
4
4
|
import { HasParameter } from "../parameters/has-parameter";
|
|
5
5
|
import { MalloyElement } from "../types/malloy-element";
|
|
6
|
-
import {
|
|
6
|
+
import { SourceSpec, SpaceSeed } from "../space-seed";
|
|
7
7
|
import { StaticSpace } from "./static-space";
|
|
8
8
|
export declare abstract class DynamicSpace extends StaticSpace {
|
|
9
9
|
protected final: model.StructDef | undefined;
|
|
@@ -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" };
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
exports.QueryField = QueryField;
|
|
@@ -200,8 +200,8 @@ class QuerySpace extends refined_space_1.RefinedSpace {
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
const segment = {
|
|
203
|
-
type: this.segmentType,
|
|
204
|
-
fields: this.queryFieldDefs()
|
|
203
|
+
"type": this.segmentType,
|
|
204
|
+
"fields": this.queryFieldDefs()
|
|
205
205
|
};
|
|
206
206
|
segment.fields = (0, field_utils_1.mergeFields)(refineFrom === null || refineFrom === void 0 ? void 0 : refineFrom.fields, segment.fields);
|
|
207
207
|
if (refineFrom === null || refineFrom === void 0 ? void 0 : refineFrom.extendSource) {
|
|
@@ -38,7 +38,7 @@ class ReferenceField extends space_field_1.SpaceField {
|
|
|
38
38
|
return this.fieldRef.refString;
|
|
39
39
|
}
|
|
40
40
|
typeDesc() {
|
|
41
|
-
return { dataType: "unknown", expressionType: "scalar" };
|
|
41
|
+
return { "dataType": "unknown", "expressionType": "scalar" };
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
exports.ReferenceField = ReferenceField;
|
|
@@ -93,14 +93,14 @@ class StaticSpace {
|
|
|
93
93
|
return this.fromStruct;
|
|
94
94
|
}
|
|
95
95
|
emptyStructDef() {
|
|
96
|
-
return { ...this.fromStruct, fields: [] };
|
|
96
|
+
return { ...this.fromStruct, "fields": [] };
|
|
97
97
|
}
|
|
98
98
|
lookup(path) {
|
|
99
99
|
const head = path[0];
|
|
100
100
|
const rest = path.slice(1);
|
|
101
101
|
const found = this.entry(head.refString);
|
|
102
102
|
if (!found) {
|
|
103
|
-
return { error: `'${head}' is not defined`, found };
|
|
103
|
+
return { "error": `'${head}' is not defined`, found };
|
|
104
104
|
}
|
|
105
105
|
if (found instanceof space_field_1.SpaceField) {
|
|
106
106
|
/*
|
|
@@ -122,12 +122,12 @@ class StaticSpace {
|
|
|
122
122
|
const definition = found.fieldDef();
|
|
123
123
|
if (definition) {
|
|
124
124
|
head.addReference({
|
|
125
|
-
type: found instanceof struct_space_field_base_1.StructSpaceFieldBase
|
|
125
|
+
"type": found instanceof struct_space_field_base_1.StructSpaceFieldBase
|
|
126
126
|
? "joinReference"
|
|
127
127
|
: "fieldReference",
|
|
128
128
|
definition,
|
|
129
|
-
location: head.location,
|
|
130
|
-
text: head.refString
|
|
129
|
+
"location": head.location,
|
|
130
|
+
"text": head.refString
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
}
|
|
@@ -136,11 +136,11 @@ class StaticSpace {
|
|
|
136
136
|
return found.fieldSpace.lookup(rest);
|
|
137
137
|
}
|
|
138
138
|
return {
|
|
139
|
-
error: `'${head}' cannot contain a '${rest[0]}'`,
|
|
140
|
-
found: undefined
|
|
139
|
+
"error": `'${head}' cannot contain a '${rest[0]}'`,
|
|
140
|
+
"found": undefined
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
|
-
return { found, error: undefined };
|
|
143
|
+
return { found, "error": undefined };
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
exports.StaticSpace = StaticSpace;
|
|
@@ -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" };
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
exports.StructSpaceFieldBase = StructSpaceFieldBase;
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.FT = void 0;
|
|
26
26
|
function mkFragType(dType) {
|
|
27
|
-
return { dataType: dType, expressionType: "scalar" };
|
|
27
|
+
return { "dataType": dType, "expressionType": "scalar" };
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Collects functions which operate on fragtype compatible objects
|
|
@@ -95,6 +95,6 @@ FT.anyAtomicT = [
|
|
|
95
95
|
FT.stringT,
|
|
96
96
|
FT.dateT,
|
|
97
97
|
FT.timestampT,
|
|
98
|
-
FT.boolT
|
|
98
|
+
FT.boolT
|
|
99
99
|
];
|
|
100
100
|
//# sourceMappingURL=fragtype-utils.js.map
|
|
@@ -27,7 +27,7 @@ const malloy_types_1 = require("../../../model/malloy_types");
|
|
|
27
27
|
const has_parameter_1 = require("./has-parameter");
|
|
28
28
|
class ConstantParameter extends has_parameter_1.HasParameter {
|
|
29
29
|
constructor(name, value) {
|
|
30
|
-
super({ name, isCondition: false });
|
|
30
|
+
super({ name, "isCondition": false });
|
|
31
31
|
this.value = value;
|
|
32
32
|
this.has({ value });
|
|
33
33
|
}
|
|
@@ -36,17 +36,17 @@ class ConstantParameter extends has_parameter_1.HasParameter {
|
|
|
36
36
|
if (!(0, malloy_types_1.isAtomicFieldType)(cVal.dataType)) {
|
|
37
37
|
this.log(`Unexpected expression type '${cVal.dataType}'`);
|
|
38
38
|
return {
|
|
39
|
-
value: ["XXX-type-mismatch-error-XXX"],
|
|
40
|
-
type: "string",
|
|
41
|
-
name: this.name,
|
|
42
|
-
constant: true
|
|
39
|
+
"value": ["XXX-type-mismatch-error-XXX"],
|
|
40
|
+
"type": "string",
|
|
41
|
+
"name": this.name,
|
|
42
|
+
"constant": true
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
return {
|
|
46
|
-
value: cVal.value,
|
|
47
|
-
type: cVal.dataType,
|
|
48
|
-
name: this.name,
|
|
49
|
-
constant: true
|
|
46
|
+
"value": cVal.value,
|
|
47
|
+
"type": cVal.dataType,
|
|
48
|
+
"name": this.name,
|
|
49
|
+
"constant": true
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
}
|