@malloydata/malloy 0.0.1
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/README.md +39 -0
- package/dist/connection_utils.d.ts +1 -0
- package/dist/connection_utils.js +56 -0
- package/dist/dialect/dialect-map.d.ts +3 -0
- package/dist/dialect/dialect-map.js +33 -0
- package/dist/dialect/dialect.d.ts +64 -0
- package/dist/dialect/dialect.js +64 -0
- package/dist/dialect/dialect_map.d.ts +3 -0
- package/dist/dialect/dialect_map.js +35 -0
- package/dist/dialect/duckdb.d.ts +49 -0
- package/dist/dialect/duckdb.js +349 -0
- package/dist/dialect/index.d.ts +6 -0
- package/dist/dialect/index.js +27 -0
- package/dist/dialect/postgres.d.ts +49 -0
- package/dist/dialect/postgres.js +308 -0
- package/dist/dialect/standardsql.d.ts +46 -0
- package/dist/dialect/standardsql.js +361 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +47 -0
- package/dist/lang/ast/apply-expr.d.ts +16 -0
- package/dist/lang/ast/apply-expr.js +215 -0
- package/dist/lang/ast/ast-expr.d.ts +291 -0
- package/dist/lang/ast/ast-expr.js +1056 -0
- package/dist/lang/ast/ast-main.d.ts +480 -0
- package/dist/lang/ast/ast-main.js +2096 -0
- package/dist/lang/ast/ast-time-expr.d.ts +109 -0
- package/dist/lang/ast/ast-time-expr.js +550 -0
- package/dist/lang/ast/ast-types.d.ts +83 -0
- package/dist/lang/ast/ast-types.js +215 -0
- package/dist/lang/ast/index.d.ts +5 -0
- package/dist/lang/ast/index.js +34 -0
- package/dist/lang/ast/time-utils.d.ts +8 -0
- package/dist/lang/ast/time-utils.js +83 -0
- package/dist/lang/field-space.d.ts +157 -0
- package/dist/lang/field-space.js +651 -0
- package/dist/lang/field-utils.d.ts +5 -0
- package/dist/lang/field-utils.js +33 -0
- package/dist/lang/index.d.ts +9 -0
- package/dist/lang/index.js +22 -0
- package/dist/lang/lib/Malloy/MalloyLexer.d.ts +156 -0
- package/dist/lang/lib/Malloy/MalloyLexer.js +1163 -0
- package/dist/lang/lib/Malloy/MalloyListener.d.ts +2026 -0
- package/dist/lang/lib/Malloy/MalloyListener.js +4 -0
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +1920 -0
- package/dist/lang/lib/Malloy/MalloyParser.js +11790 -0
- package/dist/lang/lib/Malloy/MalloyVisitor.d.ts +1276 -0
- package/dist/lang/lib/Malloy/MalloyVisitor.js +4 -0
- package/dist/lang/parse-log.d.ts +27 -0
- package/dist/lang/parse-log.js +41 -0
- package/dist/lang/parse-malloy.d.ts +245 -0
- package/dist/lang/parse-malloy.js +729 -0
- package/dist/lang/parse-to-ast.d.ts +156 -0
- package/dist/lang/parse-to-ast.js +945 -0
- package/dist/lang/parse-tree-walkers/document-completion-walker.d.ts +10 -0
- package/dist/lang/parse-tree-walkers/document-completion-walker.js +136 -0
- package/dist/lang/parse-tree-walkers/document-help-context-walker.d.ts +9 -0
- package/dist/lang/parse-tree-walkers/document-help-context-walker.js +97 -0
- package/dist/lang/parse-tree-walkers/document-highlight-walker.d.ts +83 -0
- package/dist/lang/parse-tree-walkers/document-highlight-walker.js +375 -0
- package/dist/lang/parse-tree-walkers/document-symbol-walker.d.ts +11 -0
- package/dist/lang/parse-tree-walkers/document-symbol-walker.js +172 -0
- package/dist/lang/parse-tree-walkers/explore-query-walker.d.ts +34 -0
- package/dist/lang/parse-tree-walkers/explore-query-walker.js +64 -0
- package/dist/lang/parse-tree-walkers/find-external-references.d.ts +11 -0
- package/dist/lang/parse-tree-walkers/find-external-references.js +51 -0
- package/dist/lang/reference-list.d.ts +10 -0
- package/dist/lang/reference-list.js +80 -0
- package/dist/lang/space-field.d.ts +119 -0
- package/dist/lang/space-field.js +339 -0
- package/dist/lang/test/document-help-context-walker.spec.d.ts +1 -0
- package/dist/lang/test/document-help-context-walker.spec.js +45 -0
- package/dist/lang/test/document-symbol-walker.spec.d.ts +1 -0
- package/dist/lang/test/document-symbol-walker.spec.js +100 -0
- package/dist/lang/test/field-symbols.spec.d.ts +1 -0
- package/dist/lang/test/field-symbols.spec.js +172 -0
- package/dist/lang/test/parse.spec.d.ts +12 -0
- package/dist/lang/test/parse.spec.js +1936 -0
- package/dist/lang/test/test-translator.d.ts +38 -0
- package/dist/lang/test/test-translator.js +334 -0
- package/dist/lang/zone.d.ts +57 -0
- package/dist/lang/zone.js +97 -0
- package/dist/malloy.d.ts +1134 -0
- package/dist/malloy.js +2354 -0
- package/dist/model/index.d.ts +2 -0
- package/dist/model/index.js +34 -0
- package/dist/model/malloy-query.d.ts +313 -0
- package/dist/model/malloy-query.js +2603 -0
- package/dist/model/malloy-types.d.ts +404 -0
- package/dist/model/malloy-types.js +242 -0
- package/dist/model/malloy_query.d.ts +353 -0
- package/dist/model/malloy_query.js +2990 -0
- package/dist/model/malloy_types.d.ts +502 -0
- package/dist/model/malloy_types.js +283 -0
- package/dist/model/sql-block.d.ts +11 -0
- package/dist/model/sql-block.js +38 -0
- package/dist/model/sql_block.d.ts +11 -0
- package/dist/model/sql_block.js +41 -0
- package/dist/model/utils.d.ts +21 -0
- package/dist/model/utils.js +84 -0
- package/dist/runtime-types.d.ts +116 -0
- package/dist/runtime-types.js +40 -0
- package/dist/runtime_types.d.ts +119 -0
- package/dist/runtime_types.js +15 -0
- package/package.json +36 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { By, AtomicFieldType, FieldTypeDef, Fragment, TimeFieldType } from "../../model/malloy_types";
|
|
2
|
+
import { FSPair, FieldSpace } from "../field-space";
|
|
3
|
+
import { Filter, MalloyElement, ExprValue, FieldValueType, FragType } from "./index";
|
|
4
|
+
import { FieldName, FieldReference } from "./ast-main";
|
|
5
|
+
/**
|
|
6
|
+
* Root node for any element in an expression. These essentially
|
|
7
|
+
* create a sub-tree in the larger AST. Expression nodes know
|
|
8
|
+
* how to write themselves as SQL (or rather, generate the
|
|
9
|
+
* template for SQL required by the query writer)
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class ExpressionDef extends MalloyElement {
|
|
12
|
+
abstract elementType: string;
|
|
13
|
+
granular(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the "translation" or template for SQL generation. When asking
|
|
16
|
+
* for a tranlsation you may pass the types you can accept, allowing
|
|
17
|
+
* the translation code a chance to convert to match your expectations
|
|
18
|
+
* @param space Namespace for looking up field references
|
|
19
|
+
*/
|
|
20
|
+
abstract getExpression(fs: FSPair): ExprValue;
|
|
21
|
+
legalChildTypes: FragType[];
|
|
22
|
+
/**
|
|
23
|
+
* Some operators want to give the right hand value a chance to
|
|
24
|
+
* rewrite itself. This requests a translation for a rewrite,
|
|
25
|
+
* or returns undefined if that request should be denied.
|
|
26
|
+
* @param fs FieldSpace
|
|
27
|
+
* @returns Translated expression or undefined
|
|
28
|
+
*/
|
|
29
|
+
requestExpression(fs: FSPair): ExprValue | undefined;
|
|
30
|
+
defaultFieldName(): string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Check an expression for type compatibility
|
|
33
|
+
* @param _eNode currently unused, will be used to get error location
|
|
34
|
+
* @param eVal ...list of expressions that must match legalChildTypes
|
|
35
|
+
*/
|
|
36
|
+
typeCheck(eNode: ExpressionDef, eVal: ExprValue): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* This is the operation which makes partial comparison and value trees work
|
|
39
|
+
* The default implemention merely constructs LEFT OP RIGHT, but specialized
|
|
40
|
+
* nodes like alternation trees or or partial comparison can control how
|
|
41
|
+
* the appplication gets generated
|
|
42
|
+
* @param fs The symbol table
|
|
43
|
+
* @param op The operator being applied
|
|
44
|
+
* @param expr The "other" (besdies 'this') value
|
|
45
|
+
* @returns The translated expression
|
|
46
|
+
*/
|
|
47
|
+
apply(fs: FSPair, op: string, left: ExpressionDef): ExprValue;
|
|
48
|
+
}
|
|
49
|
+
export declare class ConstantSubExpression extends ExpressionDef {
|
|
50
|
+
readonly expr: ExpressionDef;
|
|
51
|
+
elementType: string;
|
|
52
|
+
private cfs?;
|
|
53
|
+
constructor(expr: ExpressionDef);
|
|
54
|
+
getExpression(_fs: FSPair): ExprValue;
|
|
55
|
+
private get constantFs();
|
|
56
|
+
constantValue(): ExprValue;
|
|
57
|
+
constantCondition(type: AtomicFieldType): ExprValue;
|
|
58
|
+
apply(fs: FSPair, op: string, expr: ExpressionDef): ExprValue;
|
|
59
|
+
requestExpression(fs: FSPair): ExprValue | undefined;
|
|
60
|
+
}
|
|
61
|
+
export declare class FieldDeclaration extends MalloyElement {
|
|
62
|
+
readonly expr: ExpressionDef;
|
|
63
|
+
readonly defineName: string;
|
|
64
|
+
readonly exprSrc?: string | undefined;
|
|
65
|
+
elementType: string;
|
|
66
|
+
isMeasure?: boolean;
|
|
67
|
+
constructor(expr: ExpressionDef, defineName: string, exprSrc?: string | undefined);
|
|
68
|
+
fieldDef(fs: FieldSpace, exprName: string): FieldTypeDef;
|
|
69
|
+
queryFieldDef(exprFS: FSPair, exprName: string): FieldTypeDef;
|
|
70
|
+
}
|
|
71
|
+
export declare class TypeMistmatch extends Error {
|
|
72
|
+
}
|
|
73
|
+
export declare class ExprString extends ExpressionDef {
|
|
74
|
+
readonly value: string;
|
|
75
|
+
elementType: string;
|
|
76
|
+
constructor(value: string);
|
|
77
|
+
getExpression(_fs: FSPair): ExprValue;
|
|
78
|
+
}
|
|
79
|
+
export declare class ExprNumber extends ExpressionDef {
|
|
80
|
+
readonly n: string;
|
|
81
|
+
elementType: string;
|
|
82
|
+
constructor(n: string);
|
|
83
|
+
getExpression(_fs: FSPair): ExprValue;
|
|
84
|
+
constantExpression(): ExprValue;
|
|
85
|
+
}
|
|
86
|
+
export declare class ExprRegEx extends ExpressionDef {
|
|
87
|
+
readonly regex: string;
|
|
88
|
+
elementType: string;
|
|
89
|
+
constructor(regex: string);
|
|
90
|
+
getExpression(): ExprValue;
|
|
91
|
+
}
|
|
92
|
+
export declare class ExprTime extends ExpressionDef {
|
|
93
|
+
elementType: string;
|
|
94
|
+
readonly translationValue: ExprValue;
|
|
95
|
+
constructor(timeType: TimeFieldType, value: Fragment[] | string, aggregate?: boolean);
|
|
96
|
+
getExpression(_fs: FSPair): ExprValue;
|
|
97
|
+
static fromValue(timeType: TimeFieldType, expr: ExprValue): ExprTime;
|
|
98
|
+
}
|
|
99
|
+
declare abstract class Unary extends ExpressionDef {
|
|
100
|
+
readonly expr: ExpressionDef;
|
|
101
|
+
constructor(expr: ExpressionDef);
|
|
102
|
+
}
|
|
103
|
+
export declare class ExprNot extends Unary {
|
|
104
|
+
elementType: string;
|
|
105
|
+
legalChildTypes: FragType[];
|
|
106
|
+
constructor(expr: ExpressionDef);
|
|
107
|
+
getExpression(fs: FSPair): ExprValue;
|
|
108
|
+
}
|
|
109
|
+
export declare class Boolean extends ExpressionDef {
|
|
110
|
+
readonly value: "true" | "false";
|
|
111
|
+
elementType: string;
|
|
112
|
+
constructor(value: "true" | "false");
|
|
113
|
+
getExpression(): ExprValue;
|
|
114
|
+
}
|
|
115
|
+
export declare abstract class BinaryBoolean<opType extends string> extends ExpressionDef {
|
|
116
|
+
readonly left: ExpressionDef;
|
|
117
|
+
readonly op: opType;
|
|
118
|
+
readonly right: ExpressionDef;
|
|
119
|
+
elementType: string;
|
|
120
|
+
legalChildTypes: FragType[];
|
|
121
|
+
constructor(left: ExpressionDef, op: opType, right: ExpressionDef);
|
|
122
|
+
getExpression(fs: FSPair): ExprValue;
|
|
123
|
+
}
|
|
124
|
+
export declare class ExprLogicalOp extends BinaryBoolean<"and" | "or"> {
|
|
125
|
+
elementType: string;
|
|
126
|
+
legalChildTypes: FragType[];
|
|
127
|
+
}
|
|
128
|
+
export declare class ExprIdReference extends ExpressionDef {
|
|
129
|
+
readonly fieldReference: FieldReference;
|
|
130
|
+
elementType: string;
|
|
131
|
+
constructor(fieldReference: FieldReference);
|
|
132
|
+
get refString(): string;
|
|
133
|
+
getExpression(fs: FSPair): ExprValue;
|
|
134
|
+
apply(fs: FSPair, op: string, expr: ExpressionDef): ExprValue;
|
|
135
|
+
}
|
|
136
|
+
export declare class ExprNULL extends ExpressionDef {
|
|
137
|
+
elementType: string;
|
|
138
|
+
getExpression(): ExprValue;
|
|
139
|
+
}
|
|
140
|
+
export declare class ExprParens extends ExpressionDef {
|
|
141
|
+
readonly expr: ExpressionDef;
|
|
142
|
+
elementType: string;
|
|
143
|
+
constructor(expr: ExpressionDef);
|
|
144
|
+
apply(fs: FSPair, op: string, expr: ExpressionDef): ExprValue;
|
|
145
|
+
requestExpression(fs: FSPair): ExprValue | undefined;
|
|
146
|
+
getExpression(fs: FSPair): ExprValue;
|
|
147
|
+
}
|
|
148
|
+
export declare class ExprMinus extends ExpressionDef {
|
|
149
|
+
readonly expr: ExpressionDef;
|
|
150
|
+
elementType: string;
|
|
151
|
+
constructor(expr: ExpressionDef);
|
|
152
|
+
getExpression(fs: FSPair): ExprValue;
|
|
153
|
+
}
|
|
154
|
+
export declare abstract class BinaryNumeric<opType extends string> extends ExpressionDef {
|
|
155
|
+
readonly left: ExpressionDef;
|
|
156
|
+
readonly op: opType;
|
|
157
|
+
readonly right: ExpressionDef;
|
|
158
|
+
elementType: string;
|
|
159
|
+
constructor(left: ExpressionDef, op: opType, right: ExpressionDef);
|
|
160
|
+
getExpression(fs: FSPair): ExprValue;
|
|
161
|
+
}
|
|
162
|
+
export declare class ExprAddSub extends BinaryNumeric<"+" | "-"> {
|
|
163
|
+
elementType: string;
|
|
164
|
+
}
|
|
165
|
+
export declare class ExprMulDiv extends BinaryNumeric<"*" | "/"> {
|
|
166
|
+
elementType: string;
|
|
167
|
+
}
|
|
168
|
+
export declare class ExprAlternationTree extends BinaryBoolean<"|" | "&"> {
|
|
169
|
+
elementType: string;
|
|
170
|
+
constructor(left: ExpressionDef, op: "|" | "&", right: ExpressionDef);
|
|
171
|
+
apply(fs: FSPair, applyOp: string, expr: ExpressionDef): ExprValue;
|
|
172
|
+
requestExpression(_fs: FSPair): ExprValue | undefined;
|
|
173
|
+
getExpression(_fs: FSPair): ExprValue;
|
|
174
|
+
}
|
|
175
|
+
declare abstract class ExprAggregateFunction extends ExpressionDef {
|
|
176
|
+
readonly func: string;
|
|
177
|
+
elementType: string;
|
|
178
|
+
source?: FieldReference;
|
|
179
|
+
expr?: ExpressionDef;
|
|
180
|
+
legalChildTypes: FragType[];
|
|
181
|
+
constructor(func: string, expr?: ExpressionDef);
|
|
182
|
+
returns(_forExpression: ExprValue): FieldValueType;
|
|
183
|
+
getExpression(fs: FSPair): ExprValue;
|
|
184
|
+
}
|
|
185
|
+
export declare class ExprMin extends ExprAggregateFunction {
|
|
186
|
+
legalChildTypes: FragType[];
|
|
187
|
+
constructor(expr: ExpressionDef);
|
|
188
|
+
returns(forExpression: ExprValue): FieldValueType;
|
|
189
|
+
}
|
|
190
|
+
export declare class ExprMax extends ExprAggregateFunction {
|
|
191
|
+
legalChildTypes: FragType[];
|
|
192
|
+
constructor(expr: ExpressionDef);
|
|
193
|
+
returns(forExpression: ExprValue): FieldValueType;
|
|
194
|
+
}
|
|
195
|
+
export declare class ExprCountDistinct extends ExprAggregateFunction {
|
|
196
|
+
legalChildTypes: FragType[];
|
|
197
|
+
constructor(expr: ExpressionDef);
|
|
198
|
+
}
|
|
199
|
+
declare abstract class ExprAsymmetric extends ExprAggregateFunction {
|
|
200
|
+
readonly func: "sum" | "avg";
|
|
201
|
+
readonly expr: ExpressionDef | undefined;
|
|
202
|
+
readonly source?: FieldReference | undefined;
|
|
203
|
+
constructor(func: "sum" | "avg", expr: ExpressionDef | undefined, source?: FieldReference | undefined);
|
|
204
|
+
defaultFieldName(): undefined | string;
|
|
205
|
+
}
|
|
206
|
+
export declare class ExprCount extends ExprAggregateFunction {
|
|
207
|
+
readonly source?: FieldReference | undefined;
|
|
208
|
+
elementType: string;
|
|
209
|
+
constructor(source?: FieldReference | undefined);
|
|
210
|
+
defaultFieldName(): string | undefined;
|
|
211
|
+
getExpression(_fs: FSPair): ExprValue;
|
|
212
|
+
}
|
|
213
|
+
export declare class ExprAvg extends ExprAsymmetric {
|
|
214
|
+
constructor(expr: ExpressionDef | undefined, source?: FieldReference);
|
|
215
|
+
}
|
|
216
|
+
export declare class ExprSum extends ExprAsymmetric {
|
|
217
|
+
constructor(expr: ExpressionDef | undefined, source?: FieldReference);
|
|
218
|
+
}
|
|
219
|
+
export declare class ExprUngroup extends ExpressionDef {
|
|
220
|
+
readonly control: "all" | "exclude";
|
|
221
|
+
readonly expr: ExpressionDef;
|
|
222
|
+
readonly fields: FieldName[];
|
|
223
|
+
legalChildTypes: FragType[];
|
|
224
|
+
elementType: string;
|
|
225
|
+
constructor(control: "all" | "exclude", expr: ExpressionDef, fields: FieldName[]);
|
|
226
|
+
returns(_forExpression: ExprValue): FieldValueType;
|
|
227
|
+
getExpression(fs: FSPair): ExprValue;
|
|
228
|
+
}
|
|
229
|
+
export declare class WhenClause extends ExpressionDef {
|
|
230
|
+
readonly whenThis: ExpressionDef;
|
|
231
|
+
readonly thenThis: ExpressionDef;
|
|
232
|
+
elementType: string;
|
|
233
|
+
constructor(whenThis: ExpressionDef, thenThis: ExpressionDef);
|
|
234
|
+
getExpression(_fs: FSPair): ExprValue;
|
|
235
|
+
}
|
|
236
|
+
export declare class ExprCase extends ExpressionDef {
|
|
237
|
+
readonly when: WhenClause[];
|
|
238
|
+
readonly elseClause?: ExpressionDef | undefined;
|
|
239
|
+
elementType: string;
|
|
240
|
+
constructor(when: WhenClause[], elseClause?: ExpressionDef | undefined);
|
|
241
|
+
getExpression(fs: FSPair): ExprValue;
|
|
242
|
+
}
|
|
243
|
+
export declare class ExprFilter extends ExpressionDef {
|
|
244
|
+
readonly expr: ExpressionDef;
|
|
245
|
+
readonly filter: Filter;
|
|
246
|
+
elementType: string;
|
|
247
|
+
legalChildTypes: FragType[];
|
|
248
|
+
constructor(expr: ExpressionDef, filter: Filter);
|
|
249
|
+
getExpression(fs: FSPair): ExprValue;
|
|
250
|
+
}
|
|
251
|
+
declare type CastType = "string" | "number" | "boolean" | "date" | "timestamp";
|
|
252
|
+
export declare function isCastType(t: string): t is CastType;
|
|
253
|
+
export declare class ExprCast extends ExpressionDef {
|
|
254
|
+
readonly expr: ExpressionDef;
|
|
255
|
+
readonly castType: CastType;
|
|
256
|
+
readonly safe: boolean;
|
|
257
|
+
elementType: string;
|
|
258
|
+
constructor(expr: ExpressionDef, castType: CastType, safe?: boolean);
|
|
259
|
+
getExpression(fs: FSPair): ExprValue;
|
|
260
|
+
}
|
|
261
|
+
export declare class TopBy extends MalloyElement {
|
|
262
|
+
readonly by: string | ExpressionDef;
|
|
263
|
+
elementType: string;
|
|
264
|
+
constructor(by: string | ExpressionDef);
|
|
265
|
+
getBy(fs: FSPair): By;
|
|
266
|
+
}
|
|
267
|
+
export declare class Range extends ExpressionDef {
|
|
268
|
+
readonly first: ExpressionDef;
|
|
269
|
+
readonly last: ExpressionDef;
|
|
270
|
+
elementType: string;
|
|
271
|
+
constructor(first: ExpressionDef, last: ExpressionDef);
|
|
272
|
+
apply(fs: FSPair, op: string, expr: ExpressionDef): ExprValue;
|
|
273
|
+
requestExpression(_fs: FSPair): ExprValue | undefined;
|
|
274
|
+
getExpression(_fs: FSPair): ExprValue;
|
|
275
|
+
}
|
|
276
|
+
export declare class PickWhen extends MalloyElement {
|
|
277
|
+
readonly pick: ExpressionDef | undefined;
|
|
278
|
+
readonly when: ExpressionDef;
|
|
279
|
+
elementType: string;
|
|
280
|
+
constructor(pick: ExpressionDef | undefined, when: ExpressionDef);
|
|
281
|
+
}
|
|
282
|
+
export declare class Pick extends ExpressionDef {
|
|
283
|
+
readonly choices: PickWhen[];
|
|
284
|
+
readonly elsePick?: ExpressionDef | undefined;
|
|
285
|
+
elementType: string;
|
|
286
|
+
constructor(choices: PickWhen[], elsePick?: ExpressionDef | undefined);
|
|
287
|
+
requestExpression(fs: FSPair): ExprValue | undefined;
|
|
288
|
+
apply(fs: FSPair, op: string, expr: ExpressionDef): ExprValue;
|
|
289
|
+
getExpression(fs: FSPair): ExprValue;
|
|
290
|
+
}
|
|
291
|
+
export {};
|