@malloydata/malloy 0.0.205-dev241028163321 → 0.0.205-dev241028192658
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/functions/util.d.ts +16 -16
- package/dist/dialect/functions/util.js +16 -48
- package/dist/index.d.ts +1 -1
- package/dist/lang/ast/ast-utils.js +1 -1
- package/dist/lang/ast/expressions/binary-boolean.js +27 -4
- package/dist/lang/ast/expressions/binary-numeric.js +25 -2
- package/dist/lang/ast/expressions/boolean.js +25 -2
- package/dist/lang/ast/expressions/case.js +41 -20
- package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +2 -2
- package/dist/lang/ast/expressions/expr-aggregate-function.js +30 -10
- package/dist/lang/ast/expressions/expr-alternation-tree.js +2 -2
- package/dist/lang/ast/expressions/expr-asymmetric.d.ts +2 -0
- package/dist/lang/ast/expressions/expr-asymmetric.js +3 -0
- package/dist/lang/ast/expressions/expr-cast.js +4 -6
- package/dist/lang/ast/expressions/expr-coalesce.js +30 -7
- package/dist/lang/ast/expressions/expr-compare.js +33 -10
- package/dist/lang/ast/expressions/expr-count-distinct.d.ts +2 -0
- package/dist/lang/ast/expressions/expr-count-distinct.js +34 -2
- package/dist/lang/ast/expressions/expr-count.d.ts +1 -0
- package/dist/lang/ast/expressions/expr-count.js +11 -1
- package/dist/lang/ast/expressions/expr-func.d.ts +3 -3
- package/dist/lang/ast/expressions/expr-func.js +41 -15
- package/dist/lang/ast/expressions/expr-granular-time.js +36 -14
- package/dist/lang/ast/expressions/expr-logical-op.js +25 -2
- package/dist/lang/ast/expressions/expr-max.d.ts +3 -4
- package/dist/lang/ast/expressions/expr-max.js +27 -4
- package/dist/lang/ast/expressions/expr-min.d.ts +3 -4
- package/dist/lang/ast/expressions/expr-min.js +27 -4
- package/dist/lang/ast/expressions/expr-minus.js +27 -4
- package/dist/lang/ast/expressions/expr-not.js +26 -3
- package/dist/lang/ast/expressions/expr-now.js +1 -1
- package/dist/lang/ast/expressions/expr-null.js +1 -1
- package/dist/lang/ast/expressions/expr-number.js +5 -1
- package/dist/lang/ast/expressions/expr-props.js +25 -2
- package/dist/lang/ast/expressions/expr-regex.js +1 -1
- package/dist/lang/ast/expressions/expr-string.js +1 -1
- package/dist/lang/ast/expressions/expr-time-extract.js +18 -18
- package/dist/lang/ast/expressions/expr-time.js +4 -4
- package/dist/lang/ast/expressions/expr-ungroup.d.ts +0 -2
- package/dist/lang/ast/expressions/expr-ungroup.js +26 -6
- package/dist/lang/ast/expressions/for-range.js +32 -9
- package/dist/lang/ast/expressions/pick-when.js +46 -25
- package/dist/lang/ast/expressions/range.js +1 -1
- package/dist/lang/ast/expressions/time-literal.js +9 -4
- package/dist/lang/ast/field-space/index-field-space.js +1 -3
- package/dist/lang/ast/field-space/project-field-space.d.ts +1 -1
- package/dist/lang/ast/field-space/project-field-space.js +2 -1
- package/dist/lang/ast/field-space/query-spaces.d.ts +1 -1
- package/dist/lang/ast/field-space/query-spaces.js +4 -3
- package/dist/lang/ast/field-space/reference-field.js +43 -10
- package/dist/lang/ast/field-space/rename-space-field.d.ts +2 -2
- package/dist/lang/ast/field-space/static-space.js +1 -1
- package/dist/lang/ast/field-space/struct-space-field-base.d.ts +2 -2
- package/dist/lang/ast/field-space/struct-space-field-base.js +40 -8
- package/dist/lang/ast/field-space/view-field.d.ts +2 -2
- package/dist/lang/ast/field-space/view-field.js +25 -1
- package/dist/lang/ast/parameters/has-parameter.d.ts +1 -1
- package/dist/lang/ast/parameters/has-parameter.js +8 -8
- package/dist/lang/ast/query-items/field-declaration.d.ts +2 -1
- package/dist/lang/ast/query-items/field-declaration.js +34 -9
- package/dist/lang/ast/query-items/typecheck_utils.js +11 -13
- package/dist/lang/ast/query-properties/filters.js +1 -1
- package/dist/lang/ast/source-elements/named-source.js +2 -2
- package/dist/lang/ast/source-properties/join.js +3 -3
- package/dist/lang/ast/time-utils.d.ts +2 -2
- package/dist/lang/ast/time-utils.js +6 -1
- package/dist/lang/ast/typedesc-utils.d.ts +48 -0
- package/dist/lang/ast/typedesc-utils.js +157 -0
- package/dist/lang/ast/types/expr-result.d.ts +2 -1
- package/dist/lang/ast/types/expr-value.d.ts +11 -36
- package/dist/lang/ast/types/expr-value.js +27 -13
- package/dist/lang/ast/types/expression-def.d.ts +3 -2
- package/dist/lang/ast/types/expression-def.js +84 -60
- package/dist/lang/ast/types/global-name-space.js +2 -2
- package/dist/lang/ast/types/granular-result.d.ts +2 -2
- package/dist/lang/ast/types/granular-result.js +1 -1
- package/dist/lang/ast/types/space-field.js +2 -13
- package/dist/lang/ast/types/space-param.d.ts +3 -1
- package/dist/lang/ast/types/space-param.js +36 -4
- package/dist/lang/ast/types/time-result.d.ts +3 -4
- package/dist/lang/parse-log.d.ts +15 -15
- package/dist/lang/test/literals.spec.js +1 -1
- package/dist/lang/test/parse-expects.js +2 -2
- package/dist/model/malloy_types.d.ts +30 -32
- package/dist/model/malloy_types.js +25 -16
- package/package.json +1 -1
- package/dist/lang/ast/fragtype-utils.d.ts +0 -46
- package/dist/lang/ast/fragtype-utils.js +0 -115
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AtomicTypeDef, TypeDesc } from '../../model';
|
|
2
|
+
export declare const nullT: TypeDesc;
|
|
3
|
+
export declare const numberT: TypeDesc;
|
|
4
|
+
export declare const stringT: TypeDesc;
|
|
5
|
+
export declare const dateT: TypeDesc;
|
|
6
|
+
export declare const timestampT: TypeDesc;
|
|
7
|
+
export declare const boolT: TypeDesc;
|
|
8
|
+
export declare const errorT: TypeDesc;
|
|
9
|
+
export declare const viewT: TypeDesc;
|
|
10
|
+
export declare const aggregateBoolT: TypeDesc;
|
|
11
|
+
export declare const anyAtomicT: TypeDesc[];
|
|
12
|
+
/**
|
|
13
|
+
* Checks if a given type is in a list
|
|
14
|
+
* @param check The type to check (can be undefined)
|
|
15
|
+
* @param from List of types which are OK
|
|
16
|
+
*/
|
|
17
|
+
export declare function any(check: TypeDesc | undefined, from: TypeDesc[]): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if a possibly undefined candidate matches a type
|
|
20
|
+
* @param good The real type
|
|
21
|
+
* @param checkThis The possibly undefined candidate
|
|
22
|
+
*/
|
|
23
|
+
export declare function eq(good: TypeDesc, checkThis: TypeDesc | undefined): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Checks if a given type is in a list, ignoring aggregate
|
|
26
|
+
* @param check The type to check (can be undefined)
|
|
27
|
+
* @param from List of types which are OK
|
|
28
|
+
*/
|
|
29
|
+
export declare function typeIn(check: TypeDesc | undefined, from: TypeDesc[]): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Checks if the base types, ignoring expressionType, are equal
|
|
32
|
+
* @param left Left type
|
|
33
|
+
* @param right Right type
|
|
34
|
+
* @param nullOk True if a NULL is an acceptable match
|
|
35
|
+
*/
|
|
36
|
+
export declare function typeEq(left: TypeDesc, right: TypeDesc, nullOk?: boolean, errorOk?: boolean): boolean;
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* For error messages, returns a comma seperated list of readable names
|
|
40
|
+
* for a list of types.
|
|
41
|
+
* @param types List of type or objects with types
|
|
42
|
+
*/
|
|
43
|
+
export declare function inspect(...types: (TypeDesc | undefined)[]): string;
|
|
44
|
+
/**
|
|
45
|
+
* Used when using a TypeDesc or TypeDesc-like interface to
|
|
46
|
+
* create a field, don't copy the non type fields.
|
|
47
|
+
*/
|
|
48
|
+
export declare function atomicDef(td: AtomicTypeDef | TypeDesc): AtomicTypeDef;
|
|
@@ -0,0 +1,157 @@
|
|
|
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.atomicDef = exports.inspect = exports.typeEq = exports.typeIn = exports.eq = exports.any = exports.anyAtomicT = exports.aggregateBoolT = exports.viewT = exports.errorT = exports.boolT = exports.timestampT = exports.dateT = exports.stringT = exports.numberT = exports.nullT = void 0;
|
|
26
|
+
const model_1 = require("../../model");
|
|
27
|
+
function mkTypeDesc(
|
|
28
|
+
// The problem is that record and array, as currently defined, require a dialect
|
|
29
|
+
// which isn't available. In retrospect the dialect shouldn't be in the type,
|
|
30
|
+
// it should only be in the field, which I wil do eventually.
|
|
31
|
+
dataType, expressionType = 'scalar', evalSpace = 'constant') {
|
|
32
|
+
return { type: dataType, expressionType, evalSpace };
|
|
33
|
+
}
|
|
34
|
+
exports.nullT = mkTypeDesc('null');
|
|
35
|
+
exports.numberT = mkTypeDesc('number');
|
|
36
|
+
exports.stringT = mkTypeDesc('string');
|
|
37
|
+
exports.dateT = mkTypeDesc('date');
|
|
38
|
+
exports.timestampT = mkTypeDesc('timestamp');
|
|
39
|
+
exports.boolT = mkTypeDesc('boolean');
|
|
40
|
+
exports.errorT = mkTypeDesc('error');
|
|
41
|
+
exports.viewT = mkTypeDesc('turtle');
|
|
42
|
+
exports.aggregateBoolT = mkTypeDesc('boolean', 'aggregate');
|
|
43
|
+
exports.anyAtomicT = [exports.numberT, exports.stringT, exports.dateT, exports.timestampT, exports.boolT];
|
|
44
|
+
/**
|
|
45
|
+
* Checks if a given type is in a list
|
|
46
|
+
* @param check The type to check (can be undefined)
|
|
47
|
+
* @param from List of types which are OK
|
|
48
|
+
*/
|
|
49
|
+
function any(check, from) {
|
|
50
|
+
if (check) {
|
|
51
|
+
const found = from.find(okType => eq(okType, check));
|
|
52
|
+
return found !== undefined;
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
exports.any = any;
|
|
57
|
+
/**
|
|
58
|
+
* Checks if a possibly undefined candidate matches a type
|
|
59
|
+
* @param good The real type
|
|
60
|
+
* @param checkThis The possibly undefined candidate
|
|
61
|
+
*/
|
|
62
|
+
function eq(good, checkThis) {
|
|
63
|
+
return (checkThis !== undefined &&
|
|
64
|
+
model_1.TD.eq(good, checkThis) &&
|
|
65
|
+
good.expressionType === checkThis.expressionType);
|
|
66
|
+
}
|
|
67
|
+
exports.eq = eq;
|
|
68
|
+
/**
|
|
69
|
+
* Checks if a given type is in a list, ignoring aggregate
|
|
70
|
+
* @param check The type to check (can be undefined)
|
|
71
|
+
* @param from List of types which are OK
|
|
72
|
+
*/
|
|
73
|
+
function typeIn(check, from) {
|
|
74
|
+
if (check) {
|
|
75
|
+
const found = from.find(okType => typeEq(okType, check));
|
|
76
|
+
return found !== undefined;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
exports.typeIn = typeIn;
|
|
81
|
+
/**
|
|
82
|
+
* Checks if the base types, ignoring expressionType, are equal
|
|
83
|
+
* @param left Left type
|
|
84
|
+
* @param right Right type
|
|
85
|
+
* @param nullOk True if a NULL is an acceptable match
|
|
86
|
+
*/
|
|
87
|
+
function typeEq(left, right, nullOk = false, errorOk = true) {
|
|
88
|
+
const maybeEq = model_1.TD.eq(left, right);
|
|
89
|
+
const nullEq = nullOk && (left.type === 'null' || right.type === 'null');
|
|
90
|
+
const errorEq = errorOk && (left.type === 'error' || right.type === 'error');
|
|
91
|
+
return maybeEq || nullEq || errorEq;
|
|
92
|
+
}
|
|
93
|
+
exports.typeEq = typeEq;
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* For error messages, returns a comma seperated list of readable names
|
|
97
|
+
* for a list of types.
|
|
98
|
+
* @param types List of type or objects with types
|
|
99
|
+
*/
|
|
100
|
+
function inspect(...types) {
|
|
101
|
+
const strings = types.map(type => {
|
|
102
|
+
if (type) {
|
|
103
|
+
let inspected = type.type;
|
|
104
|
+
if (!(0, model_1.expressionIsScalar)(type.expressionType)) {
|
|
105
|
+
inspected = `${type.expressionType} ${inspected}`;
|
|
106
|
+
}
|
|
107
|
+
return inspected;
|
|
108
|
+
}
|
|
109
|
+
return 'undefined';
|
|
110
|
+
});
|
|
111
|
+
return strings.join(',');
|
|
112
|
+
}
|
|
113
|
+
exports.inspect = inspect;
|
|
114
|
+
/**
|
|
115
|
+
* Used when using a TypeDesc or TypeDesc-like interface to
|
|
116
|
+
* create a field, don't copy the non type fields.
|
|
117
|
+
*/
|
|
118
|
+
function atomicDef(td) {
|
|
119
|
+
if (model_1.TD.isAtomic(td)) {
|
|
120
|
+
switch (td.type) {
|
|
121
|
+
case 'array': {
|
|
122
|
+
return {
|
|
123
|
+
name: '',
|
|
124
|
+
type: 'array',
|
|
125
|
+
join: 'many',
|
|
126
|
+
elementTypeDef: td.elementTypeDef,
|
|
127
|
+
dialect: td.dialect,
|
|
128
|
+
fields: td.fields,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
case 'record': {
|
|
132
|
+
return {
|
|
133
|
+
name: '',
|
|
134
|
+
type: 'record',
|
|
135
|
+
join: 'one',
|
|
136
|
+
dialect: td.dialect,
|
|
137
|
+
fields: td.fields,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
case 'number': {
|
|
141
|
+
return td.numberType
|
|
142
|
+
? { type: 'number', numberType: td.numberType }
|
|
143
|
+
: { type: 'number' };
|
|
144
|
+
}
|
|
145
|
+
case 'sql native': {
|
|
146
|
+
return td.rawType
|
|
147
|
+
? { type: 'sql native', rawType: td.rawType }
|
|
148
|
+
: { type: 'sql native' };
|
|
149
|
+
}
|
|
150
|
+
default:
|
|
151
|
+
return { type: td.type };
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return { type: 'error' };
|
|
155
|
+
}
|
|
156
|
+
exports.atomicDef = atomicDef;
|
|
157
|
+
//# sourceMappingURL=typedesc-utils.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Expr, TypeDesc } from '../../../model/malloy_types';
|
|
2
2
|
type MorphicValues = Record<string, Expr>;
|
|
3
|
-
export interface
|
|
3
|
+
export interface WithValue {
|
|
4
4
|
value: Expr;
|
|
5
5
|
morphic?: MorphicValues;
|
|
6
6
|
}
|
|
7
|
+
export type ExprResult = TypeDesc & WithValue;
|
|
7
8
|
export {};
|
|
@@ -1,54 +1,29 @@
|
|
|
1
|
-
import { Expr,
|
|
1
|
+
import { Expr, ExpressionValueTypeDef, TemporalTypeDef, TimestampUnit } from '../../../model';
|
|
2
2
|
import { ExprResult } from './expr-result';
|
|
3
3
|
import { TimeResult } from './time-result';
|
|
4
4
|
export type ExprValue = ExprResult | TimeResult;
|
|
5
|
-
export declare function computedExprValue({ value, dataType,
|
|
5
|
+
export declare function computedExprValue({ value, dataType, from, }: {
|
|
6
6
|
value: Expr;
|
|
7
|
-
dataType:
|
|
8
|
-
rawType?: string;
|
|
7
|
+
dataType: ExpressionValueTypeDef;
|
|
9
8
|
from: ExprValue[];
|
|
10
9
|
}): ExprValue;
|
|
11
|
-
export declare function computedTimeResult({ value, dataType,
|
|
10
|
+
export declare function computedTimeResult({ value, dataType, from, timeframe, }: {
|
|
12
11
|
value: Expr;
|
|
13
|
-
|
|
14
|
-
dataType: TemporalFieldType;
|
|
12
|
+
dataType: TemporalTypeDef;
|
|
15
13
|
timeframe?: TimestampUnit;
|
|
16
14
|
from: ExprValue[];
|
|
17
|
-
}):
|
|
18
|
-
|
|
19
|
-
value: Expr;
|
|
20
|
-
morphic?: {
|
|
21
|
-
[x: string]: Expr;
|
|
22
|
-
} | undefined;
|
|
23
|
-
dataType: FieldValueType;
|
|
24
|
-
expressionType: import("../../../model").ExpressionType;
|
|
25
|
-
rawType?: string | undefined;
|
|
26
|
-
evalSpace: import("../../../model").EvalSpace;
|
|
27
|
-
} | {
|
|
28
|
-
timeframe: TimestampUnit | undefined;
|
|
29
|
-
dataType: TemporalFieldType;
|
|
30
|
-
value: Expr;
|
|
31
|
-
morphic?: {
|
|
32
|
-
[x: string]: Expr;
|
|
33
|
-
} | undefined;
|
|
34
|
-
expressionType: import("../../../model").ExpressionType;
|
|
35
|
-
rawType?: string | undefined;
|
|
36
|
-
evalSpace: import("../../../model").EvalSpace;
|
|
37
|
-
};
|
|
38
|
-
export declare function computedErrorExprValue({ dataType, rawType, from, error, }: {
|
|
15
|
+
}): TimeResult;
|
|
16
|
+
export declare function computedErrorExprValue({ dataType, from, error, }: {
|
|
39
17
|
error: string;
|
|
40
|
-
|
|
41
|
-
dataType?: FieldValueType;
|
|
18
|
+
dataType?: ExpressionValueTypeDef;
|
|
42
19
|
from: ExprValue[];
|
|
43
20
|
}): ExprValue;
|
|
44
21
|
export declare function literalExprValue(options: {
|
|
45
22
|
value: Expr;
|
|
46
|
-
|
|
47
|
-
dataType: FieldValueType;
|
|
23
|
+
dataType: ExpressionValueTypeDef;
|
|
48
24
|
}): ExprValue;
|
|
49
|
-
export declare function literalTimeResult({ value, dataType,
|
|
25
|
+
export declare function literalTimeResult({ value, dataType, timeframe, }: {
|
|
50
26
|
value: Expr;
|
|
51
|
-
|
|
52
|
-
dataType: TemporalFieldType;
|
|
27
|
+
dataType: TemporalTypeDef;
|
|
53
28
|
timeframe?: TimestampUnit;
|
|
54
29
|
}): TimeResult;
|
|
@@ -24,24 +24,32 @@
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.literalTimeResult = exports.literalExprValue = exports.computedErrorExprValue = exports.computedTimeResult = exports.computedExprValue = void 0;
|
|
26
26
|
const model_1 = require("../../../model");
|
|
27
|
-
function computedExprValue({ value, dataType,
|
|
27
|
+
function computedExprValue({ value, dataType, from, }) {
|
|
28
28
|
return {
|
|
29
|
+
...dataType,
|
|
29
30
|
value,
|
|
30
|
-
dataType,
|
|
31
|
-
rawType,
|
|
32
31
|
expressionType: (0, model_1.maxOfExpressionTypes)(from.map(e => e.expressionType)),
|
|
33
32
|
evalSpace: (0, model_1.mergeEvalSpaces)(...from.map(e => e.evalSpace)),
|
|
34
33
|
};
|
|
35
34
|
}
|
|
36
35
|
exports.computedExprValue = computedExprValue;
|
|
37
|
-
function computedTimeResult({ value, dataType,
|
|
38
|
-
|
|
36
|
+
function computedTimeResult({ value, dataType, from, timeframe, }) {
|
|
37
|
+
const xv = computedExprValue({ value, dataType, from });
|
|
38
|
+
const y = {
|
|
39
|
+
...dataType,
|
|
40
|
+
expressionType: xv.expressionType,
|
|
41
|
+
evalSpace: xv.evalSpace,
|
|
42
|
+
value: xv.value,
|
|
43
|
+
};
|
|
44
|
+
if (timeframe) {
|
|
45
|
+
y.timeframe = timeframe;
|
|
46
|
+
}
|
|
47
|
+
return y;
|
|
39
48
|
}
|
|
40
49
|
exports.computedTimeResult = computedTimeResult;
|
|
41
|
-
function computedErrorExprValue({ dataType,
|
|
50
|
+
function computedErrorExprValue({ dataType, from, error, }) {
|
|
42
51
|
return computedExprValue({
|
|
43
|
-
dataType: dataType
|
|
44
|
-
rawType,
|
|
52
|
+
dataType: dataType !== null && dataType !== void 0 ? dataType : { type: 'error' },
|
|
45
53
|
value: { node: 'error', message: error },
|
|
46
54
|
from,
|
|
47
55
|
});
|
|
@@ -52,12 +60,18 @@ function literalExprValue(options) {
|
|
|
52
60
|
return computedExprValue({ ...options, from: [] });
|
|
53
61
|
}
|
|
54
62
|
exports.literalExprValue = literalExprValue;
|
|
55
|
-
function literalTimeResult({ value, dataType,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
dataType,
|
|
59
|
-
|
|
63
|
+
function literalTimeResult({ value, dataType, timeframe, }) {
|
|
64
|
+
const xv = computedExprValue({ value, dataType, from: [] });
|
|
65
|
+
const y = {
|
|
66
|
+
...dataType,
|
|
67
|
+
expressionType: xv.expressionType,
|
|
68
|
+
evalSpace: xv.evalSpace,
|
|
69
|
+
value: xv.value,
|
|
60
70
|
};
|
|
71
|
+
if (timeframe) {
|
|
72
|
+
y.timeframe = timeframe;
|
|
73
|
+
}
|
|
74
|
+
return y;
|
|
61
75
|
}
|
|
62
76
|
exports.literalTimeResult = literalTimeResult;
|
|
63
77
|
//# sourceMappingURL=expr-value.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TimestampUnit
|
|
1
|
+
import { TimestampUnit } from '../../../model/malloy_types';
|
|
2
2
|
import { ExprValue } from './expr-value';
|
|
3
3
|
import { FieldSpace } from './field-space';
|
|
4
4
|
import { MalloyElement } from './malloy-element';
|
|
@@ -69,7 +69,8 @@ export declare class ExprDuration extends ExpressionDef {
|
|
|
69
69
|
apply(fs: FieldSpace, op: BinaryMalloyOperator, left: ExpressionDef): ExprValue;
|
|
70
70
|
getExpression(fs: FieldSpace): ExprValue;
|
|
71
71
|
}
|
|
72
|
-
export
|
|
72
|
+
export type MorphicType = 'date' | 'timestamp';
|
|
73
|
+
export declare function getMorphicValue(mv: ExprValue, mt: MorphicType): ExprValue | undefined;
|
|
73
74
|
/**
|
|
74
75
|
* All of the magic of malloy expressions eventually flows to here,
|
|
75
76
|
* where an operator is applied to two values. Depending on the
|