@malloydata/malloy 0.0.2 → 0.0.3
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 +12 -11
- package/dist/dialect/duckdb.d.ts +1 -1
- package/dist/dialect/duckdb.js +35 -37
- package/dist/dialect/postgres.d.ts +1 -1
- package/dist/dialect/postgres.js +15 -8
- package/dist/dialect/standardsql.js +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/lang/ast/apply-expr.js +2 -2
- package/dist/lang/ast/ast-expr.js +2 -12
- package/dist/lang/ast/ast-main.d.ts +2 -2
- package/dist/lang/ast/ast-main.js +2 -1
- package/dist/lang/field-space.d.ts +9 -7
- package/dist/lang/field-space.js +10 -8
- package/dist/lang/lib/Malloy/MalloyLexer.d.ts +108 -106
- package/dist/lang/lib/Malloy/MalloyLexer.js +1019 -1006
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +581 -590
- package/dist/lang/lib/Malloy/MalloyParser.js +1141 -1202
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +2015 -0
- package/dist/lang/lib/Malloy/MalloyParserListener.js +4 -0
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +1269 -0
- package/dist/lang/lib/Malloy/MalloyParserVisitor.js +4 -0
- package/dist/lang/parse-to-ast.d.ts +3 -4
- package/dist/lang/parse-to-ast.js +1 -1
- package/dist/lang/parse-tree-walkers/document-completion-walker.js +2 -0
- package/dist/lang/parse-tree-walkers/explore-query-walker.d.ts +2 -2
- package/dist/lang/test/field-symbols.spec.js +2 -2
- package/dist/lang/test/parse.spec.js +15 -0
- package/dist/lang/test/test-translator.js +1 -1
- package/dist/malloy.d.ts +1 -1
- package/dist/malloy.js +11 -5
- package/dist/md5.d.ts +1 -0
- package/dist/md5.js +30 -0
- package/dist/model/malloy_query.js +4 -6
- package/dist/model/malloy_types.d.ts +3 -1
- package/package.json +9 -14
- package/dist/dialect/dialect-map.d.ts +0 -3
- package/dist/dialect/dialect-map.js +0 -33
- package/dist/model/malloy-query.d.ts +0 -313
- package/dist/model/malloy-query.js +0 -2603
- package/dist/model/malloy-types.d.ts +0 -404
- package/dist/model/malloy-types.js +0 -242
- package/dist/model/sql-block.d.ts +0 -11
- package/dist/model/sql-block.js +0 -38
- package/dist/runtime-types.d.ts +0 -116
- package/dist/runtime-types.js +0 -40
|
@@ -1,404 +0,0 @@
|
|
|
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 interface AggregateFragment {
|
|
100
|
-
type: "aggregate";
|
|
101
|
-
function: string;
|
|
102
|
-
e: Expr;
|
|
103
|
-
structPath?: string;
|
|
104
|
-
}
|
|
105
|
-
export declare function isAggregateFragment(f: Fragment): f is AggregateFragment;
|
|
106
|
-
export declare function isAsymmetricFragment(f: Fragment): f is AggregateFragment;
|
|
107
|
-
export interface FieldFragment {
|
|
108
|
-
type: "field";
|
|
109
|
-
path: string;
|
|
110
|
-
}
|
|
111
|
-
export declare function isFieldFragment(f: Fragment): f is FieldFragment;
|
|
112
|
-
export interface ParameterFragment {
|
|
113
|
-
type: "parameter";
|
|
114
|
-
path: string;
|
|
115
|
-
}
|
|
116
|
-
export declare function isParameterFragment(f: Fragment): f is ParameterFragment;
|
|
117
|
-
export interface ApplyValueFragment {
|
|
118
|
-
type: "applyVal";
|
|
119
|
-
}
|
|
120
|
-
export declare function isApplyValue(f: Fragment): f is ApplyValueFragment;
|
|
121
|
-
export interface ApplyFragment {
|
|
122
|
-
type: "apply";
|
|
123
|
-
value: Expr;
|
|
124
|
-
to: Expr;
|
|
125
|
-
}
|
|
126
|
-
export declare function isApplyFragment(f: Fragment): f is ApplyFragment;
|
|
127
|
-
export declare type Fragment = string | ApplyFragment | ApplyValueFragment | FieldFragment | ParameterFragment | FilterFragment | AggregateFragment;
|
|
128
|
-
export declare type Expr = Fragment[];
|
|
129
|
-
export interface Expression {
|
|
130
|
-
e?: Expr;
|
|
131
|
-
aggregate?: boolean;
|
|
132
|
-
source?: string;
|
|
133
|
-
}
|
|
134
|
-
interface JustExpression {
|
|
135
|
-
e: Expr;
|
|
136
|
-
}
|
|
137
|
-
declare type HasExpression = FieldDef & JustExpression;
|
|
138
|
-
/** Grants access to the expression property of a FielfDef */
|
|
139
|
-
export declare function hasExpression(f: FieldDef): f is HasExpression;
|
|
140
|
-
export declare type AtomicFieldType = "string" | "number" | "date" | "timestamp" | "boolean";
|
|
141
|
-
export declare function isAtomicFieldType(s: string): s is AtomicFieldType;
|
|
142
|
-
/** All scalars can have an optional expression */
|
|
143
|
-
export interface FieldAtomicDef extends NamedObject, Expression, ResultMetadata {
|
|
144
|
-
type: AtomicFieldType;
|
|
145
|
-
}
|
|
146
|
-
export declare function FieldIsIntrinsic(f: FieldDef): boolean;
|
|
147
|
-
/** Scalar String Field */
|
|
148
|
-
export interface FieldStringDef extends FieldAtomicDef {
|
|
149
|
-
type: "string";
|
|
150
|
-
bucketFilter?: string;
|
|
151
|
-
bucketOther?: string;
|
|
152
|
-
}
|
|
153
|
-
/** Scalar Numeric String Field */
|
|
154
|
-
export interface FieldNumberDef extends FieldAtomicDef {
|
|
155
|
-
type: "number";
|
|
156
|
-
numberType?: "integer" | "float";
|
|
157
|
-
}
|
|
158
|
-
/** Scalar Boolean Field */
|
|
159
|
-
export interface FieldBooleanDef extends FieldAtomicDef {
|
|
160
|
-
type: "boolean";
|
|
161
|
-
}
|
|
162
|
-
/** valid suffixes for a date field ref which are not valid timeframes */
|
|
163
|
-
declare type LegacySecretTimeFrames = "date" | "day_of_month" | "day_of_year" | "day_of_week" | "month_of_year";
|
|
164
|
-
/** valid timeframes for date */
|
|
165
|
-
export declare type DateTimeframe = LegacySecretTimeFrames | "day" | "week" | "month" | "quarter" | "year";
|
|
166
|
-
export declare function isDateTimeFrame(str: string): str is DateTimeframe;
|
|
167
|
-
/** Value types distinguished by their usage in generated SQL, particularly with respect to filters. */
|
|
168
|
-
export declare enum ValueType {
|
|
169
|
-
Date = "date",
|
|
170
|
-
Timestamp = "timestamp",
|
|
171
|
-
Number = "number",
|
|
172
|
-
String = "string"
|
|
173
|
-
}
|
|
174
|
-
export declare type TimeValueType = ValueType.Date | ValueType.Timestamp;
|
|
175
|
-
/** Scalar Date Field. */
|
|
176
|
-
export interface FieldDateDef extends FieldAtomicDef {
|
|
177
|
-
type: "date";
|
|
178
|
-
timeframe?: DateTimeframe;
|
|
179
|
-
}
|
|
180
|
-
/** valid suffuxes for a timestamp field which are not valid timeframes */
|
|
181
|
-
declare type LegacyTimeTimeframes = "hour_of_day";
|
|
182
|
-
/** valid timeframes for a timestmap */
|
|
183
|
-
export declare type TimeTimeframe = DateTimeframe | LegacyTimeTimeframes | "hour" | "minute" | "second";
|
|
184
|
-
export declare function isTimeTimeframe(s: string): s is TimeTimeframe;
|
|
185
|
-
/** Scalar Timestamp Field */
|
|
186
|
-
export interface FieldTimestampDef extends FieldAtomicDef {
|
|
187
|
-
type: "timestamp";
|
|
188
|
-
timeframe?: TimeTimeframe;
|
|
189
|
-
}
|
|
190
|
-
/** parameter to order a query */
|
|
191
|
-
export interface OrderBy {
|
|
192
|
-
field: string | number;
|
|
193
|
-
dir?: "asc" | "desc";
|
|
194
|
-
}
|
|
195
|
-
export interface ByName {
|
|
196
|
-
by: "name";
|
|
197
|
-
name: string;
|
|
198
|
-
}
|
|
199
|
-
export interface ByExpression {
|
|
200
|
-
by: "expression";
|
|
201
|
-
e: Expr;
|
|
202
|
-
}
|
|
203
|
-
export declare type By = ByName | ByExpression;
|
|
204
|
-
export declare function isByName(by: By | undefined): by is ByName;
|
|
205
|
-
export declare function isByExpression(by: By | undefined): by is ByExpression;
|
|
206
|
-
/** reference to a data source */
|
|
207
|
-
export declare type StructRef = string | StructDef;
|
|
208
|
-
export declare function refIsStructDef(ref: StructRef): ref is StructDef;
|
|
209
|
-
/** join pattern structs is a struct. */
|
|
210
|
-
export interface JoinedStruct {
|
|
211
|
-
structRef: StructRef;
|
|
212
|
-
structRelationship: StructRelationship;
|
|
213
|
-
as: string;
|
|
214
|
-
}
|
|
215
|
-
export interface Filtered {
|
|
216
|
-
filterList?: FilterExpression[];
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* First element in a pipeline might be a reference to a turtle
|
|
220
|
-
*/
|
|
221
|
-
export interface TurtleSegment extends Filtered {
|
|
222
|
-
name: string;
|
|
223
|
-
}
|
|
224
|
-
export interface Pipeline {
|
|
225
|
-
pipeHead?: TurtleSegment;
|
|
226
|
-
pipeline: PipeSegment[];
|
|
227
|
-
}
|
|
228
|
-
export interface Query extends Pipeline, Filtered, HasLocation {
|
|
229
|
-
type?: "query";
|
|
230
|
-
structRef: StructRef;
|
|
231
|
-
}
|
|
232
|
-
export declare type NamedQuery = Query & NamedObject;
|
|
233
|
-
export declare type PipeSegment = ReduceSegment | ProjectSegment | IndexSegment;
|
|
234
|
-
export interface ReduceSegment extends QuerySegment {
|
|
235
|
-
type: "reduce";
|
|
236
|
-
}
|
|
237
|
-
export declare function isReduceSegment(pe: PipeSegment): pe is ReduceSegment;
|
|
238
|
-
export interface ProjectSegment extends QuerySegment {
|
|
239
|
-
type: "project";
|
|
240
|
-
}
|
|
241
|
-
export declare function isProjectSegment(pe: PipeSegment): pe is ProjectSegment;
|
|
242
|
-
export declare function isQuerySegment(pe: PipeSegment): pe is QuerySegment;
|
|
243
|
-
export interface IndexSegment extends Filtered {
|
|
244
|
-
type: "index";
|
|
245
|
-
fields: string[];
|
|
246
|
-
limit?: number;
|
|
247
|
-
weightMeasure?: string;
|
|
248
|
-
}
|
|
249
|
-
export declare function isIndexSegment(pe: PipeSegment): pe is IndexSegment;
|
|
250
|
-
export interface QuerySegment extends Filtered {
|
|
251
|
-
type: "reduce" | "project";
|
|
252
|
-
fields: QueryFieldDef[];
|
|
253
|
-
extendSource?: FieldDef[];
|
|
254
|
-
limit?: number;
|
|
255
|
-
by?: By;
|
|
256
|
-
orderBy?: OrderBy[];
|
|
257
|
-
}
|
|
258
|
-
export interface TurtleDef extends NamedObject, Pipeline {
|
|
259
|
-
type: "turtle";
|
|
260
|
-
}
|
|
261
|
-
export declare type JoinRelationship = "one_to_one" | "one_to_many" | "many_to_one" | "many_to_many";
|
|
262
|
-
export interface JoinOn {
|
|
263
|
-
type: "one" | "many" | "cross";
|
|
264
|
-
onExpression?: Expr;
|
|
265
|
-
}
|
|
266
|
-
export declare function isJoinOn(sr: StructRelationship): sr is JoinOn;
|
|
267
|
-
/** types of joins. */
|
|
268
|
-
export declare type StructRelationship = {
|
|
269
|
-
type: "basetable";
|
|
270
|
-
connectionName: string;
|
|
271
|
-
} | JoinOn | {
|
|
272
|
-
type: "inline";
|
|
273
|
-
} | {
|
|
274
|
-
type: "nested";
|
|
275
|
-
field: FieldRef;
|
|
276
|
-
};
|
|
277
|
-
/**
|
|
278
|
-
* Use factory makeSQLBlock to create one of these, it will compute the
|
|
279
|
-
* name: property and fill it in.
|
|
280
|
-
*/
|
|
281
|
-
export interface SQLBlock extends NamedObject {
|
|
282
|
-
type: "sqlBlock";
|
|
283
|
-
name: string;
|
|
284
|
-
before?: string[];
|
|
285
|
-
select: string;
|
|
286
|
-
after?: string[];
|
|
287
|
-
connection?: string;
|
|
288
|
-
}
|
|
289
|
-
interface SubquerySource {
|
|
290
|
-
type: "sql";
|
|
291
|
-
method: "subquery";
|
|
292
|
-
sqlBlock: SQLBlock;
|
|
293
|
-
}
|
|
294
|
-
/** where does the struct come from? */
|
|
295
|
-
export declare type StructSource = {
|
|
296
|
-
type: "table";
|
|
297
|
-
tablePath?: string;
|
|
298
|
-
} | {
|
|
299
|
-
type: "nested";
|
|
300
|
-
} | {
|
|
301
|
-
type: "inline";
|
|
302
|
-
} | {
|
|
303
|
-
type: "query";
|
|
304
|
-
query: Query;
|
|
305
|
-
} | {
|
|
306
|
-
type: "sql";
|
|
307
|
-
method: "nested";
|
|
308
|
-
} | SubquerySource;
|
|
309
|
-
/** struct that is intrinsic to the table */
|
|
310
|
-
export interface StructDef extends NamedObject, ResultStructMetadata, Filtered {
|
|
311
|
-
type: "struct";
|
|
312
|
-
structSource: StructSource;
|
|
313
|
-
structRelationship: StructRelationship;
|
|
314
|
-
fields: FieldDef[];
|
|
315
|
-
primaryKey?: PrimaryKeyRef;
|
|
316
|
-
parameters?: Record<string, Parameter>;
|
|
317
|
-
dialect: string;
|
|
318
|
-
}
|
|
319
|
-
/** any of the different field types */
|
|
320
|
-
export declare type FieldTypeDef = FieldStringDef | FieldDateDef | FieldTimestampDef | FieldNumberDef | FieldBooleanDef;
|
|
321
|
-
export declare function isFieldTypeDef(f: FieldDef): f is FieldTypeDef;
|
|
322
|
-
export declare function isFieldTimeBased(f: FieldDef): f is FieldTimestampDef | FieldDateDef;
|
|
323
|
-
export declare function isFieldStructDef(f: FieldDef): f is StructDef;
|
|
324
|
-
/** field reference in a query */
|
|
325
|
-
export declare type FieldTypeRef = string | FieldTypeDef | FilteredAliasedName;
|
|
326
|
-
/** field reference with with possibly and order by. */
|
|
327
|
-
export declare type QueryFieldDef = FieldTypeRef | TurtleDef;
|
|
328
|
-
/** basics statement */
|
|
329
|
-
export declare type FieldDef = FieldTypeDef | StructDef | TurtleDef;
|
|
330
|
-
/** reference to a field */
|
|
331
|
-
export declare type FieldRef = string | FieldDef;
|
|
332
|
-
/** which field is the primary key in this struct */
|
|
333
|
-
export declare type PrimaryKeyRef = string;
|
|
334
|
-
/** filters */
|
|
335
|
-
export interface FilterExpression {
|
|
336
|
-
expression: Expr;
|
|
337
|
-
source: string;
|
|
338
|
-
aggregate?: boolean;
|
|
339
|
-
}
|
|
340
|
-
/** Get the output name for a NamedObject */
|
|
341
|
-
export declare function getIdentifier(n: AliasedName): string;
|
|
342
|
-
export declare type NamedModelObject = StructDef | NamedQuery;
|
|
343
|
-
/** Result of parsing a model file */
|
|
344
|
-
export interface ModelDef {
|
|
345
|
-
name: string;
|
|
346
|
-
exports: string[];
|
|
347
|
-
contents: Record<string, NamedModelObject>;
|
|
348
|
-
}
|
|
349
|
-
/** Very common record type */
|
|
350
|
-
export declare type NamedStructDefs = Record<string, StructDef>;
|
|
351
|
-
export declare type QueryScalar = string | boolean | number | Date | Buffer | null;
|
|
352
|
-
/** One value in one column of returned data. */
|
|
353
|
-
export declare type QueryValue = QueryScalar | QueryData | QueryDataRow;
|
|
354
|
-
/** A row of returned data. */
|
|
355
|
-
export declare type QueryDataRow = {
|
|
356
|
-
[columnName: string]: QueryValue;
|
|
357
|
-
};
|
|
358
|
-
/** Returned query data. */
|
|
359
|
-
export declare type QueryData = QueryDataRow[];
|
|
360
|
-
/** Returned Malloy query data */
|
|
361
|
-
export declare type MalloyQueryData = {
|
|
362
|
-
rows: QueryDataRow[];
|
|
363
|
-
totalRows: number;
|
|
364
|
-
};
|
|
365
|
-
export interface DrillSource {
|
|
366
|
-
sourceExplore: string;
|
|
367
|
-
sourceFilters?: FilterExpression[];
|
|
368
|
-
}
|
|
369
|
-
export interface CompiledQuery extends DrillSource {
|
|
370
|
-
structs: StructDef[];
|
|
371
|
-
sql: string;
|
|
372
|
-
lastStageName: string;
|
|
373
|
-
malloy: string;
|
|
374
|
-
queryName?: string | undefined;
|
|
375
|
-
connectionName: string;
|
|
376
|
-
}
|
|
377
|
-
/** Result type for running a Malloy query. */
|
|
378
|
-
export interface QueryResult extends CompiledQuery {
|
|
379
|
-
result: QueryData;
|
|
380
|
-
totalRows: number;
|
|
381
|
-
error?: string;
|
|
382
|
-
}
|
|
383
|
-
export declare function isTurtleDef(def: FieldDef): def is TurtleDef;
|
|
384
|
-
export interface SearchResultRow {
|
|
385
|
-
field_name: string;
|
|
386
|
-
field_value: string;
|
|
387
|
-
weight: number;
|
|
388
|
-
}
|
|
389
|
-
export declare type SearchResult = SearchResultRow[];
|
|
390
|
-
export declare function isDimensional(field: FieldDef): boolean;
|
|
391
|
-
export declare function isPhysical(field: FieldDef): boolean;
|
|
392
|
-
export declare function getDimensions(structDef: StructDef): FieldAtomicDef[];
|
|
393
|
-
export declare function getPhysicalFields(structDef: StructDef): FieldDef[];
|
|
394
|
-
export declare function isMeasureLike(field: FieldDef): boolean;
|
|
395
|
-
export declare function isValueString(value: QueryValue, field: FieldDef): value is string | null;
|
|
396
|
-
export declare function isValueNumber(value: QueryValue, field: FieldDef): value is number | null;
|
|
397
|
-
export declare function isValueBoolean(value: QueryValue, field: FieldDef): value is boolean | null;
|
|
398
|
-
export declare function isValueTimestamp(value: QueryValue, field: FieldDef): value is {
|
|
399
|
-
value: string;
|
|
400
|
-
} | null;
|
|
401
|
-
export declare function isValueDate(value: QueryValue, field: FieldDef): value is {
|
|
402
|
-
value: string;
|
|
403
|
-
} | null;
|
|
404
|
-
export {};
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2021 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* This program is free software; you can redistribute it and/or
|
|
6
|
-
* modify it under the terms of the GNU General Public License
|
|
7
|
-
* version 2 as published by the Free Software Foundation.
|
|
8
|
-
*
|
|
9
|
-
* This program is distributed in the hope that it will be useful,
|
|
10
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
* GNU General Public License for more details.
|
|
13
|
-
*/
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.isValueDate = exports.isValueTimestamp = exports.isValueBoolean = exports.isValueNumber = exports.isValueString = exports.isMeasureLike = exports.getPhysicalFields = exports.getDimensions = exports.isPhysical = exports.isDimensional = exports.isTurtleDef = exports.getIdentifier = exports.isFieldStructDef = exports.isFieldTimeBased = exports.isFieldTypeDef = exports.isJoinOn = exports.isIndexSegment = exports.isQuerySegment = exports.isProjectSegment = exports.isReduceSegment = exports.refIsStructDef = exports.isByExpression = exports.isByName = exports.isTimeTimeframe = exports.ValueType = exports.isDateTimeFrame = exports.FieldIsIntrinsic = exports.isAtomicFieldType = exports.hasExpression = exports.isApplyFragment = exports.isApplyValue = exports.isParameterFragment = exports.isFieldFragment = exports.isAsymmetricFragment = exports.isAggregateFragment = exports.isFilterFragment = exports.isFilteredAliasedName = exports.paramHasValue = exports.isConditionParameter = exports.isValueParameter = void 0;
|
|
16
|
-
function isValueParameter(p) {
|
|
17
|
-
return p.value !== undefined;
|
|
18
|
-
}
|
|
19
|
-
exports.isValueParameter = isValueParameter;
|
|
20
|
-
function isConditionParameter(p) {
|
|
21
|
-
return p.condition !== undefined;
|
|
22
|
-
}
|
|
23
|
-
exports.isConditionParameter = isConditionParameter;
|
|
24
|
-
function paramHasValue(p) {
|
|
25
|
-
return isValueParameter(p) || p.condition !== null;
|
|
26
|
-
}
|
|
27
|
-
exports.paramHasValue = paramHasValue;
|
|
28
|
-
function isFilteredAliasedName(f) {
|
|
29
|
-
for (const prop of Object.keys(f)) {
|
|
30
|
-
if (!["name", "as", "filterList"].includes(prop)) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
exports.isFilteredAliasedName = isFilteredAliasedName;
|
|
37
|
-
function isFilterFragment(f) {
|
|
38
|
-
var _a;
|
|
39
|
-
return ((_a = f) === null || _a === void 0 ? void 0 : _a.type) === "filterExpression";
|
|
40
|
-
}
|
|
41
|
-
exports.isFilterFragment = isFilterFragment;
|
|
42
|
-
function isAggregateFragment(f) {
|
|
43
|
-
var _a;
|
|
44
|
-
return ((_a = f) === null || _a === void 0 ? void 0 : _a.type) === "aggregate";
|
|
45
|
-
}
|
|
46
|
-
exports.isAggregateFragment = isAggregateFragment;
|
|
47
|
-
function isAsymmetricFragment(f) {
|
|
48
|
-
return isAggregateFragment(f) && ["sum", "avg", "count"].includes(f.function);
|
|
49
|
-
}
|
|
50
|
-
exports.isAsymmetricFragment = isAsymmetricFragment;
|
|
51
|
-
function isFieldFragment(f) {
|
|
52
|
-
var _a;
|
|
53
|
-
return ((_a = f) === null || _a === void 0 ? void 0 : _a.type) === "field";
|
|
54
|
-
}
|
|
55
|
-
exports.isFieldFragment = isFieldFragment;
|
|
56
|
-
function isParameterFragment(f) {
|
|
57
|
-
var _a;
|
|
58
|
-
return ((_a = f) === null || _a === void 0 ? void 0 : _a.type) === "parameter";
|
|
59
|
-
}
|
|
60
|
-
exports.isParameterFragment = isParameterFragment;
|
|
61
|
-
function isApplyValue(f) {
|
|
62
|
-
var _a;
|
|
63
|
-
return ((_a = f) === null || _a === void 0 ? void 0 : _a.type) === "applyVal";
|
|
64
|
-
}
|
|
65
|
-
exports.isApplyValue = isApplyValue;
|
|
66
|
-
function isApplyFragment(f) {
|
|
67
|
-
var _a;
|
|
68
|
-
return ((_a = f) === null || _a === void 0 ? void 0 : _a.type) === "apply";
|
|
69
|
-
}
|
|
70
|
-
exports.isApplyFragment = isApplyFragment;
|
|
71
|
-
/** Grants access to the expression property of a FielfDef */
|
|
72
|
-
function hasExpression(f) {
|
|
73
|
-
return f.e !== undefined;
|
|
74
|
-
}
|
|
75
|
-
exports.hasExpression = hasExpression;
|
|
76
|
-
function isAtomicFieldType(s) {
|
|
77
|
-
return ["string", "number", "date", "timestamp", "boolean"].includes(s);
|
|
78
|
-
}
|
|
79
|
-
exports.isAtomicFieldType = isAtomicFieldType;
|
|
80
|
-
// this field definition represents something in the database.
|
|
81
|
-
function FieldIsIntrinsic(f) {
|
|
82
|
-
if (isAtomicFieldType(f.type) && !hasExpression(f)) {
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
else if (f.type === "struct" &&
|
|
86
|
-
(f.structSource.type === "inline" || f.structSource.type === "nested")) {
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
exports.FieldIsIntrinsic = FieldIsIntrinsic;
|
|
94
|
-
function isDateTimeFrame(str) {
|
|
95
|
-
return [
|
|
96
|
-
"day",
|
|
97
|
-
"week",
|
|
98
|
-
"month",
|
|
99
|
-
"quarter",
|
|
100
|
-
"year",
|
|
101
|
-
// TODO Don't forget to remove legacy types here
|
|
102
|
-
"day_of_month",
|
|
103
|
-
"day_of_year",
|
|
104
|
-
"day_of_week",
|
|
105
|
-
"month_of_year",
|
|
106
|
-
].includes(str);
|
|
107
|
-
}
|
|
108
|
-
exports.isDateTimeFrame = isDateTimeFrame;
|
|
109
|
-
/** Value types distinguished by their usage in generated SQL, particularly with respect to filters. */
|
|
110
|
-
var ValueType;
|
|
111
|
-
(function (ValueType) {
|
|
112
|
-
ValueType["Date"] = "date";
|
|
113
|
-
ValueType["Timestamp"] = "timestamp";
|
|
114
|
-
ValueType["Number"] = "number";
|
|
115
|
-
ValueType["String"] = "string";
|
|
116
|
-
})(ValueType = exports.ValueType || (exports.ValueType = {}));
|
|
117
|
-
function isTimeTimeframe(s) {
|
|
118
|
-
// TODO Don't forget to remove legacy types here
|
|
119
|
-
return (isDateTimeFrame(s) ||
|
|
120
|
-
["hour", "minute", "second", "hour_of_day"].includes(s));
|
|
121
|
-
}
|
|
122
|
-
exports.isTimeTimeframe = isTimeTimeframe;
|
|
123
|
-
function isByName(by) {
|
|
124
|
-
if (by === undefined) {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
return by.by === "name";
|
|
128
|
-
}
|
|
129
|
-
exports.isByName = isByName;
|
|
130
|
-
function isByExpression(by) {
|
|
131
|
-
if (by === undefined) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
return by.by === "name";
|
|
135
|
-
}
|
|
136
|
-
exports.isByExpression = isByExpression;
|
|
137
|
-
function refIsStructDef(ref) {
|
|
138
|
-
return typeof ref !== "string" && ref.type === "struct";
|
|
139
|
-
}
|
|
140
|
-
exports.refIsStructDef = refIsStructDef;
|
|
141
|
-
function isReduceSegment(pe) {
|
|
142
|
-
return pe.type === "reduce";
|
|
143
|
-
}
|
|
144
|
-
exports.isReduceSegment = isReduceSegment;
|
|
145
|
-
function isProjectSegment(pe) {
|
|
146
|
-
return pe.type === "project";
|
|
147
|
-
}
|
|
148
|
-
exports.isProjectSegment = isProjectSegment;
|
|
149
|
-
function isQuerySegment(pe) {
|
|
150
|
-
return pe.type === "project" || pe.type === "reduce";
|
|
151
|
-
}
|
|
152
|
-
exports.isQuerySegment = isQuerySegment;
|
|
153
|
-
function isIndexSegment(pe) {
|
|
154
|
-
return pe.type === "index";
|
|
155
|
-
}
|
|
156
|
-
exports.isIndexSegment = isIndexSegment;
|
|
157
|
-
function isJoinOn(sr) {
|
|
158
|
-
return ["one", "many", "cross"].includes(sr.type);
|
|
159
|
-
}
|
|
160
|
-
exports.isJoinOn = isJoinOn;
|
|
161
|
-
function isFieldTypeDef(f) {
|
|
162
|
-
return (f.type === "string" ||
|
|
163
|
-
f.type === "date" ||
|
|
164
|
-
f.type === "number" ||
|
|
165
|
-
f.type === "timestamp" ||
|
|
166
|
-
f.type === "boolean");
|
|
167
|
-
}
|
|
168
|
-
exports.isFieldTypeDef = isFieldTypeDef;
|
|
169
|
-
function isFieldTimeBased(f) {
|
|
170
|
-
return f.type === "date" || f.type === "timestamp";
|
|
171
|
-
}
|
|
172
|
-
exports.isFieldTimeBased = isFieldTimeBased;
|
|
173
|
-
function isFieldStructDef(f) {
|
|
174
|
-
return f.type === "struct";
|
|
175
|
-
}
|
|
176
|
-
exports.isFieldStructDef = isFieldStructDef;
|
|
177
|
-
/** Get the output name for a NamedObject */
|
|
178
|
-
function getIdentifier(n) {
|
|
179
|
-
if (n.as !== undefined) {
|
|
180
|
-
return n.as;
|
|
181
|
-
}
|
|
182
|
-
return n.name;
|
|
183
|
-
}
|
|
184
|
-
exports.getIdentifier = getIdentifier;
|
|
185
|
-
function isTurtleDef(def) {
|
|
186
|
-
return def.type === "turtle";
|
|
187
|
-
}
|
|
188
|
-
exports.isTurtleDef = isTurtleDef;
|
|
189
|
-
function isDimensional(field) {
|
|
190
|
-
var _a;
|
|
191
|
-
if ("resultMetadata" in field) {
|
|
192
|
-
return ((_a = field.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) === "dimension";
|
|
193
|
-
}
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
exports.isDimensional = isDimensional;
|
|
197
|
-
function isPhysical(field) {
|
|
198
|
-
return ((isFieldTypeDef(field) && field.e === undefined) ||
|
|
199
|
-
(isFieldStructDef(field) &&
|
|
200
|
-
(field.structSource.type === "nested" ||
|
|
201
|
-
field.structSource.type == "inline")));
|
|
202
|
-
}
|
|
203
|
-
exports.isPhysical = isPhysical;
|
|
204
|
-
function getDimensions(structDef) {
|
|
205
|
-
return structDef.fields.filter(isDimensional);
|
|
206
|
-
}
|
|
207
|
-
exports.getDimensions = getDimensions;
|
|
208
|
-
function getPhysicalFields(structDef) {
|
|
209
|
-
return structDef.fields.filter(isPhysical);
|
|
210
|
-
}
|
|
211
|
-
exports.getPhysicalFields = getPhysicalFields;
|
|
212
|
-
function isMeasureLike(field) {
|
|
213
|
-
var _a, _b;
|
|
214
|
-
if ("resultMetadata" in field) {
|
|
215
|
-
return (((_a = field.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) === "measure" ||
|
|
216
|
-
((_b = field.resultMetadata) === null || _b === void 0 ? void 0 : _b.fieldKind) === "struct");
|
|
217
|
-
}
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
220
|
-
exports.isMeasureLike = isMeasureLike;
|
|
221
|
-
function isValueString(value, field) {
|
|
222
|
-
return field.type === "string";
|
|
223
|
-
}
|
|
224
|
-
exports.isValueString = isValueString;
|
|
225
|
-
function isValueNumber(value, field) {
|
|
226
|
-
return field.type === "number";
|
|
227
|
-
}
|
|
228
|
-
exports.isValueNumber = isValueNumber;
|
|
229
|
-
function isValueBoolean(value, field) {
|
|
230
|
-
return field.type === "boolean";
|
|
231
|
-
}
|
|
232
|
-
exports.isValueBoolean = isValueBoolean;
|
|
233
|
-
function isValueTimestamp(value, field) {
|
|
234
|
-
return field.type === "timestamp";
|
|
235
|
-
}
|
|
236
|
-
exports.isValueTimestamp = isValueTimestamp;
|
|
237
|
-
function isValueDate(value, field) {
|
|
238
|
-
return field.type === "date";
|
|
239
|
-
}
|
|
240
|
-
exports.isValueDate = isValueDate;
|
|
241
|
-
// clang-format on
|
|
242
|
-
//# sourceMappingURL=malloy-types.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { SQLBlock } from "./malloy-types";
|
|
2
|
-
/**
|
|
3
|
-
* SQLBlockRequest does not have a digest in it
|
|
4
|
-
*/
|
|
5
|
-
export interface SQLBlockRequest extends Partial<SQLBlock> {
|
|
6
|
-
select: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* The factory for SQLBlocks.
|
|
10
|
-
*/
|
|
11
|
-
export declare function makeSQLBlock(from: SQLBlockRequest): SQLBlock;
|
package/dist/model/sql-block.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2022 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* This program is free software; you can redistribute it and/or
|
|
6
|
-
* modify it under the terms of the GNU General Public License
|
|
7
|
-
* version 2 as published by the Free Software Foundation.
|
|
8
|
-
*
|
|
9
|
-
* This program is distributed in the hope that it will be useful,
|
|
10
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
* GNU General Public License for more details.
|
|
13
|
-
*/
|
|
14
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.makeSQLBlock = void 0;
|
|
19
|
-
const md5_1 = __importDefault(require("md5"));
|
|
20
|
-
/**
|
|
21
|
-
* The factory for SQLBlocks.
|
|
22
|
-
*/
|
|
23
|
-
function makeSQLBlock(from) {
|
|
24
|
-
const theBlock = {
|
|
25
|
-
type: "sqlBlock",
|
|
26
|
-
name: `md5:/${from.connection || "$default"}//${(0, md5_1.default)(from.select)}`,
|
|
27
|
-
select: from.select,
|
|
28
|
-
};
|
|
29
|
-
if (from.before) {
|
|
30
|
-
theBlock.before = from.before;
|
|
31
|
-
}
|
|
32
|
-
if (from.after) {
|
|
33
|
-
theBlock.after = from.after;
|
|
34
|
-
}
|
|
35
|
-
return theBlock;
|
|
36
|
-
}
|
|
37
|
-
exports.makeSQLBlock = makeSQLBlock;
|
|
38
|
-
//# sourceMappingURL=sql-block.js.map
|