@malloydata/malloy 0.0.195-dev241003204819 → 0.0.195-dev241007154000
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/connection/base_connection.d.ts +21 -7
- package/dist/connection/base_connection.js +62 -0
- package/dist/connection/types.d.ts +5 -5
- package/dist/dialect/dialect.d.ts +5 -3
- package/dist/dialect/dialect.js +15 -0
- package/dist/dialect/duckdb/duckdb.d.ts +3 -3
- package/dist/dialect/duckdb/duckdb.js +8 -3
- package/dist/dialect/postgres/postgres.d.ts +3 -3
- package/dist/dialect/postgres/postgres.js +5 -2
- package/dist/dialect/snowflake/snowflake.d.ts +3 -3
- package/dist/dialect/snowflake/snowflake.js +4 -1
- package/dist/dialect/standardsql/standardsql.d.ts +3 -3
- package/dist/dialect/standardsql/standardsql.js +5 -2
- package/dist/dialect/trino/trino.d.ts +3 -3
- package/dist/dialect/trino/trino.js +35 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -2
- package/dist/lang/ast/error-factory.d.ts +4 -3
- package/dist/lang/ast/error-factory.js +27 -17
- package/dist/lang/ast/expressions/constant-expression.d.ts +1 -0
- package/dist/lang/ast/expressions/constant-expression.js +3 -0
- package/dist/lang/ast/expressions/expr-aggregate-function.d.ts +3 -7
- package/dist/lang/ast/expressions/expr-aggregate-function.js +50 -54
- package/dist/lang/ast/expressions/expr-cast.js +2 -4
- package/dist/lang/ast/expressions/expr-func.js +1 -1
- package/dist/lang/ast/expressions/expr-granular-time.js +1 -1
- package/dist/lang/ast/expressions/expr-record-literal.d.ts +16 -0
- package/dist/lang/ast/expressions/expr-record-literal.js +57 -0
- package/dist/lang/ast/expressions/expr-time-extract.js +3 -3
- package/dist/lang/ast/expressions/expr-time.d.ts +3 -3
- package/dist/lang/ast/expressions/expr-time.js +1 -1
- package/dist/lang/ast/expressions/time-literal.d.ts +6 -6
- package/dist/lang/ast/expressions/time-literal.js +1 -1
- package/dist/lang/ast/field-space/column-space-field.d.ts +6 -5
- package/dist/lang/ast/field-space/column-space-field.js +7 -4
- package/dist/lang/ast/field-space/dynamic-space.d.ts +8 -6
- package/dist/lang/ast/field-space/dynamic-space.js +35 -11
- package/dist/lang/ast/field-space/index-field-space.js +6 -3
- package/dist/lang/ast/field-space/ir-view-field.d.ts +1 -0
- package/dist/lang/ast/field-space/ir-view-field.js +3 -1
- package/dist/lang/ast/field-space/join-space-field.d.ts +2 -2
- package/dist/lang/ast/field-space/join-space-field.js +2 -2
- package/dist/lang/ast/field-space/parameter-space.d.ts +1 -0
- package/dist/lang/ast/field-space/parameter-space.js +4 -1
- package/dist/lang/ast/field-space/query-input-space.d.ts +4 -4
- package/dist/lang/ast/field-space/query-input-space.js +3 -5
- package/dist/lang/ast/field-space/query-spaces.d.ts +4 -4
- package/dist/lang/ast/field-space/query-spaces.js +1 -1
- package/dist/lang/ast/field-space/reference-field.js +10 -8
- package/dist/lang/ast/field-space/refined-space.d.ts +2 -2
- package/dist/lang/ast/field-space/static-space.d.ts +14 -5
- package/dist/lang/ast/field-space/static-space.js +45 -20
- package/dist/lang/ast/field-space/struct-space-field-base.d.ts +6 -5
- package/dist/lang/ast/field-space/struct-space-field-base.js +12 -4
- package/dist/lang/ast/index.d.ts +2 -1
- package/dist/lang/ast/index.js +2 -1
- package/dist/lang/ast/query-builders/index-builder.d.ts +2 -2
- package/dist/lang/ast/query-builders/project-builder.d.ts +2 -2
- package/dist/lang/ast/query-builders/reduce-builder.d.ts +2 -2
- package/dist/lang/ast/query-elements/query-arrow.js +2 -2
- package/dist/lang/ast/query-elements/query-head-struct.d.ts +2 -2
- package/dist/lang/ast/query-elements/query-head-struct.js +2 -2
- package/dist/lang/ast/query-elements/query-raw.js +2 -2
- package/dist/lang/ast/query-elements/query-reference.js +1 -1
- package/dist/lang/ast/query-items/field-declaration.d.ts +8 -6
- package/dist/lang/ast/query-items/field-declaration.js +66 -24
- package/dist/lang/ast/query-properties/qop-desc.d.ts +2 -2
- package/dist/lang/ast/query-properties/qop-desc.js +1 -1
- package/dist/lang/ast/source-elements/named-source.d.ts +4 -4
- package/dist/lang/ast/source-elements/named-source.js +16 -8
- package/dist/lang/ast/source-elements/query-source.d.ts +3 -3
- package/dist/lang/ast/source-elements/query-source.js +5 -2
- package/dist/lang/ast/source-elements/refined-source.d.ts +3 -3
- package/dist/lang/ast/source-elements/refined-source.js +4 -4
- package/dist/lang/ast/source-elements/source.d.ts +2 -2
- package/dist/lang/ast/source-elements/source.js +2 -2
- package/dist/lang/ast/source-elements/sql-source.d.ts +4 -4
- package/dist/lang/ast/source-elements/sql-source.js +6 -6
- package/dist/lang/ast/source-elements/table-source.d.ts +2 -2
- package/dist/lang/ast/source-elements/table-source.js +1 -1
- package/dist/lang/ast/source-properties/{joins.d.ts → join.d.ts} +11 -14
- package/dist/lang/ast/source-properties/{joins.js → join.js} +35 -52
- package/dist/lang/ast/source-query-elements/sq-reference.js +6 -5
- package/dist/lang/ast/sql-elements/sql-string.d.ts +2 -2
- package/dist/lang/ast/statements/define-source.js +1 -1
- package/dist/lang/ast/struct-utils.d.ts +3 -3
- package/dist/lang/ast/struct-utils.js +12 -3
- package/dist/lang/ast/time-utils.d.ts +3 -3
- package/dist/lang/ast/types/document-compile-result.d.ts +2 -2
- package/dist/lang/ast/types/expression-def.js +4 -4
- package/dist/lang/ast/types/field-space.d.ts +8 -3
- package/dist/lang/ast/types/lookup-result.d.ts +8 -5
- package/dist/lang/ast/types/malloy-element.d.ts +3 -3
- package/dist/lang/ast/types/malloy-element.js +10 -21
- package/dist/lang/ast/types/op-desc.d.ts +2 -2
- package/dist/lang/ast/types/pipeline-comp.d.ts +2 -2
- package/dist/lang/ast/types/query-comp.d.ts +3 -3
- package/dist/lang/ast/types/query-extend-property.d.ts +1 -2
- package/dist/lang/ast/types/query-extend-property.js +4 -2
- package/dist/lang/ast/types/source-property.d.ts +2 -2
- package/dist/lang/ast/types/source-property.js +2 -2
- package/dist/lang/ast/types/space-field.d.ts +10 -3
- package/dist/lang/ast/types/space-field.js +11 -2
- package/dist/lang/ast/types/time-result.d.ts +2 -2
- package/dist/lang/ast/view-elements/qop-desc-view.d.ts +3 -3
- package/dist/lang/ast/view-elements/qop-desc-view.js +1 -1
- package/dist/lang/ast/view-elements/reference-view.d.ts +4 -4
- package/dist/lang/ast/view-elements/reference-view.js +2 -6
- package/dist/lang/ast/view-elements/view-refine.d.ts +2 -2
- package/dist/lang/index.d.ts +1 -1
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +54 -21
- package/dist/lang/lib/Malloy/MalloyParser.js +1647 -1457
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +57 -9
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +35 -5
- package/dist/lang/malloy-to-ast.d.ts +4 -4
- package/dist/lang/malloy-to-ast.js +32 -4
- package/dist/lang/parse-log.d.ts +5 -9
- package/dist/lang/parse-malloy.d.ts +10 -10
- package/dist/lang/parse-malloy.js +2 -1
- package/dist/lang/test/annotation.spec.js +7 -1
- package/dist/lang/test/field-symbols.spec.js +21 -25
- package/dist/lang/test/imports.spec.js +12 -10
- package/dist/lang/test/lenses.spec.js +2 -2
- package/dist/lang/test/model_serialization.spec.d.ts +4 -4
- package/dist/lang/test/model_serialization.spec.js +19 -31
- package/dist/lang/test/parse.spec.js +3 -4
- package/dist/lang/test/query.spec.js +3 -2
- package/dist/lang/test/source.spec.js +7 -0
- package/dist/lang/test/sql-block.spec.js +8 -19
- package/dist/lang/test/test-translator.d.ts +4 -4
- package/dist/lang/test/test-translator.js +53 -61
- package/dist/lang/translate-response.d.ts +3 -3
- package/dist/malloy.d.ts +31 -149
- package/dist/malloy.js +111 -269
- package/dist/model/malloy_query.d.ts +25 -23
- package/dist/model/malloy_query.js +262 -323
- package/dist/model/malloy_types.d.ts +145 -155
- package/dist/model/malloy_types.js +81 -84
- package/dist/model/sql_block.d.ts +4 -4
- package/dist/model/sql_block.js +9 -12
- package/dist/tags.js +2 -2
- package/dist/version.d.ts +1 -0
- package/dist/version.js +6 -0
- package/package.json +3 -2
- package/dist/lang/ast/space-seed.d.ts +0 -16
- package/dist/lang/ast/space-seed.js +0 -59
|
@@ -24,7 +24,7 @@ export type AnyExpr = ExprE | ExprOptionalE | ExprWithKids | ExprLeaf;
|
|
|
24
24
|
export declare function exprHasKids(e: AnyExpr): e is ExprWithKids;
|
|
25
25
|
export declare function exprHasE(e: AnyExpr): e is ExprE;
|
|
26
26
|
export declare function exprIsLeaf(e: AnyExpr): boolean;
|
|
27
|
-
export type Expr = BinaryExpr | UnaryExpr | FunctionCallNode | OutputFieldNode | FilterCondition | FilteredExpr | AggregateExpr | EmptyExpr | UngroupNode | FunctionParameterNode | SpreadExpr | AggregateOrderByNode | AggregateLimitNode | FieldnameNode | SourceReferenceNode | ParameterNode | NowNode | MeasureTimeExpr | TimeDeltaExpr | TimeTruncExpr | TimeExtractExpr | TypecastExpr | RegexMatchExpr | RegexLiteralNode | TimeLiteralNode | StringLiteralNode | NumberLiteralNode | BooleanLiteralNode | FunctionOrderBy | GenericSQLExpr | NullNode | PickExpr | ErrorNode;
|
|
27
|
+
export type Expr = BinaryExpr | UnaryExpr | FunctionCallNode | OutputFieldNode | FilterCondition | FilteredExpr | AggregateExpr | EmptyExpr | UngroupNode | FunctionParameterNode | SpreadExpr | AggregateOrderByNode | AggregateLimitNode | FieldnameNode | SourceReferenceNode | ParameterNode | NowNode | MeasureTimeExpr | TimeDeltaExpr | TimeTruncExpr | TimeExtractExpr | TypecastExpr | RegexMatchExpr | RegexLiteralNode | TimeLiteralNode | StringLiteralNode | NumberLiteralNode | BooleanLiteralNode | RecordLiteralNode | ArrayLiteralNode | FunctionOrderBy | GenericSQLExpr | NullNode | PickExpr | ArrayEachExpr | ErrorNode;
|
|
28
28
|
interface HasDataType {
|
|
29
29
|
dataType: AtomicFieldType;
|
|
30
30
|
}
|
|
@@ -118,7 +118,7 @@ export interface NowNode extends ExprLeaf {
|
|
|
118
118
|
node: 'now';
|
|
119
119
|
}
|
|
120
120
|
interface HasTimeValue {
|
|
121
|
-
dataType:
|
|
121
|
+
dataType: TemporalFieldType;
|
|
122
122
|
}
|
|
123
123
|
type TimeExpr = Expr & HasTimeValue;
|
|
124
124
|
export interface MeasureTimeExpr extends ExprWithKids {
|
|
@@ -167,7 +167,7 @@ export interface RegexMatchExpr extends ExprWithKids {
|
|
|
167
167
|
export interface TimeLiteralNode extends ExprLeaf {
|
|
168
168
|
node: 'timeLiteral';
|
|
169
169
|
literal: string;
|
|
170
|
-
dataType:
|
|
170
|
+
dataType: TemporalFieldType;
|
|
171
171
|
timezone?: string;
|
|
172
172
|
}
|
|
173
173
|
export interface StringLiteralNode extends ExprLeaf {
|
|
@@ -185,6 +185,17 @@ export interface NumberLiteralNode extends ExprLeaf {
|
|
|
185
185
|
export interface BooleanLiteralNode extends ExprLeaf {
|
|
186
186
|
node: 'true' | 'false';
|
|
187
187
|
}
|
|
188
|
+
export interface RecordLiteralNode extends ExprWithKids {
|
|
189
|
+
node: 'recordLiteral';
|
|
190
|
+
kids: Record<string, TypedExpr>;
|
|
191
|
+
}
|
|
192
|
+
export interface ArrayLiteralNode extends ExprWithKids {
|
|
193
|
+
node: 'arrayLiteral';
|
|
194
|
+
kids: {
|
|
195
|
+
values: Expr[];
|
|
196
|
+
};
|
|
197
|
+
dataType: AtomicFieldType;
|
|
198
|
+
}
|
|
188
199
|
export interface ErrorNode extends ExprLeaf {
|
|
189
200
|
node: 'error';
|
|
190
201
|
message?: string;
|
|
@@ -207,6 +218,9 @@ export interface PickExpr extends ExprWithKids {
|
|
|
207
218
|
pickElse: Expr;
|
|
208
219
|
};
|
|
209
220
|
}
|
|
221
|
+
export interface ArrayEachExpr extends ExprLeaf {
|
|
222
|
+
node: 'arrayEach';
|
|
223
|
+
}
|
|
210
224
|
export type ExpressionType = 'scalar' | 'aggregate' | 'scalar_analytic' | 'aggregate_analytic' | 'ungrouped_aggregate';
|
|
211
225
|
export interface Expression {
|
|
212
226
|
e?: Expr;
|
|
@@ -252,7 +266,7 @@ export interface DocumentJoinReference extends DocumentReferenceBase {
|
|
|
252
266
|
}
|
|
253
267
|
export interface DocumentSQLBlockReference extends DocumentReferenceBase {
|
|
254
268
|
type: 'sqlBlockReference';
|
|
255
|
-
definition:
|
|
269
|
+
definition: SQLSourceDef;
|
|
256
270
|
}
|
|
257
271
|
export interface DocumentQueryReference extends DocumentReferenceBase {
|
|
258
272
|
type: 'queryReference';
|
|
@@ -272,9 +286,6 @@ export interface AliasedName {
|
|
|
272
286
|
name: string;
|
|
273
287
|
as?: string;
|
|
274
288
|
}
|
|
275
|
-
export interface TypedObject {
|
|
276
|
-
type: string;
|
|
277
|
-
}
|
|
278
289
|
/** all named objects have a type an a name (optionally aliased) */
|
|
279
290
|
export interface NamedObject extends AliasedName, HasLocation {
|
|
280
291
|
type: string;
|
|
@@ -306,15 +317,14 @@ export declare function expressionIsAnalytic(e: ExpressionType | undefined): boo
|
|
|
306
317
|
export declare function isExpressionTypeLEQ(e1: ExpressionType, e2: ExpressionType): boolean;
|
|
307
318
|
export declare function maxExpressionType(e1: ExpressionType, e2: ExpressionType): ExpressionType;
|
|
308
319
|
export declare function maxOfExpressionTypes(types: ExpressionType[]): ExpressionType;
|
|
309
|
-
|
|
320
|
+
/** Grants access to the expression properties of a FieldDef */
|
|
321
|
+
export declare function hasExpression<T extends FieldDef>(f: T): f is T & Expression & {
|
|
310
322
|
e: Expr;
|
|
311
323
|
};
|
|
312
|
-
|
|
313
|
-
export declare function
|
|
314
|
-
export type
|
|
315
|
-
export
|
|
316
|
-
export type CastType = 'string' | 'number' | TimeFieldType | 'boolean' | 'json';
|
|
317
|
-
export type AtomicFieldType = CastType | 'sql native' | 'error';
|
|
324
|
+
export type TemporalFieldType = 'date' | 'timestamp';
|
|
325
|
+
export declare function isTemporalField(s: string): s is TemporalFieldType;
|
|
326
|
+
export type CastType = 'string' | 'number' | TemporalFieldType | 'boolean' | 'json';
|
|
327
|
+
export type AtomicFieldType = CastType | 'sql native' | 'record' | 'array' | 'error';
|
|
318
328
|
export declare function isAtomicFieldType(s: string): s is AtomicFieldType;
|
|
319
329
|
export declare function isCastType(s: string): s is CastType;
|
|
320
330
|
/**
|
|
@@ -322,56 +332,84 @@ export declare function isCastType(s: string): s is CastType;
|
|
|
322
332
|
* value could be an expression, and this is one of the objects
|
|
323
333
|
* which might have an annotation.
|
|
324
334
|
*/
|
|
325
|
-
export interface
|
|
326
|
-
type: AtomicFieldType;
|
|
335
|
+
export interface FieldBase extends NamedObject, Expression, ResultMetadata {
|
|
327
336
|
annotation?: Annotation;
|
|
328
337
|
}
|
|
329
|
-
|
|
330
|
-
|
|
338
|
+
interface FieldAtomicBase extends FieldBase {
|
|
339
|
+
type: AtomicFieldType;
|
|
340
|
+
}
|
|
341
|
+
export declare function fieldIsIntrinsic(f: FieldDef): boolean;
|
|
342
|
+
export interface StringTypeDef {
|
|
331
343
|
type: 'string';
|
|
332
344
|
bucketFilter?: string;
|
|
333
345
|
bucketOther?: string;
|
|
334
346
|
}
|
|
335
|
-
|
|
336
|
-
export interface
|
|
337
|
-
type: 'string';
|
|
338
|
-
}
|
|
339
|
-
export interface FieldNumberTypeDef {
|
|
347
|
+
export type StringFieldDef = StringTypeDef & AtomicFieldDef;
|
|
348
|
+
export interface NumberTypeDef {
|
|
340
349
|
type: 'number';
|
|
341
350
|
numberType?: 'integer' | 'float';
|
|
342
351
|
}
|
|
343
|
-
|
|
344
|
-
export interface
|
|
345
|
-
type: 'number';
|
|
346
|
-
}
|
|
347
|
-
export interface FieldBooleanTypeDef {
|
|
348
|
-
type: 'boolean';
|
|
349
|
-
}
|
|
350
|
-
/** Scalar Boolean Field */
|
|
351
|
-
export interface FieldBooleanDef extends FieldAtomicDef, FieldBooleanTypeDef {
|
|
352
|
+
export type NumberFieldDef = NumberTypeDef & AtomicFieldDef;
|
|
353
|
+
export interface BooleanTypeDef {
|
|
352
354
|
type: 'boolean';
|
|
353
355
|
}
|
|
354
|
-
export
|
|
355
|
-
|
|
356
|
-
}
|
|
357
|
-
/** Scalar JSON Field */
|
|
358
|
-
export interface FieldJSONDef extends FieldAtomicDef, FieldJSONTypeDef {
|
|
356
|
+
export type BooleanFieldDef = BooleanTypeDef & AtomicFieldDef;
|
|
357
|
+
export interface JSONTypeDef {
|
|
359
358
|
type: 'json';
|
|
360
359
|
}
|
|
361
|
-
export
|
|
360
|
+
export type JSONFieldDef = JSONTypeDef & AtomicFieldDef;
|
|
361
|
+
export interface NativeUnsupportedTypeDef {
|
|
362
362
|
type: 'sql native';
|
|
363
363
|
rawType?: string;
|
|
364
364
|
}
|
|
365
|
-
|
|
366
|
-
export interface
|
|
367
|
-
type: '
|
|
368
|
-
|
|
369
|
-
|
|
365
|
+
export type NativeUnsupportedFieldDef = NativeUnsupportedTypeDef & AtomicFieldDef;
|
|
366
|
+
export interface ArrayTypeDef {
|
|
367
|
+
type: 'array';
|
|
368
|
+
elementTypeDef: Exclude<AtomicTypeDef, RecordTypeDef> | RecordElementTypeDef;
|
|
369
|
+
}
|
|
370
|
+
export type ArrayFieldDef = ArrayTypeDef & AtomicFieldDef;
|
|
371
|
+
export interface JoinedArrayTypeDef extends ArrayTypeDef, JoinBase, StructDefBase {
|
|
372
|
+
type: 'array';
|
|
373
|
+
join: 'many';
|
|
374
|
+
}
|
|
375
|
+
export type JoinedArrayDef = JoinedArrayTypeDef & AtomicFieldDef;
|
|
376
|
+
export declare function arrayEachFields(arrayOf: AtomicTypeDef): AtomicFieldDef[];
|
|
377
|
+
export interface RecordTypeDef extends StructDefBase, JoinBase {
|
|
378
|
+
type: 'record';
|
|
379
|
+
join: 'one';
|
|
380
|
+
}
|
|
381
|
+
export interface RecordElementTypeDef {
|
|
382
|
+
type: 'record_element';
|
|
383
|
+
}
|
|
384
|
+
export interface RepeatedRecordTypeDef extends JoinedArrayTypeDef {
|
|
385
|
+
type: 'array';
|
|
386
|
+
elementTypeDef: RecordElementTypeDef;
|
|
387
|
+
join: 'many';
|
|
388
|
+
}
|
|
389
|
+
export type RecordFieldDef = RecordTypeDef & AtomicFieldDef;
|
|
390
|
+
export type RepeatedRecordFieldDef = RepeatedRecordTypeDef & AtomicFieldDef;
|
|
391
|
+
export declare function isRepeatedRecord(fd: FieldDef): fd is RepeatedRecordFieldDef;
|
|
392
|
+
export interface ErrorTypeDef {
|
|
370
393
|
type: 'error';
|
|
371
394
|
}
|
|
372
|
-
export
|
|
373
|
-
|
|
395
|
+
export type ErrorFieldDef = ErrorTypeDef & AtomicFieldDef;
|
|
396
|
+
export type JoinType = 'one' | 'many' | 'cross';
|
|
397
|
+
export type JoinRelationship = 'one_to_one' | 'one_to_many' | 'many_to_one' | 'many_to_many';
|
|
398
|
+
export type MatrixOperation = 'left' | 'right' | 'full' | 'inner';
|
|
399
|
+
export declare function isMatrixOperation(x: string): x is MatrixOperation;
|
|
400
|
+
export type JoinElementType = 'table' | 'sql_select' | 'query_source' | 'array' | 'record';
|
|
401
|
+
export interface JoinBase {
|
|
402
|
+
type: JoinElementType;
|
|
403
|
+
join: JoinType;
|
|
404
|
+
matrixOperation?: MatrixOperation;
|
|
405
|
+
onExpression?: Expr;
|
|
374
406
|
}
|
|
407
|
+
export type Joinable = TableSourceDef | SQLSourceDef | QuerySourceDef | RecordFieldDef | JoinedArrayDef;
|
|
408
|
+
export type JoinFieldDef = JoinBase & Joinable;
|
|
409
|
+
export type JoinFieldTypes = 'table' | 'sql_select' | 'query_source' | 'array' | 'record';
|
|
410
|
+
export declare function isJoinable(sd: StructDef): sd is Joinable;
|
|
411
|
+
export declare function isJoined<T extends FieldDef | StructDef>(fd: T): fd is T & Joinable & JoinBase;
|
|
412
|
+
export declare function isJoinedSource(sd: StructDef): sd is SourceDef & JoinBase;
|
|
375
413
|
export type DateUnit = 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
376
414
|
export declare function isDateUnit(str: string): str is DateUnit;
|
|
377
415
|
export type TimestampUnit = DateUnit | 'hour' | 'minute' | 'second';
|
|
@@ -386,22 +424,16 @@ export declare enum ValueType {
|
|
|
386
424
|
String = "string"
|
|
387
425
|
}
|
|
388
426
|
export type TimeValueType = ValueType.Date | ValueType.Timestamp;
|
|
389
|
-
export interface
|
|
427
|
+
export interface DateTypeDef {
|
|
390
428
|
type: 'date';
|
|
391
429
|
timeframe?: DateUnit;
|
|
392
430
|
}
|
|
393
|
-
|
|
394
|
-
export interface
|
|
395
|
-
type: 'date';
|
|
396
|
-
}
|
|
397
|
-
export interface FieldTimestampTypeDef {
|
|
431
|
+
export type DateFieldDef = DateTypeDef & AtomicFieldDef;
|
|
432
|
+
export interface TimestampTypeDef {
|
|
398
433
|
type: 'timestamp';
|
|
399
434
|
timeframe?: TimestampUnit;
|
|
400
435
|
}
|
|
401
|
-
|
|
402
|
-
export interface FieldTimestampDef extends FieldAtomicDef, FieldTimestampTypeDef {
|
|
403
|
-
type: 'timestamp';
|
|
404
|
-
}
|
|
436
|
+
export type TimestampFieldDef = TimestampTypeDef & AtomicFieldDef;
|
|
405
437
|
/** parameter to order a query */
|
|
406
438
|
export interface OrderBy {
|
|
407
439
|
field: string | number;
|
|
@@ -428,18 +460,12 @@ export type By = ByName | ByExpression;
|
|
|
428
460
|
export declare function isByName(by: By | undefined): by is ByName;
|
|
429
461
|
export declare function isByExpression(by: By | undefined): by is ByExpression;
|
|
430
462
|
/** reference to a data source */
|
|
431
|
-
export type StructRef = string |
|
|
432
|
-
export declare function refIsStructDef(ref: StructRef): ref is
|
|
463
|
+
export type StructRef = string | SourceDef;
|
|
464
|
+
export declare function refIsStructDef(ref: StructRef): ref is SourceDef;
|
|
433
465
|
export type InvokedStructRef = {
|
|
434
466
|
structRef: StructRef;
|
|
435
467
|
sourceArguments?: Record<string, Argument>;
|
|
436
468
|
};
|
|
437
|
-
/** join pattern structs is a struct. */
|
|
438
|
-
export interface JoinedStruct {
|
|
439
|
-
structRef: StructRef;
|
|
440
|
-
structRelationship: StructRelationship;
|
|
441
|
-
as: string;
|
|
442
|
-
}
|
|
443
469
|
export interface Filtered {
|
|
444
470
|
filterList?: FilterCondition[];
|
|
445
471
|
}
|
|
@@ -518,84 +544,63 @@ export interface TurtleDef extends NamedObject, Pipeline {
|
|
|
518
544
|
type: 'turtle';
|
|
519
545
|
annotation?: Annotation;
|
|
520
546
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
547
|
+
interface StructDefBase extends HasLocation, NamedObject {
|
|
548
|
+
type: string;
|
|
549
|
+
annotation?: Annotation;
|
|
550
|
+
modelAnnotation?: ModelAnnotation;
|
|
551
|
+
fields: FieldDef[];
|
|
552
|
+
dialect: string;
|
|
553
|
+
}
|
|
554
|
+
interface SourceDefBase extends StructDefBase, Filtered, ResultStructMetadata {
|
|
555
|
+
arguments?: Record<string, Argument>;
|
|
556
|
+
parameters?: Record<string, Parameter>;
|
|
557
|
+
queryTimezone?: string;
|
|
558
|
+
connection: string;
|
|
559
|
+
primaryKey?: PrimaryKeyRef;
|
|
560
|
+
}
|
|
561
|
+
/** which field is the primary key in this struct */
|
|
562
|
+
export type PrimaryKeyRef = string;
|
|
563
|
+
export interface TableSourceDef extends SourceDefBase {
|
|
564
|
+
type: 'table';
|
|
565
|
+
tablePath: string;
|
|
528
566
|
}
|
|
529
|
-
export declare function isJoinOn(sr: StructRelationship): sr is JoinOn;
|
|
530
|
-
/** types of joins. */
|
|
531
|
-
export type StructRelationship = {
|
|
532
|
-
type: 'basetable';
|
|
533
|
-
connectionName: string;
|
|
534
|
-
} | JoinOn | {
|
|
535
|
-
type: 'inline';
|
|
536
|
-
} | {
|
|
537
|
-
type: 'nested';
|
|
538
|
-
fieldName: string;
|
|
539
|
-
isArray: boolean;
|
|
540
|
-
};
|
|
541
567
|
export interface SQLStringSegment {
|
|
542
568
|
sql: string;
|
|
543
569
|
}
|
|
544
|
-
export type
|
|
545
|
-
export declare function
|
|
546
|
-
|
|
547
|
-
* A source reference to an SQL block. The compiler uses these to request
|
|
548
|
-
* an SQLBlock with it's schema and structdef defined. Use the factory
|
|
549
|
-
* makeSQLBlock to construct these.
|
|
550
|
-
*/
|
|
551
|
-
export interface SQLBlockSource {
|
|
570
|
+
export type SQLPhraseSegment = Query | SQLStringSegment;
|
|
571
|
+
export declare function isSegmentSQL(f: SQLPhraseSegment): f is SQLStringSegment;
|
|
572
|
+
export interface SQLSentence {
|
|
552
573
|
name: string;
|
|
553
|
-
connection
|
|
554
|
-
select:
|
|
574
|
+
connection: string;
|
|
575
|
+
select: SQLPhraseSegment[];
|
|
555
576
|
}
|
|
556
|
-
export interface
|
|
557
|
-
type: '
|
|
558
|
-
connection?: string;
|
|
577
|
+
export interface SQLSourceDef extends SourceDefBase {
|
|
578
|
+
type: 'sql_select';
|
|
559
579
|
selectStr: string;
|
|
560
580
|
}
|
|
561
|
-
interface
|
|
562
|
-
type: '
|
|
563
|
-
method: 'subquery';
|
|
564
|
-
sqlBlock: SQLBlock;
|
|
565
|
-
}
|
|
566
|
-
/** where does the struct come from? */
|
|
567
|
-
export type StructSource = {
|
|
568
|
-
type: 'table';
|
|
569
|
-
tablePath: string;
|
|
570
|
-
} | {
|
|
571
|
-
type: 'nested';
|
|
572
|
-
} | {
|
|
573
|
-
type: 'inline';
|
|
574
|
-
} | {
|
|
575
|
-
type: 'query';
|
|
581
|
+
export interface QuerySourceDef extends SourceDefBase {
|
|
582
|
+
type: 'query_source';
|
|
576
583
|
query: Query;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
method: 'nested' | 'lastStage';
|
|
580
|
-
} | {
|
|
584
|
+
}
|
|
585
|
+
export interface QueryResultDef extends SourceDefBase {
|
|
581
586
|
type: 'query_result';
|
|
582
|
-
} | SubquerySource;
|
|
583
|
-
/** struct that is intrinsic to the table */
|
|
584
|
-
export interface StructDef extends NamedObject, ResultStructMetadata, Filtered {
|
|
585
|
-
type: 'struct';
|
|
586
|
-
structSource: StructSource;
|
|
587
|
-
structRelationship: StructRelationship;
|
|
588
|
-
fields: FieldDef[];
|
|
589
|
-
primaryKey?: PrimaryKeyRef;
|
|
590
|
-
arguments?: Record<string, Argument>;
|
|
591
|
-
parameters?: Record<string, Parameter>;
|
|
592
|
-
queryTimezone?: string;
|
|
593
|
-
dialect: string;
|
|
594
|
-
annotation?: Annotation;
|
|
595
|
-
modelAnnotation?: ModelAnnotation;
|
|
596
587
|
}
|
|
588
|
+
export interface NestSourceDef extends SourceDefBase {
|
|
589
|
+
type: 'nest_source';
|
|
590
|
+
pipeSQL: string;
|
|
591
|
+
}
|
|
592
|
+
export interface FinalizeSourceDef extends SourceDefBase {
|
|
593
|
+
type: 'finalize';
|
|
594
|
+
}
|
|
595
|
+
export declare function sourceBase(sd: SourceDefBase): SourceDefBase;
|
|
596
|
+
export declare function isSourceDef(sd: StructDef | FieldDef): sd is SourceDef;
|
|
597
|
+
export type SourceDef = TableSourceDef | SQLSourceDef | QuerySourceDef | QueryResultDef | FinalizeSourceDef | NestSourceDef;
|
|
598
|
+
/** Is this the "FROM" table of a query tree */
|
|
599
|
+
export declare function isBaseTable(def: StructDef): def is SourceDef;
|
|
600
|
+
export declare function isScalarArray(def: FieldDef | StructDef): boolean;
|
|
601
|
+
export type StructDef = SourceDef | RecordFieldDef | JoinedArrayDef;
|
|
597
602
|
export type ExpressionValueType = AtomicFieldType | 'null' | 'duration' | 'any' | 'regular expression';
|
|
598
|
-
export type FieldValueType = ExpressionValueType | 'turtle' |
|
|
603
|
+
export type FieldValueType = ExpressionValueType | 'turtle' | JoinFieldTypes;
|
|
599
604
|
export interface ExpressionTypeDesc {
|
|
600
605
|
dataType: FieldValueType;
|
|
601
606
|
expressionType: ExpressionType;
|
|
@@ -646,32 +651,21 @@ export interface FunctionDef extends NamedObject {
|
|
|
646
651
|
export interface ConnectionDef extends NamedObject {
|
|
647
652
|
type: 'connection';
|
|
648
653
|
}
|
|
649
|
-
export
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
export
|
|
654
|
-
/** any of the different field types */
|
|
655
|
-
export type FieldTypeDef = FieldStringDef | FieldDateDef | FieldTimestampDef | FieldNumberDef | FieldBooleanDef | FieldJSONDef | FeldNativeUnsupportedDef | FieldErrorDef;
|
|
656
|
-
export type FieldAtomicTypeDef = FieldStringTypeDef | FieldDateTypeDef | FieldTimestampTypeDef | FieldNumberTypeDef | FieldBooleanTypeDef | FieldJSONTypeDef | FieldNativeUnsupportedTypeDef | FieldErrorTypeDef;
|
|
657
|
-
export declare function isFieldTypeDef(f: FieldDef): f is FieldTypeDef;
|
|
658
|
-
export declare function isFieldTimeBased(f: FieldDef): f is FieldTimestampDef | FieldDateDef;
|
|
659
|
-
export declare function isFieldStructDef(f: FieldDef): f is StructDef;
|
|
660
|
-
export type QueryFieldDef = FieldTypeDef | TurtleDef | RefToField;
|
|
661
|
-
/** basics statement */
|
|
662
|
-
export type FieldDef = FieldTypeDef | StructDef | TurtleDef;
|
|
663
|
-
/** reference to a field */
|
|
654
|
+
export type TemporalTypeDef = DateTypeDef | TimestampTypeDef;
|
|
655
|
+
export type LeafAtomicDef = StringTypeDef | TemporalTypeDef | NumberTypeDef | BooleanTypeDef | JSONTypeDef | NativeUnsupportedTypeDef | ErrorTypeDef;
|
|
656
|
+
export type AtomicTypeDef = LeafAtomicDef | ArrayTypeDef | RecordTypeDef;
|
|
657
|
+
export type AtomicFieldDef = AtomicTypeDef & FieldAtomicBase;
|
|
658
|
+
export type FieldDef = AtomicFieldDef | JoinFieldDef | TurtleDef;
|
|
664
659
|
export interface RefToField {
|
|
665
660
|
type: 'fieldref';
|
|
666
661
|
path: string[];
|
|
667
662
|
annotation?: Annotation;
|
|
668
663
|
}
|
|
669
|
-
export type
|
|
670
|
-
/** which field is the primary key in this struct */
|
|
671
|
-
export type PrimaryKeyRef = string;
|
|
664
|
+
export type QueryFieldDef = AtomicFieldDef | TurtleDef | RefToField;
|
|
672
665
|
/** Get the output name for a NamedObject */
|
|
673
666
|
export declare function getIdentifier(n: AliasedName): string;
|
|
674
667
|
export type NamedModelObject = StructDef | NamedQuery | FunctionDef | ConnectionDef;
|
|
668
|
+
export declare function modelObjIsSource(nmo: NamedModelObject): nmo is SourceDef;
|
|
675
669
|
/** Result of parsing a model file */
|
|
676
670
|
export interface ModelDef {
|
|
677
671
|
name: string;
|
|
@@ -680,7 +674,7 @@ export interface ModelDef {
|
|
|
680
674
|
annotation?: ModelAnnotation;
|
|
681
675
|
}
|
|
682
676
|
/** Very common record type */
|
|
683
|
-
export type
|
|
677
|
+
export type NamedSourceDefs = Record<string, SourceDef>;
|
|
684
678
|
export type NamedModelObjects = Record<string, NamedModelObject>;
|
|
685
679
|
/** Malloy source annotations attached to objects */
|
|
686
680
|
export interface Annotation {
|
|
@@ -727,7 +721,7 @@ export type QueryToMaterialize = {
|
|
|
727
721
|
queryName: string;
|
|
728
722
|
};
|
|
729
723
|
export interface CompiledQuery extends DrillSource {
|
|
730
|
-
structs:
|
|
724
|
+
structs: SourceDef[];
|
|
731
725
|
sql: string;
|
|
732
726
|
lastStageName: string;
|
|
733
727
|
malloy: string;
|
|
@@ -747,18 +741,14 @@ export interface QueryResult extends CompiledQuery {
|
|
|
747
741
|
profilingUrl?: string;
|
|
748
742
|
}
|
|
749
743
|
export declare function isTurtleDef(def: FieldDef): def is TurtleDef;
|
|
750
|
-
export declare function
|
|
744
|
+
export declare function isAtomic(def: FieldDef): def is AtomicFieldDef;
|
|
751
745
|
export interface SearchResultRow {
|
|
752
746
|
field_name: string;
|
|
753
747
|
field_value: string;
|
|
754
748
|
weight: number;
|
|
755
749
|
}
|
|
756
750
|
export type SearchResult = SearchResultRow[];
|
|
757
|
-
export declare function
|
|
758
|
-
export declare function isPhysical(field: FieldDef): boolean;
|
|
759
|
-
export declare function getDimensions(structDef: StructDef): FieldAtomicDef[];
|
|
760
|
-
export declare function getPhysicalFields(structDef: StructDef): FieldDef[];
|
|
761
|
-
export declare function isMeasureLike(field: FieldDef): boolean;
|
|
751
|
+
export declare function getAtomicFields(structDef: StructDef): AtomicFieldDef[];
|
|
762
752
|
export declare function isValueString(value: QueryValue, field: FieldDef): value is string | null;
|
|
763
753
|
export declare function isValueNumber(value: QueryValue, field: FieldDef): value is number | null;
|
|
764
754
|
export declare function isValueBoolean(value: QueryValue, field: FieldDef): value is boolean | null;
|