@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,502 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
interface ParamBase {
|
|
3
|
+
name: string;
|
|
4
|
+
type: AtomicFieldType;
|
|
5
|
+
}
|
|
6
|
+
declare type ConstantExpr = Expr;
|
|
7
|
+
declare type Condition = Expr;
|
|
8
|
+
interface ParamCondition extends ParamBase {
|
|
9
|
+
condition: Condition | null;
|
|
10
|
+
}
|
|
11
|
+
interface ParamValue extends ParamBase {
|
|
12
|
+
value: ConstantExpr | null;
|
|
13
|
+
constant: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare type Parameter = ParamCondition | ParamValue;
|
|
16
|
+
export declare function isValueParameter(p: Parameter): p is ParamValue;
|
|
17
|
+
export declare function isConditionParameter(p: Parameter): p is ParamCondition;
|
|
18
|
+
export declare function paramHasValue(p: Parameter): boolean;
|
|
19
|
+
export interface DocumentRange {
|
|
20
|
+
start: DocumentPosition;
|
|
21
|
+
end: DocumentPosition;
|
|
22
|
+
}
|
|
23
|
+
export interface DocumentPosition {
|
|
24
|
+
line: number;
|
|
25
|
+
character: number;
|
|
26
|
+
}
|
|
27
|
+
export interface DocumentLocation {
|
|
28
|
+
url: string;
|
|
29
|
+
range: DocumentRange;
|
|
30
|
+
}
|
|
31
|
+
interface DocumentReferenceBase {
|
|
32
|
+
text: string;
|
|
33
|
+
location: DocumentLocation;
|
|
34
|
+
definition: HasLocation;
|
|
35
|
+
}
|
|
36
|
+
export interface DocumentExploreReference extends DocumentReferenceBase {
|
|
37
|
+
type: "exploreReference";
|
|
38
|
+
definition: StructDef;
|
|
39
|
+
}
|
|
40
|
+
export interface DocumentJoinReference extends DocumentReferenceBase {
|
|
41
|
+
type: "joinReference";
|
|
42
|
+
definition: FieldDef;
|
|
43
|
+
}
|
|
44
|
+
export interface DocumentSQLBlockReference extends DocumentReferenceBase {
|
|
45
|
+
type: "sqlBlockReference";
|
|
46
|
+
definition: SQLBlock;
|
|
47
|
+
}
|
|
48
|
+
export interface DocumentQueryReference extends DocumentReferenceBase {
|
|
49
|
+
type: "queryReference";
|
|
50
|
+
definition: Query;
|
|
51
|
+
}
|
|
52
|
+
export interface DocumentFieldReference extends DocumentReferenceBase {
|
|
53
|
+
type: "fieldReference";
|
|
54
|
+
definition: FieldDef;
|
|
55
|
+
}
|
|
56
|
+
export declare type DocumentReference = DocumentExploreReference | DocumentQueryReference | DocumentSQLBlockReference | DocumentFieldReference | DocumentJoinReference;
|
|
57
|
+
/** put location into the parse tree. */
|
|
58
|
+
export interface HasLocation {
|
|
59
|
+
location?: DocumentLocation;
|
|
60
|
+
}
|
|
61
|
+
/** All names have their source names and how they will appear in the symbol table that owns them */
|
|
62
|
+
export interface AliasedName {
|
|
63
|
+
name: string;
|
|
64
|
+
as?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface TypedObject {
|
|
67
|
+
type: string;
|
|
68
|
+
}
|
|
69
|
+
export interface FilteredAliasedName extends AliasedName {
|
|
70
|
+
filterList?: FilterExpression[];
|
|
71
|
+
}
|
|
72
|
+
export declare function isFilteredAliasedName(f: FieldTypeRef): f is FilteredAliasedName;
|
|
73
|
+
/** all named objects have a type an a name (optionally aliased) */
|
|
74
|
+
export interface NamedObject extends AliasedName, HasLocation {
|
|
75
|
+
type: string;
|
|
76
|
+
}
|
|
77
|
+
export interface ResultMetadataDef {
|
|
78
|
+
sourceField: string;
|
|
79
|
+
sourceExpression?: string;
|
|
80
|
+
sourceClasses: string[];
|
|
81
|
+
filterList?: FilterExpression[];
|
|
82
|
+
fieldKind: "measure" | "dimension" | "struct";
|
|
83
|
+
}
|
|
84
|
+
export interface ResultStructMetadataDef extends ResultMetadataDef {
|
|
85
|
+
limit?: number;
|
|
86
|
+
}
|
|
87
|
+
export interface ResultMetadata {
|
|
88
|
+
resultMetadata?: ResultMetadataDef;
|
|
89
|
+
}
|
|
90
|
+
export interface ResultStructMetadata {
|
|
91
|
+
resultMetadata?: ResultStructMetadataDef;
|
|
92
|
+
}
|
|
93
|
+
export interface FilterFragment {
|
|
94
|
+
type: "filterExpression";
|
|
95
|
+
filterList: FilterExpression[];
|
|
96
|
+
e: Expr;
|
|
97
|
+
}
|
|
98
|
+
export declare function isFilterFragment(f: Fragment): f is FilterFragment;
|
|
99
|
+
export declare function isDialectFragment(f: Fragment): f is DialectFragment;
|
|
100
|
+
export interface AggregateFragment {
|
|
101
|
+
type: "aggregate";
|
|
102
|
+
function: string;
|
|
103
|
+
e: Expr;
|
|
104
|
+
structPath?: string;
|
|
105
|
+
}
|
|
106
|
+
export declare function isAggregateFragment(f: Fragment): f is AggregateFragment;
|
|
107
|
+
export declare function isAsymmetricFragment(f: Fragment): f is AggregateFragment;
|
|
108
|
+
export interface UngroupFragment {
|
|
109
|
+
type: "all" | "exclude";
|
|
110
|
+
e: Expr;
|
|
111
|
+
fields?: string[];
|
|
112
|
+
}
|
|
113
|
+
export declare function isUngroupFragment(f: Fragment): f is UngroupFragment;
|
|
114
|
+
export interface FieldFragment {
|
|
115
|
+
type: "field";
|
|
116
|
+
path: string;
|
|
117
|
+
}
|
|
118
|
+
export declare function isFieldFragment(f: Fragment): f is FieldFragment;
|
|
119
|
+
export interface ParameterFragment {
|
|
120
|
+
type: "parameter";
|
|
121
|
+
path: string;
|
|
122
|
+
}
|
|
123
|
+
export declare function isParameterFragment(f: Fragment): f is ParameterFragment;
|
|
124
|
+
export interface ApplyValueFragment {
|
|
125
|
+
type: "applyVal";
|
|
126
|
+
}
|
|
127
|
+
export declare function isApplyValue(f: Fragment): f is ApplyValueFragment;
|
|
128
|
+
export interface ApplyFragment {
|
|
129
|
+
type: "apply";
|
|
130
|
+
value: Expr;
|
|
131
|
+
to: Expr;
|
|
132
|
+
}
|
|
133
|
+
export declare function isApplyFragment(f: Fragment): f is ApplyFragment;
|
|
134
|
+
interface DialectFragmentBase {
|
|
135
|
+
type: "dialect";
|
|
136
|
+
function: string;
|
|
137
|
+
}
|
|
138
|
+
export interface NowFragment extends DialectFragmentBase {
|
|
139
|
+
function: "now";
|
|
140
|
+
}
|
|
141
|
+
export interface TimeDiffFragment extends DialectFragmentBase {
|
|
142
|
+
function: "timeDiff";
|
|
143
|
+
units: TimestampUnit;
|
|
144
|
+
left: TimeValue;
|
|
145
|
+
right: TimeValue;
|
|
146
|
+
}
|
|
147
|
+
export interface TimeDeltaFragment extends DialectFragmentBase {
|
|
148
|
+
function: "delta";
|
|
149
|
+
base: TimeValue;
|
|
150
|
+
op: "+" | "-";
|
|
151
|
+
delta: Expr;
|
|
152
|
+
units: TimestampUnit;
|
|
153
|
+
}
|
|
154
|
+
export interface TimeTruncFragment extends DialectFragmentBase {
|
|
155
|
+
function: "trunc";
|
|
156
|
+
expr: TimeValue;
|
|
157
|
+
units: TimestampUnit;
|
|
158
|
+
}
|
|
159
|
+
export interface TimeExtractFragment extends DialectFragmentBase {
|
|
160
|
+
function: "extract";
|
|
161
|
+
expr: TimeValue;
|
|
162
|
+
units: ExtractUnit;
|
|
163
|
+
}
|
|
164
|
+
export interface TypecastFragment extends DialectFragmentBase {
|
|
165
|
+
function: "cast";
|
|
166
|
+
safe: boolean;
|
|
167
|
+
expr: Expr;
|
|
168
|
+
dstType: AtomicFieldType;
|
|
169
|
+
srcType?: AtomicFieldType;
|
|
170
|
+
}
|
|
171
|
+
export interface RegexpMatchFragment extends DialectFragmentBase {
|
|
172
|
+
function: "regexpMatch";
|
|
173
|
+
expr: Expr;
|
|
174
|
+
regexp: string;
|
|
175
|
+
}
|
|
176
|
+
export declare type DialectFragment = NowFragment | TimeDeltaFragment | TimeDiffFragment | TimeTruncFragment | TypecastFragment | TimeExtractFragment | RegexpMatchFragment;
|
|
177
|
+
export declare type Fragment = string | ApplyFragment | ApplyValueFragment | FieldFragment | ParameterFragment | FilterFragment | AggregateFragment | UngroupFragment | DialectFragment;
|
|
178
|
+
export declare type Expr = Fragment[];
|
|
179
|
+
export interface TypedValue {
|
|
180
|
+
value: Expr;
|
|
181
|
+
valueType: AtomicFieldType;
|
|
182
|
+
}
|
|
183
|
+
export interface TimeValue extends TypedValue {
|
|
184
|
+
valueType: TimeFieldType;
|
|
185
|
+
}
|
|
186
|
+
declare type TagElement = Expr | string;
|
|
187
|
+
/**
|
|
188
|
+
* Return an Expr based on the string template, subsittutions can be
|
|
189
|
+
* either strings, or other Exprs.
|
|
190
|
+
|
|
191
|
+
* ```
|
|
192
|
+
* units = "inches"
|
|
193
|
+
* len: Expr = [ "something", "returning", "a length "]
|
|
194
|
+
* computeExpr = mkExpr`MEASURE(${len} in ${units})`;
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
export declare function mkExpr(src: TemplateStringsArray, ...exprs: TagElement[]): Expr;
|
|
198
|
+
export interface Expression {
|
|
199
|
+
e?: Expr;
|
|
200
|
+
aggregate?: boolean;
|
|
201
|
+
code?: string;
|
|
202
|
+
}
|
|
203
|
+
interface JustExpression {
|
|
204
|
+
e: Expr;
|
|
205
|
+
}
|
|
206
|
+
declare type HasExpression = FieldDef & JustExpression;
|
|
207
|
+
/** Grants access to the expression property of a FielfDef */
|
|
208
|
+
export declare function hasExpression(f: FieldDef): f is HasExpression;
|
|
209
|
+
export declare type TimeFieldType = "date" | "timestamp";
|
|
210
|
+
export declare function isTimeFieldType(s: string): s is TimeFieldType;
|
|
211
|
+
export declare type AtomicFieldType = "string" | "number" | TimeFieldType | "boolean";
|
|
212
|
+
export declare function isAtomicFieldType(s: string): s is AtomicFieldType;
|
|
213
|
+
/** All scalars can have an optional expression */
|
|
214
|
+
export interface FieldAtomicDef extends NamedObject, Expression, ResultMetadata {
|
|
215
|
+
type: AtomicFieldType;
|
|
216
|
+
}
|
|
217
|
+
export declare function FieldIsIntrinsic(f: FieldDef): boolean;
|
|
218
|
+
/** Scalar String Field */
|
|
219
|
+
export interface FieldStringDef extends FieldAtomicDef {
|
|
220
|
+
type: "string";
|
|
221
|
+
bucketFilter?: string;
|
|
222
|
+
bucketOther?: string;
|
|
223
|
+
}
|
|
224
|
+
/** Scalar Numeric String Field */
|
|
225
|
+
export interface FieldNumberDef extends FieldAtomicDef {
|
|
226
|
+
type: "number";
|
|
227
|
+
numberType?: "integer" | "float";
|
|
228
|
+
}
|
|
229
|
+
/** Scalar Boolean Field */
|
|
230
|
+
export interface FieldBooleanDef extends FieldAtomicDef {
|
|
231
|
+
type: "boolean";
|
|
232
|
+
}
|
|
233
|
+
export declare type DateUnit = "day" | "week" | "month" | "quarter" | "year";
|
|
234
|
+
export declare function isDateUnit(str: string): str is DateUnit;
|
|
235
|
+
export declare type TimestampUnit = DateUnit | "hour" | "minute" | "second";
|
|
236
|
+
export declare function isTimestampUnit(s: string): s is TimestampUnit;
|
|
237
|
+
export declare type ExtractUnit = TimestampUnit | "day_of_week" | "day_of_year";
|
|
238
|
+
export declare function isExtractUnit(s: string): s is ExtractUnit;
|
|
239
|
+
/** Value types distinguished by their usage in generated SQL, particularly with respect to filters. */
|
|
240
|
+
export declare enum ValueType {
|
|
241
|
+
Date = "date",
|
|
242
|
+
Timestamp = "timestamp",
|
|
243
|
+
Number = "number",
|
|
244
|
+
String = "string"
|
|
245
|
+
}
|
|
246
|
+
export declare type TimeValueType = ValueType.Date | ValueType.Timestamp;
|
|
247
|
+
/** Scalar Date Field. */
|
|
248
|
+
export interface FieldDateDef extends FieldAtomicDef {
|
|
249
|
+
type: "date";
|
|
250
|
+
timeframe?: DateUnit;
|
|
251
|
+
}
|
|
252
|
+
/** Scalar Timestamp Field */
|
|
253
|
+
export interface FieldTimestampDef extends FieldAtomicDef {
|
|
254
|
+
type: "timestamp";
|
|
255
|
+
timeframe?: TimestampUnit;
|
|
256
|
+
}
|
|
257
|
+
/** parameter to order a query */
|
|
258
|
+
export interface OrderBy {
|
|
259
|
+
field: string | number;
|
|
260
|
+
dir?: "asc" | "desc";
|
|
261
|
+
}
|
|
262
|
+
export interface ByName {
|
|
263
|
+
by: "name";
|
|
264
|
+
name: string;
|
|
265
|
+
}
|
|
266
|
+
export interface ByExpression {
|
|
267
|
+
by: "expression";
|
|
268
|
+
e: Expr;
|
|
269
|
+
}
|
|
270
|
+
export declare type By = ByName | ByExpression;
|
|
271
|
+
export declare function isByName(by: By | undefined): by is ByName;
|
|
272
|
+
export declare function isByExpression(by: By | undefined): by is ByExpression;
|
|
273
|
+
/** reference to a data source */
|
|
274
|
+
export declare type StructRef = string | StructDef;
|
|
275
|
+
export declare function refIsStructDef(ref: StructRef): ref is StructDef;
|
|
276
|
+
/** join pattern structs is a struct. */
|
|
277
|
+
export interface JoinedStruct {
|
|
278
|
+
structRef: StructRef;
|
|
279
|
+
structRelationship: StructRelationship;
|
|
280
|
+
as: string;
|
|
281
|
+
}
|
|
282
|
+
export interface Filtered {
|
|
283
|
+
filterList?: FilterExpression[];
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* First element in a pipeline might be a reference to a turtle
|
|
287
|
+
*/
|
|
288
|
+
export interface TurtleSegment extends Filtered {
|
|
289
|
+
name: string;
|
|
290
|
+
}
|
|
291
|
+
export interface Pipeline {
|
|
292
|
+
pipeHead?: TurtleSegment;
|
|
293
|
+
pipeline: PipeSegment[];
|
|
294
|
+
}
|
|
295
|
+
export interface Query extends Pipeline, Filtered, HasLocation {
|
|
296
|
+
type?: "query";
|
|
297
|
+
structRef: StructRef;
|
|
298
|
+
}
|
|
299
|
+
export declare type NamedQuery = Query & NamedObject;
|
|
300
|
+
export declare type PipeSegment = QuerySegment | IndexSegment;
|
|
301
|
+
export interface ReduceSegment extends QuerySegment {
|
|
302
|
+
type: "reduce";
|
|
303
|
+
}
|
|
304
|
+
export declare function isReduceSegment(pe: PipeSegment): pe is ReduceSegment;
|
|
305
|
+
export interface ProjectSegment extends QuerySegment {
|
|
306
|
+
type: "project";
|
|
307
|
+
}
|
|
308
|
+
export declare function isProjectSegment(pe: PipeSegment): pe is ProjectSegment;
|
|
309
|
+
export declare function isQuerySegment(pe: PipeSegment): pe is QuerySegment;
|
|
310
|
+
export declare type Sampling = SamplingRows | SamplingEnable | SamplingPercent;
|
|
311
|
+
interface SamplingRows {
|
|
312
|
+
rows: number;
|
|
313
|
+
}
|
|
314
|
+
export declare function isSamplingRows(s: Sampling): s is SamplingRows;
|
|
315
|
+
interface SamplingPercent {
|
|
316
|
+
percent: number;
|
|
317
|
+
}
|
|
318
|
+
export declare function isSamplingPercent(s: Sampling): s is SamplingPercent;
|
|
319
|
+
interface SamplingEnable {
|
|
320
|
+
enable: boolean;
|
|
321
|
+
}
|
|
322
|
+
export declare function isSamplingEnable(s: Sampling): s is SamplingEnable;
|
|
323
|
+
export interface IndexSegment extends Filtered {
|
|
324
|
+
type: "index";
|
|
325
|
+
fields: string[];
|
|
326
|
+
limit?: number;
|
|
327
|
+
weightMeasure?: string;
|
|
328
|
+
sample?: Sampling;
|
|
329
|
+
}
|
|
330
|
+
export declare function isIndexSegment(pe: PipeSegment): pe is IndexSegment;
|
|
331
|
+
export interface QuerySegment extends Filtered {
|
|
332
|
+
type: "reduce" | "project";
|
|
333
|
+
fields: QueryFieldDef[];
|
|
334
|
+
extendSource?: FieldDef[];
|
|
335
|
+
limit?: number;
|
|
336
|
+
by?: By;
|
|
337
|
+
orderBy?: OrderBy[];
|
|
338
|
+
}
|
|
339
|
+
export interface TurtleDef extends NamedObject, Pipeline {
|
|
340
|
+
type: "turtle";
|
|
341
|
+
}
|
|
342
|
+
export declare type JoinRelationship = "one_to_one" | "one_to_many" | "many_to_one" | "many_to_many";
|
|
343
|
+
export interface JoinOn {
|
|
344
|
+
type: "one" | "many" | "cross";
|
|
345
|
+
onExpression?: Expr;
|
|
346
|
+
}
|
|
347
|
+
export declare function isJoinOn(sr: StructRelationship): sr is JoinOn;
|
|
348
|
+
/** types of joins. */
|
|
349
|
+
export declare type StructRelationship = {
|
|
350
|
+
type: "basetable";
|
|
351
|
+
connectionName: string;
|
|
352
|
+
} | JoinOn | {
|
|
353
|
+
type: "inline";
|
|
354
|
+
} | {
|
|
355
|
+
type: "nested";
|
|
356
|
+
field: FieldRef;
|
|
357
|
+
isArray: boolean;
|
|
358
|
+
};
|
|
359
|
+
export interface SQLSelectStatements {
|
|
360
|
+
before?: string[];
|
|
361
|
+
select: string;
|
|
362
|
+
after?: string[];
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Use factory makeSQLBlock to create one of these, it will compute the
|
|
366
|
+
* name: property and fill it in.
|
|
367
|
+
*/
|
|
368
|
+
export interface SQLBlock extends NamedObject, SQLSelectStatements {
|
|
369
|
+
type: "sqlBlock";
|
|
370
|
+
name: string;
|
|
371
|
+
connection?: string;
|
|
372
|
+
}
|
|
373
|
+
interface SubquerySource {
|
|
374
|
+
type: "sql";
|
|
375
|
+
method: "subquery";
|
|
376
|
+
sqlBlock: SQLBlock;
|
|
377
|
+
}
|
|
378
|
+
/** where does the struct come from? */
|
|
379
|
+
export declare type StructSource = {
|
|
380
|
+
type: "table";
|
|
381
|
+
tablePath?: string;
|
|
382
|
+
} | {
|
|
383
|
+
type: "nested";
|
|
384
|
+
} | {
|
|
385
|
+
type: "inline";
|
|
386
|
+
} | {
|
|
387
|
+
type: "query";
|
|
388
|
+
query: Query;
|
|
389
|
+
} | {
|
|
390
|
+
type: "sql";
|
|
391
|
+
method: "nested" | "lastStage";
|
|
392
|
+
} | SubquerySource;
|
|
393
|
+
/** struct that is intrinsic to the table */
|
|
394
|
+
export interface StructDef extends NamedObject, ResultStructMetadata, Filtered {
|
|
395
|
+
type: "struct";
|
|
396
|
+
structSource: StructSource;
|
|
397
|
+
structRelationship: StructRelationship;
|
|
398
|
+
fields: FieldDef[];
|
|
399
|
+
primaryKey?: PrimaryKeyRef;
|
|
400
|
+
parameters?: Record<string, Parameter>;
|
|
401
|
+
dialect: string;
|
|
402
|
+
}
|
|
403
|
+
/** any of the different field types */
|
|
404
|
+
export declare type FieldTypeDef = FieldStringDef | FieldDateDef | FieldTimestampDef | FieldNumberDef | FieldBooleanDef;
|
|
405
|
+
export declare function isFieldTypeDef(f: FieldDef): f is FieldTypeDef;
|
|
406
|
+
export declare function isFieldTimeBased(f: FieldDef): f is FieldTimestampDef | FieldDateDef;
|
|
407
|
+
export declare function isFieldStructDef(f: FieldDef): f is StructDef;
|
|
408
|
+
/** field reference in a query */
|
|
409
|
+
export declare type FieldTypeRef = string | FieldTypeDef | FilteredAliasedName;
|
|
410
|
+
/** field reference with with possibly and order by. */
|
|
411
|
+
export declare type QueryFieldDef = FieldTypeRef | TurtleDef;
|
|
412
|
+
/** basics statement */
|
|
413
|
+
export declare type FieldDef = FieldTypeDef | StructDef | TurtleDef;
|
|
414
|
+
/** reference to a field */
|
|
415
|
+
export declare type FieldRef = string | FieldDef;
|
|
416
|
+
/** which field is the primary key in this struct */
|
|
417
|
+
export declare type PrimaryKeyRef = string;
|
|
418
|
+
/** filters */
|
|
419
|
+
export interface FilterExpression {
|
|
420
|
+
expression: Expr;
|
|
421
|
+
code: string;
|
|
422
|
+
aggregate?: boolean;
|
|
423
|
+
}
|
|
424
|
+
/** Get the output name for a NamedObject */
|
|
425
|
+
export declare function getIdentifier(n: AliasedName): string;
|
|
426
|
+
export declare type NamedModelObject = StructDef | NamedQuery;
|
|
427
|
+
/** Result of parsing a model file */
|
|
428
|
+
export interface ModelDef {
|
|
429
|
+
name: string;
|
|
430
|
+
exports: string[];
|
|
431
|
+
contents: Record<string, NamedModelObject>;
|
|
432
|
+
}
|
|
433
|
+
/** Very common record type */
|
|
434
|
+
export declare type NamedStructDefs = Record<string, StructDef>;
|
|
435
|
+
export declare type QueryScalar = string | boolean | number | Date | Buffer | null;
|
|
436
|
+
/** One value in one column of returned data. */
|
|
437
|
+
export declare type QueryValue = QueryScalar | QueryData | QueryDataRow;
|
|
438
|
+
/** A row of returned data. */
|
|
439
|
+
export declare type QueryDataRow = {
|
|
440
|
+
[columnName: string]: QueryValue;
|
|
441
|
+
};
|
|
442
|
+
/** Returned query data. */
|
|
443
|
+
export declare type QueryData = QueryDataRow[];
|
|
444
|
+
/** Returned Malloy query data */
|
|
445
|
+
export declare type MalloyQueryData = {
|
|
446
|
+
rows: QueryDataRow[];
|
|
447
|
+
totalRows: number;
|
|
448
|
+
};
|
|
449
|
+
export interface DrillSource {
|
|
450
|
+
sourceExplore: string;
|
|
451
|
+
sourceFilters?: FilterExpression[];
|
|
452
|
+
}
|
|
453
|
+
export interface CompiledQuery extends DrillSource {
|
|
454
|
+
structs: StructDef[];
|
|
455
|
+
sql: string;
|
|
456
|
+
lastStageName: string;
|
|
457
|
+
malloy: string;
|
|
458
|
+
queryName?: string | undefined;
|
|
459
|
+
connectionName: string;
|
|
460
|
+
}
|
|
461
|
+
/** Result type for running a Malloy query. */
|
|
462
|
+
export interface QueryResult extends CompiledQuery {
|
|
463
|
+
result: QueryData;
|
|
464
|
+
totalRows: number;
|
|
465
|
+
error?: string;
|
|
466
|
+
}
|
|
467
|
+
export declare function isTurtleDef(def: FieldDef): def is TurtleDef;
|
|
468
|
+
export interface SearchResultRow {
|
|
469
|
+
field_name: string;
|
|
470
|
+
field_value: string;
|
|
471
|
+
weight: number;
|
|
472
|
+
}
|
|
473
|
+
export declare type SearchResult = SearchResultRow[];
|
|
474
|
+
export declare function isDimensional(field: FieldDef): boolean;
|
|
475
|
+
export declare function isPhysical(field: FieldDef): boolean;
|
|
476
|
+
export declare function getDimensions(structDef: StructDef): FieldAtomicDef[];
|
|
477
|
+
export declare function getPhysicalFields(structDef: StructDef): FieldDef[];
|
|
478
|
+
export declare function isMeasureLike(field: FieldDef): boolean;
|
|
479
|
+
export declare function isValueString(value: QueryValue, field: FieldDef): value is string | null;
|
|
480
|
+
export declare function isValueNumber(value: QueryValue, field: FieldDef): value is number | null;
|
|
481
|
+
export declare function isValueBoolean(value: QueryValue, field: FieldDef): value is boolean | null;
|
|
482
|
+
export declare function isValueTimestamp(value: QueryValue, field: FieldDef): value is {
|
|
483
|
+
value: string;
|
|
484
|
+
} | null;
|
|
485
|
+
export declare function isValueDate(value: QueryValue, field: FieldDef): value is {
|
|
486
|
+
value: string;
|
|
487
|
+
} | null;
|
|
488
|
+
export interface SearchIndexResult {
|
|
489
|
+
fieldName: string;
|
|
490
|
+
fieldValue: string;
|
|
491
|
+
fieldType: string;
|
|
492
|
+
weight: number;
|
|
493
|
+
}
|
|
494
|
+
export interface SearchValueMapResult {
|
|
495
|
+
fieldName: string;
|
|
496
|
+
cardinality: number;
|
|
497
|
+
values: {
|
|
498
|
+
fieldValue: string;
|
|
499
|
+
weight: number;
|
|
500
|
+
}[];
|
|
501
|
+
}
|
|
502
|
+
export {};
|