@malloydata/malloy-query-builder 0.0.281 → 0.0.282
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/query-ast.d.ts +54 -9
- package/dist/query-ast.js +141 -6
- package/dist/query-ast.js.map +1 -1
- package/dist/query-ast.spec.js +86 -0
- package/dist/query-ast.spec.js.map +1 -1
- package/package.json +4 -4
- package/src/query-ast.spec.ts +86 -0
- package/src/query-ast.ts +184 -7
package/dist/query-ast.d.ts
CHANGED
|
@@ -424,6 +424,7 @@ export declare class ASTStringLiteralValue extends ASTObjectNode<Malloy.LiteralV
|
|
|
424
424
|
node: Malloy.LiteralValueWithStringLiteral;
|
|
425
425
|
readonly kind: Malloy.LiteralValueType;
|
|
426
426
|
constructor(node: Malloy.LiteralValueWithStringLiteral);
|
|
427
|
+
get fieldType(): Malloy.AtomicType;
|
|
427
428
|
}
|
|
428
429
|
export declare class ASTNullLiteralValue extends ASTObjectNode<Malloy.LiteralValueWithNullLiteral, {
|
|
429
430
|
kind: 'null_literal';
|
|
@@ -431,6 +432,7 @@ export declare class ASTNullLiteralValue extends ASTObjectNode<Malloy.LiteralVal
|
|
|
431
432
|
node: Malloy.LiteralValueWithNullLiteral;
|
|
432
433
|
readonly kind: Malloy.LiteralValueType;
|
|
433
434
|
constructor(node: Malloy.LiteralValueWithNullLiteral);
|
|
435
|
+
get fieldType(): undefined;
|
|
434
436
|
}
|
|
435
437
|
export declare class ASTNumberLiteralValue extends ASTObjectNode<Malloy.LiteralValueWithNumberLiteral, {
|
|
436
438
|
kind: 'number_literal';
|
|
@@ -439,6 +441,7 @@ export declare class ASTNumberLiteralValue extends ASTObjectNode<Malloy.LiteralV
|
|
|
439
441
|
node: Malloy.LiteralValueWithNumberLiteral;
|
|
440
442
|
readonly kind: Malloy.LiteralValueType;
|
|
441
443
|
constructor(node: Malloy.LiteralValueWithNumberLiteral);
|
|
444
|
+
get fieldType(): Malloy.AtomicType;
|
|
442
445
|
}
|
|
443
446
|
export declare class ASTBooleanLiteralValue extends ASTObjectNode<Malloy.LiteralValueWithBooleanLiteral, {
|
|
444
447
|
kind: 'boolean_literal';
|
|
@@ -447,6 +450,7 @@ export declare class ASTBooleanLiteralValue extends ASTObjectNode<Malloy.Literal
|
|
|
447
450
|
node: Malloy.LiteralValueWithBooleanLiteral;
|
|
448
451
|
readonly kind: Malloy.LiteralValueType;
|
|
449
452
|
constructor(node: Malloy.LiteralValueWithBooleanLiteral);
|
|
453
|
+
get fieldType(): Malloy.AtomicType;
|
|
450
454
|
}
|
|
451
455
|
export declare class ASTDateLiteralValue extends ASTObjectNode<Malloy.LiteralValueWithDateLiteral, {
|
|
452
456
|
kind: 'date_literal';
|
|
@@ -456,6 +460,7 @@ export declare class ASTDateLiteralValue extends ASTObjectNode<Malloy.LiteralVal
|
|
|
456
460
|
node: Malloy.LiteralValueWithDateLiteral;
|
|
457
461
|
readonly kind: Malloy.LiteralValueType;
|
|
458
462
|
constructor(node: Malloy.LiteralValueWithDateLiteral);
|
|
463
|
+
get fieldType(): Malloy.AtomicType;
|
|
459
464
|
}
|
|
460
465
|
export declare class ASTTimestampLiteralValue extends ASTObjectNode<Malloy.LiteralValueWithTimestampLiteral, {
|
|
461
466
|
kind: 'timestamp_literal';
|
|
@@ -465,6 +470,7 @@ export declare class ASTTimestampLiteralValue extends ASTObjectNode<Malloy.Liter
|
|
|
465
470
|
node: Malloy.LiteralValueWithTimestampLiteral;
|
|
466
471
|
readonly kind: Malloy.LiteralValueType;
|
|
467
472
|
constructor(node: Malloy.LiteralValueWithTimestampLiteral);
|
|
473
|
+
get fieldType(): Malloy.AtomicType;
|
|
468
474
|
}
|
|
469
475
|
export declare class ASTFilterExpressionLiteralValue extends ASTObjectNode<Malloy.LiteralValueWithFilterExpressionLiteral, {
|
|
470
476
|
kind: 'filter_expression_literal';
|
|
@@ -473,6 +479,7 @@ export declare class ASTFilterExpressionLiteralValue extends ASTObjectNode<Mallo
|
|
|
473
479
|
node: Malloy.LiteralValueWithFilterExpressionLiteral;
|
|
474
480
|
readonly kind: Malloy.LiteralValueType;
|
|
475
481
|
constructor(node: Malloy.LiteralValueWithFilterExpressionLiteral);
|
|
482
|
+
get fieldType(): undefined;
|
|
476
483
|
}
|
|
477
484
|
export declare class ASTUnimplemented<T> extends ASTNode<T> {
|
|
478
485
|
private readonly node;
|
|
@@ -902,6 +909,7 @@ export declare class ASTSegmentViewDefinition extends ASTObjectNode<Malloy.ViewD
|
|
|
902
909
|
* @param path Join path for this dimension.
|
|
903
910
|
*/
|
|
904
911
|
addGroupBy(name: string, path?: string[], rename?: string): ASTGroupByViewOperation;
|
|
912
|
+
addDrill(drill: Malloy.DrillOperation): ASTDrillViewOperation;
|
|
905
913
|
addWhere(name: string, filter: ParsedFilter): ASTWhereViewOperation;
|
|
906
914
|
addWhere(name: string, filterString: string): ASTWhereViewOperation;
|
|
907
915
|
addWhere(name: string, path: string[], filter: ParsedFilter): ASTWhereViewOperation;
|
|
@@ -1010,7 +1018,7 @@ export declare class ASTViewOperationList extends ASTListNode<Malloy.ViewOperati
|
|
|
1010
1018
|
*/
|
|
1011
1019
|
get segment(): ASTSegmentViewDefinition;
|
|
1012
1020
|
}
|
|
1013
|
-
export type ASTViewOperation = ASTGroupByViewOperation | ASTAggregateViewOperation | ASTOrderByViewOperation | ASTNestViewOperation | ASTLimitViewOperation | ASTWhereViewOperation | ASTHavingViewOperation;
|
|
1021
|
+
export type ASTViewOperation = ASTGroupByViewOperation | ASTAggregateViewOperation | ASTOrderByViewOperation | ASTNestViewOperation | ASTLimitViewOperation | ASTWhereViewOperation | ASTDrillViewOperation | ASTHavingViewOperation;
|
|
1014
1022
|
export declare const ASTViewOperation: {
|
|
1015
1023
|
from(value: Malloy.ViewOperation): ASTViewOperation;
|
|
1016
1024
|
isLimit(x: ASTViewOperation): x is ASTLimitViewOperation;
|
|
@@ -1195,7 +1203,7 @@ export declare class ASTField extends ASTObjectNode<Malloy.Field, {
|
|
|
1195
1203
|
constructor(node: Malloy.Field);
|
|
1196
1204
|
get expression(): ASTExpression;
|
|
1197
1205
|
set expression(expression: ASTExpression);
|
|
1198
|
-
get name(): string;
|
|
1206
|
+
get name(): string | undefined;
|
|
1199
1207
|
get type(): Malloy.AtomicType | {
|
|
1200
1208
|
timeframe: Malloy.DateTimeframe;
|
|
1201
1209
|
kind: "date_type";
|
|
@@ -1205,7 +1213,7 @@ export declare class ASTField extends ASTObjectNode<Malloy.Field, {
|
|
|
1205
1213
|
};
|
|
1206
1214
|
get annotations(): ASTAnnotationList | undefined;
|
|
1207
1215
|
set annotations(annotations: ASTAnnotationList | undefined);
|
|
1208
|
-
getReference(): Malloy.Reference;
|
|
1216
|
+
getReference(): Malloy.Reference | undefined;
|
|
1209
1217
|
getOrAddAnnotations(): ASTAnnotationList;
|
|
1210
1218
|
getInheritedTag(prefix?: RegExp | string): Tag;
|
|
1211
1219
|
getIntrinsicTag(prefix?: RegExp | string): Tag;
|
|
@@ -1218,7 +1226,7 @@ export declare class ASTField extends ASTObjectNode<Malloy.Field, {
|
|
|
1218
1226
|
get segment(): ASTSegmentViewDefinition;
|
|
1219
1227
|
getInheritedAnnotations(): Malloy.Annotation[];
|
|
1220
1228
|
}
|
|
1221
|
-
export type ASTExpression = ASTReferenceExpression | ASTFilteredFieldExpression | ASTTimeTruncationExpression;
|
|
1229
|
+
export type ASTExpression = ASTReferenceExpression | ASTFilteredFieldExpression | ASTTimeTruncationExpression | ASTLiteralValueExpression;
|
|
1222
1230
|
export declare const ASTExpression: {
|
|
1223
1231
|
from(value: Malloy.Expression): ASTExpression;
|
|
1224
1232
|
};
|
|
@@ -1274,11 +1282,23 @@ export declare class ASTTimeTruncationExpression extends ASTObjectNode<Malloy.Ex
|
|
|
1274
1282
|
};
|
|
1275
1283
|
getInheritedAnnotations(): Malloy.Annotation[];
|
|
1276
1284
|
}
|
|
1285
|
+
export declare class ASTLiteralValueExpression extends ASTObjectNode<Malloy.ExpressionWithLiteralValue, {
|
|
1286
|
+
kind: 'literal_value';
|
|
1287
|
+
literal_value: ASTLiteralValue;
|
|
1288
|
+
}> {
|
|
1289
|
+
node: Malloy.ExpressionWithLiteralValue;
|
|
1290
|
+
readonly kind: Malloy.ExpressionType;
|
|
1291
|
+
constructor(node: Malloy.ExpressionWithLiteralValue);
|
|
1292
|
+
get name(): undefined;
|
|
1293
|
+
get literalValue(): ASTLiteralValue;
|
|
1294
|
+
get fieldType(): Malloy.AtomicType | undefined;
|
|
1295
|
+
getInheritedAnnotations(): Malloy.Annotation[];
|
|
1296
|
+
}
|
|
1277
1297
|
export declare class ASTFilterOperation extends ASTObjectNode<Malloy.FilterOperation, {
|
|
1278
1298
|
filter: ASTFilter;
|
|
1279
1299
|
}> {
|
|
1280
1300
|
constructor(node: Malloy.FilterOperation);
|
|
1281
|
-
get filter():
|
|
1301
|
+
get filter(): ASTFilter;
|
|
1282
1302
|
get list(): ASTFilterOperationList;
|
|
1283
1303
|
delete(): void;
|
|
1284
1304
|
}
|
|
@@ -1387,7 +1407,21 @@ export declare class ASTWhereViewOperation extends ASTObjectNode<Malloy.ViewOper
|
|
|
1387
1407
|
node: Malloy.ViewOperationWithWhere;
|
|
1388
1408
|
readonly kind: Malloy.ViewOperationType;
|
|
1389
1409
|
constructor(node: Malloy.ViewOperationWithWhere);
|
|
1390
|
-
get filter():
|
|
1410
|
+
get filter(): ASTFilter;
|
|
1411
|
+
/**
|
|
1412
|
+
* @internal
|
|
1413
|
+
*/
|
|
1414
|
+
get list(): ASTViewOperationList;
|
|
1415
|
+
delete(): void;
|
|
1416
|
+
}
|
|
1417
|
+
export declare class ASTDrillViewOperation extends ASTObjectNode<Malloy.ViewOperationWithDrill, {
|
|
1418
|
+
kind: 'drill';
|
|
1419
|
+
filter: ASTFilter;
|
|
1420
|
+
}> {
|
|
1421
|
+
node: Malloy.ViewOperationWithDrill;
|
|
1422
|
+
readonly kind: Malloy.ViewOperationType;
|
|
1423
|
+
constructor(node: Malloy.ViewOperationWithDrill);
|
|
1424
|
+
get filter(): ASTFilter;
|
|
1391
1425
|
/**
|
|
1392
1426
|
* @internal
|
|
1393
1427
|
*/
|
|
@@ -1401,16 +1435,16 @@ export declare class ASTHavingViewOperation extends ASTObjectNode<Malloy.ViewOpe
|
|
|
1401
1435
|
node: Malloy.ViewOperationWithHaving;
|
|
1402
1436
|
readonly kind: Malloy.ViewOperationType;
|
|
1403
1437
|
constructor(node: Malloy.ViewOperationWithHaving);
|
|
1404
|
-
get filter():
|
|
1438
|
+
get filter(): ASTFilter;
|
|
1405
1439
|
/**
|
|
1406
1440
|
* @internal
|
|
1407
1441
|
*/
|
|
1408
1442
|
get list(): ASTViewOperationList;
|
|
1409
1443
|
delete(): void;
|
|
1410
1444
|
}
|
|
1411
|
-
export type ASTFilter = ASTFilterWithFilterString;
|
|
1445
|
+
export type ASTFilter = ASTFilterWithFilterString | ASTFilterWithLiteralEquality;
|
|
1412
1446
|
export declare const ASTFilter: {
|
|
1413
|
-
from(filter: Malloy.Filter): ASTFilterWithFilterString;
|
|
1447
|
+
from(filter: Malloy.Filter): ASTFilterWithFilterString | ASTFilterWithLiteralEquality;
|
|
1414
1448
|
};
|
|
1415
1449
|
export declare class ASTFilterWithFilterString extends ASTObjectNode<Malloy.FilterWithFilterString, {
|
|
1416
1450
|
kind: 'filter_string';
|
|
@@ -1429,6 +1463,17 @@ export declare class ASTFilterWithFilterString extends ASTObjectNode<Malloy.Filt
|
|
|
1429
1463
|
setFilter(filter: ParsedFilter): void;
|
|
1430
1464
|
getFilter(): ParsedFilter;
|
|
1431
1465
|
}
|
|
1466
|
+
export declare class ASTFilterWithLiteralEquality extends ASTObjectNode<Malloy.FilterWithLiteralEquality, {
|
|
1467
|
+
kind: 'literal_equality';
|
|
1468
|
+
field_reference: ASTFieldReference;
|
|
1469
|
+
value: ASTLiteralValue;
|
|
1470
|
+
}> {
|
|
1471
|
+
node: Malloy.FilterWithLiteralEquality;
|
|
1472
|
+
readonly kind: Malloy.FilterType;
|
|
1473
|
+
constructor(node: Malloy.FilterWithLiteralEquality);
|
|
1474
|
+
get fieldReference(): ASTFieldReference;
|
|
1475
|
+
get value(): ASTLiteralValue;
|
|
1476
|
+
}
|
|
1432
1477
|
export declare class ASTView extends ASTObjectNode<Malloy.View, {
|
|
1433
1478
|
definition: ASTViewDefinition;
|
|
1434
1479
|
annotations?: ASTAnnotationList;
|
package/dist/query-ast.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.ASTAnnotation = exports.ASTAnnotationList = exports.ASTLimitViewOperation = exports.ASTView = exports.ASTFilterWithFilterString = exports.ASTFilter = exports.ASTHavingViewOperation = exports.ASTWhereViewOperation = exports.ASTNestViewOperation = exports.ASTFilteredFieldExpression = exports.ASTFilterOperationList = exports.ASTFilterOperation = exports.ASTTimeTruncationExpression = exports.ASTReferenceExpression = exports.ASTExpression = exports.ASTField = exports.ASTAggregateViewOperation = exports.ASTGroupByViewOperation = exports.ASTOrderByViewOperation = exports.ASTViewOperation = exports.ASTViewOperationList = exports.ASTSegmentViewDefinition = exports.ASTRefinementViewDefinition = exports.ASTArrowViewDefinition = exports.ASTReferenceViewDefinition = exports.ASTReferenceQueryArrowSource = exports.ASTReferenceQueryDefinition = exports.ASTRefinementQueryDefinition = exports.ASTArrowQueryDefinition = exports.ASTQueryDefinition = exports.ASTQueryArrowSource = exports.ASTUnimplemented = exports.ASTFilterExpressionLiteralValue = exports.ASTTimestampLiteralValue = exports.ASTDateLiteralValue = exports.ASTBooleanLiteralValue = exports.ASTNumberLiteralValue = exports.ASTNullLiteralValue = exports.ASTStringLiteralValue = exports.ASTLiteralValue = exports.ASTParameterValue = exports.ASTParameterValueList = exports.ASTFieldReference = exports.ASTReference = exports.ASTQuery = void 0;
|
|
36
|
+
exports.ASTAnnotation = exports.ASTAnnotationList = exports.ASTLimitViewOperation = exports.ASTView = exports.ASTFilterWithLiteralEquality = exports.ASTFilterWithFilterString = exports.ASTFilter = exports.ASTHavingViewOperation = exports.ASTDrillViewOperation = exports.ASTWhereViewOperation = exports.ASTNestViewOperation = exports.ASTFilteredFieldExpression = exports.ASTFilterOperationList = exports.ASTFilterOperation = exports.ASTLiteralValueExpression = exports.ASTTimeTruncationExpression = exports.ASTReferenceExpression = exports.ASTExpression = exports.ASTField = exports.ASTAggregateViewOperation = exports.ASTGroupByViewOperation = exports.ASTOrderByViewOperation = exports.ASTViewOperation = exports.ASTViewOperationList = exports.ASTSegmentViewDefinition = exports.ASTRefinementViewDefinition = exports.ASTArrowViewDefinition = exports.ASTReferenceViewDefinition = exports.ASTReferenceQueryArrowSource = exports.ASTReferenceQueryDefinition = exports.ASTRefinementQueryDefinition = exports.ASTArrowQueryDefinition = exports.ASTQueryDefinition = exports.ASTQueryArrowSource = exports.ASTUnimplemented = exports.ASTFilterExpressionLiteralValue = exports.ASTTimestampLiteralValue = exports.ASTDateLiteralValue = exports.ASTBooleanLiteralValue = exports.ASTNumberLiteralValue = exports.ASTNullLiteralValue = exports.ASTStringLiteralValue = exports.ASTLiteralValue = exports.ASTParameterValue = exports.ASTParameterValueList = exports.ASTFieldReference = exports.ASTReference = exports.ASTQuery = void 0;
|
|
37
37
|
/*
|
|
38
38
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
39
39
|
*
|
|
@@ -1045,6 +1045,11 @@ class ASTStringLiteralValue extends ASTObjectNode {
|
|
|
1045
1045
|
this.node = node;
|
|
1046
1046
|
this.kind = 'string_literal';
|
|
1047
1047
|
}
|
|
1048
|
+
get fieldType() {
|
|
1049
|
+
return {
|
|
1050
|
+
kind: 'string_type',
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1048
1053
|
}
|
|
1049
1054
|
exports.ASTStringLiteralValue = ASTStringLiteralValue;
|
|
1050
1055
|
class ASTNullLiteralValue extends ASTObjectNode {
|
|
@@ -1055,6 +1060,9 @@ class ASTNullLiteralValue extends ASTObjectNode {
|
|
|
1055
1060
|
this.node = node;
|
|
1056
1061
|
this.kind = 'null_literal';
|
|
1057
1062
|
}
|
|
1063
|
+
get fieldType() {
|
|
1064
|
+
return undefined;
|
|
1065
|
+
}
|
|
1058
1066
|
}
|
|
1059
1067
|
exports.ASTNullLiteralValue = ASTNullLiteralValue;
|
|
1060
1068
|
class ASTNumberLiteralValue extends ASTObjectNode {
|
|
@@ -1066,6 +1074,14 @@ class ASTNumberLiteralValue extends ASTObjectNode {
|
|
|
1066
1074
|
this.node = node;
|
|
1067
1075
|
this.kind = 'number_literal';
|
|
1068
1076
|
}
|
|
1077
|
+
get fieldType() {
|
|
1078
|
+
return {
|
|
1079
|
+
kind: 'number_type',
|
|
1080
|
+
subtype: Number.isInteger(this.children.number_value)
|
|
1081
|
+
? 'integer'
|
|
1082
|
+
: 'decimal',
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1069
1085
|
}
|
|
1070
1086
|
exports.ASTNumberLiteralValue = ASTNumberLiteralValue;
|
|
1071
1087
|
class ASTBooleanLiteralValue extends ASTObjectNode {
|
|
@@ -1077,6 +1093,11 @@ class ASTBooleanLiteralValue extends ASTObjectNode {
|
|
|
1077
1093
|
this.node = node;
|
|
1078
1094
|
this.kind = 'boolean_literal';
|
|
1079
1095
|
}
|
|
1096
|
+
get fieldType() {
|
|
1097
|
+
return {
|
|
1098
|
+
kind: 'boolean_type',
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1080
1101
|
}
|
|
1081
1102
|
exports.ASTBooleanLiteralValue = ASTBooleanLiteralValue;
|
|
1082
1103
|
class ASTDateLiteralValue extends ASTObjectNode {
|
|
@@ -1089,6 +1110,12 @@ class ASTDateLiteralValue extends ASTObjectNode {
|
|
|
1089
1110
|
this.node = node;
|
|
1090
1111
|
this.kind = 'date_literal';
|
|
1091
1112
|
}
|
|
1113
|
+
get fieldType() {
|
|
1114
|
+
return {
|
|
1115
|
+
kind: 'date_type',
|
|
1116
|
+
timeframe: this.children.granularity,
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1092
1119
|
}
|
|
1093
1120
|
exports.ASTDateLiteralValue = ASTDateLiteralValue;
|
|
1094
1121
|
class ASTTimestampLiteralValue extends ASTObjectNode {
|
|
@@ -1101,6 +1128,12 @@ class ASTTimestampLiteralValue extends ASTObjectNode {
|
|
|
1101
1128
|
this.node = node;
|
|
1102
1129
|
this.kind = 'timestamp_literal';
|
|
1103
1130
|
}
|
|
1131
|
+
get fieldType() {
|
|
1132
|
+
return {
|
|
1133
|
+
kind: 'timestamp_type',
|
|
1134
|
+
timeframe: this.children.granularity,
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1104
1137
|
}
|
|
1105
1138
|
exports.ASTTimestampLiteralValue = ASTTimestampLiteralValue;
|
|
1106
1139
|
class ASTFilterExpressionLiteralValue extends ASTObjectNode {
|
|
@@ -1112,6 +1145,9 @@ class ASTFilterExpressionLiteralValue extends ASTObjectNode {
|
|
|
1112
1145
|
this.node = node;
|
|
1113
1146
|
this.kind = 'filter_expression_literal';
|
|
1114
1147
|
}
|
|
1148
|
+
get fieldType() {
|
|
1149
|
+
return undefined;
|
|
1150
|
+
}
|
|
1115
1151
|
}
|
|
1116
1152
|
exports.ASTFilterExpressionLiteralValue = ASTFilterExpressionLiteralValue;
|
|
1117
1153
|
class ASTUnimplemented extends ASTNode {
|
|
@@ -1840,6 +1876,7 @@ class ASTSegmentViewDefinition extends ASTObjectNode {
|
|
|
1840
1876
|
this.DEFAULT_INSERTION_ORDER = [
|
|
1841
1877
|
'group_by',
|
|
1842
1878
|
'aggregate',
|
|
1879
|
+
'drill',
|
|
1843
1880
|
'where',
|
|
1844
1881
|
'having',
|
|
1845
1882
|
'nest',
|
|
@@ -2104,7 +2141,9 @@ class ASTSegmentViewDefinition extends ASTObjectNode {
|
|
|
2104
2141
|
if (operation instanceof ASTGroupByViewOperation ||
|
|
2105
2142
|
operation instanceof ASTAggregateViewOperation) {
|
|
2106
2143
|
const reference = operation.field.getReference();
|
|
2107
|
-
if (reference
|
|
2144
|
+
if (reference &&
|
|
2145
|
+
reference.name === name &&
|
|
2146
|
+
pathsMatch(reference.path, path)) {
|
|
2108
2147
|
return operation;
|
|
2109
2148
|
}
|
|
2110
2149
|
}
|
|
@@ -2203,6 +2242,14 @@ class ASTSegmentViewDefinition extends ASTObjectNode {
|
|
|
2203
2242
|
this.addOperation(item);
|
|
2204
2243
|
return item;
|
|
2205
2244
|
}
|
|
2245
|
+
addDrill(drill) {
|
|
2246
|
+
const item = new ASTDrillViewOperation({
|
|
2247
|
+
kind: 'drill',
|
|
2248
|
+
...drill,
|
|
2249
|
+
});
|
|
2250
|
+
this.addOperation(item);
|
|
2251
|
+
return item;
|
|
2252
|
+
}
|
|
2206
2253
|
addWhere(name, arg2, arg3) {
|
|
2207
2254
|
const path = Array.isArray(arg2) ? arg2 : [];
|
|
2208
2255
|
const filter = arg3 === undefined ? arg2 : arg3;
|
|
@@ -2485,6 +2532,8 @@ exports.ASTViewOperation = {
|
|
|
2485
2532
|
return new ASTLimitViewOperation(value);
|
|
2486
2533
|
case 'where':
|
|
2487
2534
|
return new ASTWhereViewOperation(value);
|
|
2535
|
+
case 'drill':
|
|
2536
|
+
return new ASTDrillViewOperation(value);
|
|
2488
2537
|
case 'having':
|
|
2489
2538
|
return new ASTHavingViewOperation(value);
|
|
2490
2539
|
}
|
|
@@ -2551,7 +2600,11 @@ class ASTGroupByViewOperation extends ASTObjectNode {
|
|
|
2551
2600
|
}
|
|
2552
2601
|
get name() {
|
|
2553
2602
|
var _a;
|
|
2554
|
-
|
|
2603
|
+
const name = (_a = this.children.name) !== null && _a !== void 0 ? _a : this.field.name;
|
|
2604
|
+
if (name === undefined) {
|
|
2605
|
+
throw new Error('Group by does not have a name');
|
|
2606
|
+
}
|
|
2607
|
+
return name;
|
|
2555
2608
|
}
|
|
2556
2609
|
set name(name) {
|
|
2557
2610
|
if (this.name === name)
|
|
@@ -2705,7 +2758,11 @@ class ASTAggregateViewOperation extends ASTObjectNode {
|
|
|
2705
2758
|
}
|
|
2706
2759
|
get name() {
|
|
2707
2760
|
var _a;
|
|
2708
|
-
|
|
2761
|
+
const name = (_a = this.children.name) !== null && _a !== void 0 ? _a : this.field.name;
|
|
2762
|
+
if (name === undefined) {
|
|
2763
|
+
throw new Error('Aggregate does not have a name');
|
|
2764
|
+
}
|
|
2765
|
+
return name;
|
|
2709
2766
|
}
|
|
2710
2767
|
set name(name) {
|
|
2711
2768
|
if (this.name === name)
|
|
@@ -2873,7 +2930,11 @@ class ASTField extends ASTObjectNode {
|
|
|
2873
2930
|
return this.expression.name;
|
|
2874
2931
|
}
|
|
2875
2932
|
get type() {
|
|
2876
|
-
|
|
2933
|
+
const type = this.expression.fieldType;
|
|
2934
|
+
if (type === undefined) {
|
|
2935
|
+
throw new Error('Field expression does not have a type');
|
|
2936
|
+
}
|
|
2937
|
+
return type;
|
|
2877
2938
|
}
|
|
2878
2939
|
get annotations() {
|
|
2879
2940
|
return this.children.annotations;
|
|
@@ -2884,6 +2945,9 @@ class ASTField extends ASTObjectNode {
|
|
|
2884
2945
|
}
|
|
2885
2946
|
// Returns a Malloy reference that this field points to
|
|
2886
2947
|
getReference() {
|
|
2948
|
+
if (this.expression instanceof ASTLiteralValueExpression) {
|
|
2949
|
+
return undefined;
|
|
2950
|
+
}
|
|
2887
2951
|
return this.expression.getReference();
|
|
2888
2952
|
}
|
|
2889
2953
|
getOrAddAnnotations() {
|
|
@@ -2936,6 +3000,8 @@ exports.ASTExpression = {
|
|
|
2936
3000
|
return new ASTFilteredFieldExpression(value);
|
|
2937
3001
|
case 'time_truncation':
|
|
2938
3002
|
return new ASTTimeTruncationExpression(value);
|
|
3003
|
+
case 'literal_value':
|
|
3004
|
+
return new ASTLiteralValueExpression(value);
|
|
2939
3005
|
}
|
|
2940
3006
|
},
|
|
2941
3007
|
};
|
|
@@ -3060,6 +3126,29 @@ class ASTTimeTruncationExpression extends ASTObjectNode {
|
|
|
3060
3126
|
}
|
|
3061
3127
|
}
|
|
3062
3128
|
exports.ASTTimeTruncationExpression = ASTTimeTruncationExpression;
|
|
3129
|
+
class ASTLiteralValueExpression extends ASTObjectNode {
|
|
3130
|
+
constructor(node) {
|
|
3131
|
+
super(node, {
|
|
3132
|
+
kind: node.kind,
|
|
3133
|
+
literal_value: exports.ASTLiteralValue.from(node.literal_value),
|
|
3134
|
+
});
|
|
3135
|
+
this.node = node;
|
|
3136
|
+
this.kind = 'time_truncation';
|
|
3137
|
+
}
|
|
3138
|
+
get name() {
|
|
3139
|
+
return undefined;
|
|
3140
|
+
}
|
|
3141
|
+
get literalValue() {
|
|
3142
|
+
return this.children.literal_value;
|
|
3143
|
+
}
|
|
3144
|
+
get fieldType() {
|
|
3145
|
+
return this.literalValue.fieldType;
|
|
3146
|
+
}
|
|
3147
|
+
getInheritedAnnotations() {
|
|
3148
|
+
return [];
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
exports.ASTLiteralValueExpression = ASTLiteralValueExpression;
|
|
3063
3152
|
class ASTFilterOperation extends ASTObjectNode {
|
|
3064
3153
|
constructor(node) {
|
|
3065
3154
|
super(node, {
|
|
@@ -3306,6 +3395,29 @@ class ASTWhereViewOperation extends ASTObjectNode {
|
|
|
3306
3395
|
}
|
|
3307
3396
|
}
|
|
3308
3397
|
exports.ASTWhereViewOperation = ASTWhereViewOperation;
|
|
3398
|
+
class ASTDrillViewOperation extends ASTObjectNode {
|
|
3399
|
+
constructor(node) {
|
|
3400
|
+
super(node, {
|
|
3401
|
+
kind: 'drill',
|
|
3402
|
+
filter: exports.ASTFilter.from(node.filter),
|
|
3403
|
+
});
|
|
3404
|
+
this.node = node;
|
|
3405
|
+
this.kind = 'drill';
|
|
3406
|
+
}
|
|
3407
|
+
get filter() {
|
|
3408
|
+
return this.children.filter;
|
|
3409
|
+
}
|
|
3410
|
+
/**
|
|
3411
|
+
* @internal
|
|
3412
|
+
*/
|
|
3413
|
+
get list() {
|
|
3414
|
+
return this.parent.as.ViewOperationList();
|
|
3415
|
+
}
|
|
3416
|
+
delete() {
|
|
3417
|
+
this.list.remove(this);
|
|
3418
|
+
}
|
|
3419
|
+
}
|
|
3420
|
+
exports.ASTDrillViewOperation = ASTDrillViewOperation;
|
|
3309
3421
|
class ASTHavingViewOperation extends ASTObjectNode {
|
|
3310
3422
|
constructor(node) {
|
|
3311
3423
|
super(node, {
|
|
@@ -3331,7 +3443,12 @@ class ASTHavingViewOperation extends ASTObjectNode {
|
|
|
3331
3443
|
exports.ASTHavingViewOperation = ASTHavingViewOperation;
|
|
3332
3444
|
exports.ASTFilter = {
|
|
3333
3445
|
from(filter) {
|
|
3334
|
-
|
|
3446
|
+
switch (filter.kind) {
|
|
3447
|
+
case 'filter_string':
|
|
3448
|
+
return new ASTFilterWithFilterString(filter);
|
|
3449
|
+
case 'literal_equality':
|
|
3450
|
+
return new ASTFilterWithLiteralEquality(filter);
|
|
3451
|
+
}
|
|
3335
3452
|
},
|
|
3336
3453
|
};
|
|
3337
3454
|
class ASTFilterWithFilterString extends ASTObjectNode {
|
|
@@ -3383,6 +3500,24 @@ class ASTFilterWithFilterString extends ASTObjectNode {
|
|
|
3383
3500
|
}
|
|
3384
3501
|
}
|
|
3385
3502
|
exports.ASTFilterWithFilterString = ASTFilterWithFilterString;
|
|
3503
|
+
class ASTFilterWithLiteralEquality extends ASTObjectNode {
|
|
3504
|
+
constructor(node) {
|
|
3505
|
+
super(node, {
|
|
3506
|
+
kind: 'literal_equality',
|
|
3507
|
+
field_reference: new ASTFieldReference(node.field_reference),
|
|
3508
|
+
value: exports.ASTLiteralValue.from(node.value),
|
|
3509
|
+
});
|
|
3510
|
+
this.node = node;
|
|
3511
|
+
this.kind = 'literal_equality';
|
|
3512
|
+
}
|
|
3513
|
+
get fieldReference() {
|
|
3514
|
+
return this.children.field_reference;
|
|
3515
|
+
}
|
|
3516
|
+
get value() {
|
|
3517
|
+
return this.children.value;
|
|
3518
|
+
}
|
|
3519
|
+
}
|
|
3520
|
+
exports.ASTFilterWithLiteralEquality = ASTFilterWithLiteralEquality;
|
|
3386
3521
|
class ASTView extends ASTObjectNode {
|
|
3387
3522
|
constructor(node) {
|
|
3388
3523
|
super(node, {
|