@malloydata/malloy 0.0.36-dev230524224445 → 0.0.36-dev230525034638
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/lang/ast/expressions/expr-coalesce.d.ts +11 -0
- package/dist/lang/ast/expressions/expr-coalesce.js +59 -0
- package/dist/lang/ast/index.d.ts +1 -0
- package/dist/lang/ast/index.js +1 -0
- package/dist/lang/lib/Malloy/MalloyLexer.d.ts +71 -70
- package/dist/lang/lib/Malloy/MalloyLexer.js +1025 -1020
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +111 -86
- package/dist/lang/lib/Malloy/MalloyParser.js +767 -638
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +62 -23
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +38 -14
- package/dist/lang/malloy-to-ast.d.ts +5 -2
- package/dist/lang/malloy-to-ast.js +19 -7
- package/dist/lang/test/parse.spec.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ExprValue } from '../types/expr-value';
|
|
2
|
+
import { ExpressionDef } from '../types/expression-def';
|
|
3
|
+
import { FieldSpace } from '../types/field-space';
|
|
4
|
+
export declare class ExprCoalesce extends ExpressionDef {
|
|
5
|
+
readonly expr: ExpressionDef;
|
|
6
|
+
readonly altExpr: ExpressionDef;
|
|
7
|
+
elementType: string;
|
|
8
|
+
legalChildTypes: import("../types/type-desc").TypeDesc[];
|
|
9
|
+
constructor(expr: ExpressionDef, altExpr: ExpressionDef);
|
|
10
|
+
getExpression(fs: FieldSpace): ExprValue;
|
|
11
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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.ExprCoalesce = void 0;
|
|
26
|
+
const model_1 = require("../../../model");
|
|
27
|
+
const fragtype_utils_1 = require("../fragtype-utils");
|
|
28
|
+
const expression_def_1 = require("../types/expression-def");
|
|
29
|
+
class ExprCoalesce extends expression_def_1.ExpressionDef {
|
|
30
|
+
constructor(expr, altExpr) {
|
|
31
|
+
super({ expr, altExpr });
|
|
32
|
+
this.expr = expr;
|
|
33
|
+
this.altExpr = altExpr;
|
|
34
|
+
this.elementType = 'coalesce expression';
|
|
35
|
+
this.legalChildTypes = fragtype_utils_1.FT.anyAtomicT;
|
|
36
|
+
}
|
|
37
|
+
getExpression(fs) {
|
|
38
|
+
const maybeNull = this.expr.getExpression(fs);
|
|
39
|
+
const whenNull = this.altExpr.getExpression(fs);
|
|
40
|
+
if (maybeNull.dataType === 'null') {
|
|
41
|
+
return whenNull;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Could maybe walk altExpr to combine all the times that altExpr
|
|
45
|
+
* is also an ExprCoalesce into a single fragment. Not doing that now.
|
|
46
|
+
*
|
|
47
|
+
* Also this should maybe generate a dialect fragment and not write
|
|
48
|
+
* SQL, but I decided that is will happen when the "expressions are true
|
|
49
|
+
* trees" rewrite happens.
|
|
50
|
+
*/
|
|
51
|
+
return {
|
|
52
|
+
...whenNull,
|
|
53
|
+
expressionType: (0, model_1.maxExpressionType)(maybeNull.expressionType, whenNull.expressionType),
|
|
54
|
+
value: (0, model_1.mkExpr) `COALESCE(${maybeNull.value},${whenNull.value})`,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.ExprCoalesce = ExprCoalesce;
|
|
59
|
+
//# sourceMappingURL=expr-coalesce.js.map
|
package/dist/lang/ast/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from './expressions/expr-alternation-tree';
|
|
|
17
17
|
export * from './expressions/expr-asymmetric';
|
|
18
18
|
export * from './expressions/expr-avg';
|
|
19
19
|
export * from './expressions/expr-cast';
|
|
20
|
+
export * from './expressions/expr-coalesce';
|
|
20
21
|
export * from './expressions/expr-compare';
|
|
21
22
|
export * from './expressions/expr-count';
|
|
22
23
|
export * from './expressions/expr-count-distinct';
|
package/dist/lang/ast/index.js
CHANGED
|
@@ -55,6 +55,7 @@ __exportStar(require("./expressions/expr-alternation-tree"), exports);
|
|
|
55
55
|
__exportStar(require("./expressions/expr-asymmetric"), exports);
|
|
56
56
|
__exportStar(require("./expressions/expr-avg"), exports);
|
|
57
57
|
__exportStar(require("./expressions/expr-cast"), exports);
|
|
58
|
+
__exportStar(require("./expressions/expr-coalesce"), exports);
|
|
58
59
|
__exportStar(require("./expressions/expr-compare"), exports);
|
|
59
60
|
__exportStar(require("./expressions/expr-count"), exports);
|
|
60
61
|
__exportStar(require("./expressions/expr-count-distinct"), exports);
|
|
@@ -71,76 +71,77 @@ export declare class MalloyLexer extends Lexer {
|
|
|
71
71
|
static readonly ON = 66;
|
|
72
72
|
static readonly OR = 67;
|
|
73
73
|
static readonly PICK = 68;
|
|
74
|
-
static readonly
|
|
75
|
-
static readonly
|
|
76
|
-
static readonly
|
|
77
|
-
static readonly
|
|
78
|
-
static readonly
|
|
79
|
-
static readonly
|
|
80
|
-
static readonly
|
|
81
|
-
static readonly
|
|
82
|
-
static readonly
|
|
83
|
-
static readonly
|
|
84
|
-
static readonly
|
|
85
|
-
static readonly
|
|
86
|
-
static readonly
|
|
87
|
-
static readonly
|
|
88
|
-
static readonly
|
|
89
|
-
static readonly
|
|
90
|
-
static readonly
|
|
91
|
-
static readonly
|
|
92
|
-
static readonly
|
|
93
|
-
static readonly
|
|
94
|
-
static readonly
|
|
95
|
-
static readonly
|
|
96
|
-
static readonly
|
|
97
|
-
static readonly
|
|
98
|
-
static readonly
|
|
99
|
-
static readonly
|
|
100
|
-
static readonly
|
|
101
|
-
static readonly
|
|
102
|
-
static readonly
|
|
103
|
-
static readonly
|
|
104
|
-
static readonly
|
|
105
|
-
static readonly
|
|
106
|
-
static readonly
|
|
107
|
-
static readonly
|
|
108
|
-
static readonly
|
|
109
|
-
static readonly
|
|
110
|
-
static readonly
|
|
111
|
-
static readonly
|
|
112
|
-
static readonly
|
|
113
|
-
static readonly
|
|
114
|
-
static readonly
|
|
115
|
-
static readonly
|
|
116
|
-
static readonly
|
|
117
|
-
static readonly
|
|
118
|
-
static readonly
|
|
119
|
-
static readonly
|
|
120
|
-
static readonly
|
|
121
|
-
static readonly
|
|
122
|
-
static readonly
|
|
123
|
-
static readonly
|
|
124
|
-
static readonly
|
|
125
|
-
static readonly
|
|
126
|
-
static readonly
|
|
127
|
-
static readonly
|
|
128
|
-
static readonly
|
|
129
|
-
static readonly
|
|
130
|
-
static readonly
|
|
131
|
-
static readonly
|
|
132
|
-
static readonly
|
|
133
|
-
static readonly
|
|
134
|
-
static readonly
|
|
135
|
-
static readonly
|
|
136
|
-
static readonly
|
|
137
|
-
static readonly
|
|
138
|
-
static readonly
|
|
139
|
-
static readonly
|
|
140
|
-
static readonly
|
|
141
|
-
static readonly
|
|
142
|
-
static readonly
|
|
143
|
-
static readonly
|
|
74
|
+
static readonly QUARTER = 69;
|
|
75
|
+
static readonly SECOND = 70;
|
|
76
|
+
static readonly STRING = 71;
|
|
77
|
+
static readonly SUM = 72;
|
|
78
|
+
static readonly TABLE = 73;
|
|
79
|
+
static readonly THEN = 74;
|
|
80
|
+
static readonly THIS = 75;
|
|
81
|
+
static readonly TIMESTAMP = 76;
|
|
82
|
+
static readonly TO = 77;
|
|
83
|
+
static readonly TRUE = 78;
|
|
84
|
+
static readonly TURTLE = 79;
|
|
85
|
+
static readonly WEEK = 80;
|
|
86
|
+
static readonly WHEN = 81;
|
|
87
|
+
static readonly WITH = 82;
|
|
88
|
+
static readonly YEAR = 83;
|
|
89
|
+
static readonly UNGROUPED = 84;
|
|
90
|
+
static readonly STRING_ESCAPE = 85;
|
|
91
|
+
static readonly HACKY_REGEX = 86;
|
|
92
|
+
static readonly STRING_LITERAL = 87;
|
|
93
|
+
static readonly AMPER = 88;
|
|
94
|
+
static readonly ARROW = 89;
|
|
95
|
+
static readonly FAT_ARROW = 90;
|
|
96
|
+
static readonly OPAREN = 91;
|
|
97
|
+
static readonly CPAREN = 92;
|
|
98
|
+
static readonly OBRACK = 93;
|
|
99
|
+
static readonly CBRACK = 94;
|
|
100
|
+
static readonly OCURLY = 95;
|
|
101
|
+
static readonly CCURLY = 96;
|
|
102
|
+
static readonly DOUBLECOLON = 97;
|
|
103
|
+
static readonly COLON = 98;
|
|
104
|
+
static readonly COMMA = 99;
|
|
105
|
+
static readonly DOT = 100;
|
|
106
|
+
static readonly LT = 101;
|
|
107
|
+
static readonly GT = 102;
|
|
108
|
+
static readonly EQ = 103;
|
|
109
|
+
static readonly NE = 104;
|
|
110
|
+
static readonly LTE = 105;
|
|
111
|
+
static readonly GTE = 106;
|
|
112
|
+
static readonly PLUS = 107;
|
|
113
|
+
static readonly MINUS = 108;
|
|
114
|
+
static readonly STAR = 109;
|
|
115
|
+
static readonly STARSTAR = 110;
|
|
116
|
+
static readonly SLASH = 111;
|
|
117
|
+
static readonly BAR = 112;
|
|
118
|
+
static readonly SEMI = 113;
|
|
119
|
+
static readonly NOT_MATCH = 114;
|
|
120
|
+
static readonly MATCH = 115;
|
|
121
|
+
static readonly PERCENT = 116;
|
|
122
|
+
static readonly DOUBLE_QMARK = 117;
|
|
123
|
+
static readonly QMARK = 118;
|
|
124
|
+
static readonly LITERAL_TIMESTAMP = 119;
|
|
125
|
+
static readonly LITERAL_HOUR = 120;
|
|
126
|
+
static readonly LITERAL_DAY = 121;
|
|
127
|
+
static readonly LITERAL_QUARTER = 122;
|
|
128
|
+
static readonly LITERAL_MONTH = 123;
|
|
129
|
+
static readonly LITERAL_WEEK = 124;
|
|
130
|
+
static readonly LITERAL_YEAR = 125;
|
|
131
|
+
static readonly IDENTIFIER = 126;
|
|
132
|
+
static readonly PERCENT_LITERAL = 127;
|
|
133
|
+
static readonly INTEGER_LITERAL = 128;
|
|
134
|
+
static readonly NUMERIC_LITERAL = 129;
|
|
135
|
+
static readonly OBJECT_NAME_LITERAL = 130;
|
|
136
|
+
static readonly BLOCK_COMMENT = 131;
|
|
137
|
+
static readonly COMMENT_TO_EOL = 132;
|
|
138
|
+
static readonly WHITE_SPACE = 133;
|
|
139
|
+
static readonly SQL_BEGIN = 134;
|
|
140
|
+
static readonly CLOSE_CODE = 135;
|
|
141
|
+
static readonly UNWATED_CHARS_TRAILING_NUMBERS = 136;
|
|
142
|
+
static readonly UNEXPECTED_CHAR = 137;
|
|
143
|
+
static readonly OPEN_CODE = 138;
|
|
144
|
+
static readonly SQL_END = 139;
|
|
144
145
|
static readonly SQL_MODE = 1;
|
|
145
146
|
static readonly channelNames: string[];
|
|
146
147
|
static readonly modeNames: string[];
|