@malloydata/malloy 0.0.1 → 0.0.2
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/dialect/dialect.d.ts +1 -1
- package/dist/dialect/dialect.js +13 -0
- package/dist/lang/ast/apply-expr.d.ts +2 -2
- package/dist/lang/ast/apply-expr.js +19 -3
- package/dist/lang/ast/ast-expr.d.ts +37 -37
- package/dist/lang/ast/ast-expr.js +22 -27
- package/dist/lang/ast/ast-main.d.ts +12 -12
- package/dist/lang/ast/ast-main.js +34 -44
- package/dist/lang/ast/ast-time-expr.d.ts +19 -19
- package/dist/lang/ast/ast-time-expr.js +6 -7
- package/dist/lang/ast/time-utils.d.ts +1 -0
- package/dist/lang/ast/time-utils.js +12 -1
- package/dist/lang/field-space.d.ts +37 -37
- package/dist/lang/field-space.js +108 -130
- package/dist/lang/space-field.d.ts +10 -7
- package/dist/lang/space-field.js +11 -4
- package/dist/lang/test/parse.spec.js +1 -1
- package/dist/model/malloy_query.js +6 -0
- package/dist/model/malloy_types.d.ts +12 -1
- package/package.json +2 -1
|
@@ -512,7 +512,7 @@ class RefinedExplore extends Mallobj {
|
|
|
512
512
|
fs.addParameters(pList);
|
|
513
513
|
}
|
|
514
514
|
if (primaryKey) {
|
|
515
|
-
const keyDef = primaryKey.field.getField(
|
|
515
|
+
const keyDef = primaryKey.field.getField(fs);
|
|
516
516
|
if (keyDef.error) {
|
|
517
517
|
primaryKey.log(keyDef.error);
|
|
518
518
|
}
|
|
@@ -522,7 +522,7 @@ class RefinedExplore extends Mallobj {
|
|
|
522
522
|
let moreFilters = false;
|
|
523
523
|
for (const filter of filters) {
|
|
524
524
|
for (const el of filter.list) {
|
|
525
|
-
const fc = el.filterExpression(
|
|
525
|
+
const fc = el.filterExpression(fs);
|
|
526
526
|
if (fc.aggregate) {
|
|
527
527
|
el.log("Can't use aggregate computations in top level filters");
|
|
528
528
|
}
|
|
@@ -1017,7 +1017,7 @@ class FieldName extends MalloyElement {
|
|
|
1017
1017
|
return this.refString;
|
|
1018
1018
|
}
|
|
1019
1019
|
getField(fs) {
|
|
1020
|
-
return fs.
|
|
1020
|
+
return fs.lookup([this]);
|
|
1021
1021
|
}
|
|
1022
1022
|
}
|
|
1023
1023
|
exports.FieldName = FieldName;
|
|
@@ -1100,28 +1100,25 @@ class Aggregate extends ListOf {
|
|
|
1100
1100
|
}
|
|
1101
1101
|
exports.Aggregate = Aggregate;
|
|
1102
1102
|
class ReduceExecutor {
|
|
1103
|
-
constructor(baseFS
|
|
1103
|
+
constructor(baseFS) {
|
|
1104
1104
|
this.filters = [];
|
|
1105
|
-
this.
|
|
1106
|
-
this.
|
|
1105
|
+
this.resultFS = this.getResultSpace(baseFS);
|
|
1106
|
+
this.inputFS = this.resultFS.exprSpace;
|
|
1107
1107
|
}
|
|
1108
|
-
|
|
1109
|
-
return
|
|
1110
|
-
in: this.queryFS.inputFS(),
|
|
1111
|
-
out: this.queryFS,
|
|
1112
|
-
};
|
|
1108
|
+
getResultSpace(fs) {
|
|
1109
|
+
return new field_space_1.ReduceFieldSpace(fs);
|
|
1113
1110
|
}
|
|
1114
1111
|
execute(qp) {
|
|
1115
1112
|
if (qp instanceof GroupBy ||
|
|
1116
1113
|
qp instanceof Aggregate ||
|
|
1117
1114
|
qp instanceof Nests) {
|
|
1118
|
-
this.
|
|
1115
|
+
this.resultFS.addQueryItems(...qp.list);
|
|
1119
1116
|
}
|
|
1120
1117
|
else if (isNestedQuery(qp)) {
|
|
1121
|
-
this.
|
|
1118
|
+
this.resultFS.addQueryItems(qp);
|
|
1122
1119
|
}
|
|
1123
1120
|
else if (qp instanceof Filter) {
|
|
1124
|
-
this.filters.push(...qp.getFilterList(this.
|
|
1121
|
+
this.filters.push(...qp.getFilterList(this.inputFS));
|
|
1125
1122
|
}
|
|
1126
1123
|
else if (qp instanceof Top) {
|
|
1127
1124
|
if (this.limit) {
|
|
@@ -1157,7 +1154,7 @@ class ReduceExecutor {
|
|
|
1157
1154
|
}
|
|
1158
1155
|
else if (qp instanceof Joins || qp instanceof DeclareFields) {
|
|
1159
1156
|
for (const qel of qp.list) {
|
|
1160
|
-
this.
|
|
1157
|
+
this.inputFS.extendSource(qel);
|
|
1161
1158
|
}
|
|
1162
1159
|
}
|
|
1163
1160
|
}
|
|
@@ -1179,13 +1176,13 @@ class ReduceExecutor {
|
|
|
1179
1176
|
to.limit = this.limit;
|
|
1180
1177
|
}
|
|
1181
1178
|
if (this.order instanceof Top) {
|
|
1182
|
-
const topBy = this.order.getBy(this.
|
|
1179
|
+
const topBy = this.order.getBy(this.inputFS);
|
|
1183
1180
|
if (topBy) {
|
|
1184
1181
|
to.by = topBy;
|
|
1185
1182
|
}
|
|
1186
1183
|
}
|
|
1187
1184
|
if (this.order instanceof Ordering) {
|
|
1188
|
-
to.orderBy = this.order.getOrderBy(this.
|
|
1185
|
+
to.orderBy = this.order.getOrderBy(this.inputFS);
|
|
1189
1186
|
}
|
|
1190
1187
|
const oldFilters = (from === null || from === void 0 ? void 0 : from.filterList) || [];
|
|
1191
1188
|
if (this.filters.length > 0 && !oldFilters) {
|
|
@@ -1202,22 +1199,22 @@ class ReduceExecutor {
|
|
|
1202
1199
|
from = fromSeg;
|
|
1203
1200
|
}
|
|
1204
1201
|
else {
|
|
1205
|
-
this.
|
|
1202
|
+
this.inputFS.result.log(`Can't refine reduce with ${fromSeg.type}`);
|
|
1206
1203
|
return ErrorFactory.reduceSegment;
|
|
1207
1204
|
}
|
|
1208
1205
|
}
|
|
1209
|
-
const reduceSegment = this.
|
|
1206
|
+
const reduceSegment = this.resultFS.getQuerySegment(from);
|
|
1210
1207
|
this.refineFrom(from, reduceSegment);
|
|
1211
1208
|
return reduceSegment;
|
|
1212
1209
|
}
|
|
1213
1210
|
}
|
|
1214
1211
|
class ProjectExecutor extends ReduceExecutor {
|
|
1215
|
-
|
|
1216
|
-
|
|
1212
|
+
getResultSpace(fs) {
|
|
1213
|
+
return new field_space_1.ProjectFieldSpace(fs);
|
|
1217
1214
|
}
|
|
1218
1215
|
execute(qp) {
|
|
1219
1216
|
if (qp instanceof ProjectStatement) {
|
|
1220
|
-
this.
|
|
1217
|
+
this.resultFS.addMembers(qp.list);
|
|
1221
1218
|
}
|
|
1222
1219
|
else if ((qp instanceof Filter && qp.elementType === "having") ||
|
|
1223
1220
|
qp instanceof Measures ||
|
|
@@ -1235,30 +1232,24 @@ class ProjectExecutor extends ReduceExecutor {
|
|
|
1235
1232
|
from = fromSeg;
|
|
1236
1233
|
}
|
|
1237
1234
|
else {
|
|
1238
|
-
this.
|
|
1235
|
+
this.resultFS.log(`Can't refine project with ${fromSeg.type}`);
|
|
1239
1236
|
return ErrorFactory.projectSegment;
|
|
1240
1237
|
}
|
|
1241
1238
|
}
|
|
1242
|
-
const projectSegment = this.
|
|
1239
|
+
const projectSegment = this.resultFS.getQuerySegment(from);
|
|
1243
1240
|
this.refineFrom(from, projectSegment);
|
|
1244
1241
|
return projectSegment;
|
|
1245
1242
|
}
|
|
1246
1243
|
}
|
|
1247
1244
|
class IndexExecutor {
|
|
1248
|
-
constructor(
|
|
1245
|
+
constructor(inputFS) {
|
|
1249
1246
|
this.filters = [];
|
|
1250
|
-
this.
|
|
1251
|
-
this.
|
|
1252
|
-
}
|
|
1253
|
-
get qfs() {
|
|
1254
|
-
return {
|
|
1255
|
-
in: this.queryFS.inputFS(),
|
|
1256
|
-
out: this.queryFS,
|
|
1257
|
-
};
|
|
1247
|
+
this.resultFS = new field_space_1.IndexFieldSpace(inputFS);
|
|
1248
|
+
this.inputFS = this.resultFS.exprSpace;
|
|
1258
1249
|
}
|
|
1259
1250
|
execute(qp) {
|
|
1260
1251
|
if (qp instanceof Filter) {
|
|
1261
|
-
this.filters.push(...qp.getFilterList(this.
|
|
1252
|
+
this.filters.push(...qp.getFilterList(this.inputFS));
|
|
1262
1253
|
}
|
|
1263
1254
|
else if (qp instanceof Limit) {
|
|
1264
1255
|
if (this.limit) {
|
|
@@ -1267,7 +1258,7 @@ class IndexExecutor {
|
|
|
1267
1258
|
this.limit = qp;
|
|
1268
1259
|
}
|
|
1269
1260
|
else if (qp instanceof Index) {
|
|
1270
|
-
this.
|
|
1261
|
+
this.resultFS.addMembers(qp.fields.list);
|
|
1271
1262
|
if (qp.weightBy) {
|
|
1272
1263
|
if (this.indexOn) {
|
|
1273
1264
|
this.indexOn.log("Ignoring previous BY");
|
|
@@ -1284,10 +1275,10 @@ class IndexExecutor {
|
|
|
1284
1275
|
}
|
|
1285
1276
|
finalize(from) {
|
|
1286
1277
|
if (from && from.type !== "index") {
|
|
1287
|
-
this.
|
|
1278
|
+
this.resultFS.log(`Can't refine index with ${from.type}`);
|
|
1288
1279
|
return ErrorFactory.indexSegment;
|
|
1289
1280
|
}
|
|
1290
|
-
const indexSegment = this.
|
|
1281
|
+
const indexSegment = this.resultFS.getPipeSegment(from);
|
|
1291
1282
|
const oldFilters = (from === null || from === void 0 ? void 0 : from.filterList) || [];
|
|
1292
1283
|
if (this.filters.length > 0 && !oldFilters) {
|
|
1293
1284
|
indexSegment.filterList = this.filters;
|
|
@@ -1385,9 +1376,9 @@ class QOPDesc extends ListOf {
|
|
|
1385
1376
|
getOp(inputFS, forPipeline) {
|
|
1386
1377
|
const qex = this.getExecutor(inputFS);
|
|
1387
1378
|
if (forPipeline === null || forPipeline === void 0 ? void 0 : forPipeline.nestedInQuerySpace) {
|
|
1388
|
-
qex.
|
|
1379
|
+
qex.inputFS.nestParent = forPipeline.nestedInQuerySpace;
|
|
1389
1380
|
}
|
|
1390
|
-
qex.
|
|
1381
|
+
qex.resultFS.astEl = this;
|
|
1391
1382
|
for (const qp of this.list) {
|
|
1392
1383
|
qex.execute(qp);
|
|
1393
1384
|
}
|
|
@@ -1724,7 +1715,7 @@ class FullQuery extends TurtleHeadedPipe {
|
|
|
1724
1715
|
};
|
|
1725
1716
|
}
|
|
1726
1717
|
if (this.turtleName) {
|
|
1727
|
-
const { error } = this.turtleName.getField(
|
|
1718
|
+
const { error } = this.turtleName.getField(pipeFs);
|
|
1728
1719
|
if (error)
|
|
1729
1720
|
this.log(error);
|
|
1730
1721
|
const name = this.turtleName.refString;
|
|
@@ -1769,7 +1760,7 @@ class TurtleDecl extends TurtleHeadedPipe {
|
|
|
1769
1760
|
else if (headEnt.found instanceof space_field_1.QueryField) {
|
|
1770
1761
|
const headDef = headEnt.found.getQueryFieldDef(fs);
|
|
1771
1762
|
if (isTurtle(headDef)) {
|
|
1772
|
-
const newPipe = this.refinePipeline(fs
|
|
1763
|
+
const newPipe = this.refinePipeline(fs, headDef);
|
|
1773
1764
|
modelPipe.pipeline = [...newPipe.pipeline];
|
|
1774
1765
|
reportWrongType = false;
|
|
1775
1766
|
}
|
|
@@ -1781,7 +1772,7 @@ class TurtleDecl extends TurtleHeadedPipe {
|
|
|
1781
1772
|
else if (this.headRefinement) {
|
|
1782
1773
|
throw this.internalError("Can't refine the head of a turtle in its definition");
|
|
1783
1774
|
}
|
|
1784
|
-
let appendInput = fs
|
|
1775
|
+
let appendInput = fs;
|
|
1785
1776
|
if (modelPipe.pipeline.length > 0) {
|
|
1786
1777
|
let endStruct = appendInput.structDef();
|
|
1787
1778
|
for (const existingSeg of modelPipe.pipeline) {
|
|
@@ -1793,8 +1784,7 @@ class TurtleDecl extends TurtleHeadedPipe {
|
|
|
1793
1784
|
modelPipe.pipeline = appended.opList;
|
|
1794
1785
|
return modelPipe;
|
|
1795
1786
|
}
|
|
1796
|
-
getFieldDef(
|
|
1797
|
-
const fs = (0, field_space_1.fsPair)(inSpace);
|
|
1787
|
+
getFieldDef(fs, nestParent) {
|
|
1798
1788
|
if (nestParent) {
|
|
1799
1789
|
this.nestedInQuerySpace = nestParent;
|
|
1800
1790
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TimestampUnit, ExtractUnit, TimeFieldType } from "../../model/malloy_types";
|
|
2
|
-
import {
|
|
2
|
+
import { FieldSpace } from "../field-space";
|
|
3
3
|
import { ExpressionDef, BinaryBoolean, ExprValue, MalloyElement, Comparison } from "./index";
|
|
4
4
|
export declare class Timeframe extends MalloyElement {
|
|
5
5
|
elementType: string;
|
|
@@ -21,10 +21,10 @@ export declare class ExprGranularTime extends ExpressionDef {
|
|
|
21
21
|
legalChildTypes: import("./ast-types").FragType[];
|
|
22
22
|
constructor(expr: ExpressionDef, units: TimestampUnit, truncate: boolean);
|
|
23
23
|
granular(): boolean;
|
|
24
|
-
getExpression(fs:
|
|
25
|
-
apply(fs:
|
|
26
|
-
protected timestampRange(fs:
|
|
27
|
-
protected dateRange(fs:
|
|
24
|
+
getExpression(fs: FieldSpace): ExprValue;
|
|
25
|
+
apply(fs: FieldSpace, op: string, left: ExpressionDef): ExprValue;
|
|
26
|
+
protected timestampRange(fs: FieldSpace, op: string, expr: ExpressionDef): ExprValue;
|
|
27
|
+
protected dateRange(fs: FieldSpace, op: string, expr: ExpressionDef): ExprValue;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* GranularTime made from a literal. Funky because it doesn't know if it
|
|
@@ -39,12 +39,12 @@ export declare class GranularLiteral extends ExpressionDef {
|
|
|
39
39
|
constructor(moment: string, until: string, units: TimestampUnit);
|
|
40
40
|
granular(): boolean;
|
|
41
41
|
static parse(possibleLiteral: string): GranularLiteral | undefined;
|
|
42
|
-
apply(fs:
|
|
43
|
-
getExpression(
|
|
42
|
+
apply(fs: FieldSpace, op: string, left: ExpressionDef): ExprValue;
|
|
43
|
+
getExpression(_fs: FieldSpace): ExprValue;
|
|
44
44
|
}
|
|
45
45
|
export declare class ExprNow extends ExpressionDef {
|
|
46
46
|
elementType: string;
|
|
47
|
-
getExpression(_fs:
|
|
47
|
+
getExpression(_fs: FieldSpace): ExprValue;
|
|
48
48
|
}
|
|
49
49
|
export declare class ExprDuration extends ExpressionDef {
|
|
50
50
|
readonly n: ExpressionDef;
|
|
@@ -52,13 +52,13 @@ export declare class ExprDuration extends ExpressionDef {
|
|
|
52
52
|
elementType: string;
|
|
53
53
|
legalChildTypes: import("./ast-types").FragType[];
|
|
54
54
|
constructor(n: ExpressionDef, timeframe: TimestampUnit);
|
|
55
|
-
apply(fs:
|
|
56
|
-
getExpression(_fs:
|
|
55
|
+
apply(fs: FieldSpace, op: string, left: ExpressionDef): ExprValue;
|
|
56
|
+
getExpression(_fs: FieldSpace): ExprValue;
|
|
57
57
|
}
|
|
58
58
|
export declare class ExprCompare extends BinaryBoolean<Comparison> {
|
|
59
59
|
elementType: string;
|
|
60
60
|
constructor(left: ExpressionDef, op: Comparison, right: ExpressionDef);
|
|
61
|
-
getExpression(fs:
|
|
61
|
+
getExpression(fs: FieldSpace): ExprValue;
|
|
62
62
|
}
|
|
63
63
|
export declare class Apply extends ExprCompare {
|
|
64
64
|
readonly left: ExpressionDef;
|
|
@@ -72,9 +72,9 @@ export declare class PartialCompare extends ExpressionDef {
|
|
|
72
72
|
elementType: string;
|
|
73
73
|
constructor(op: Comparison, right: ExpressionDef);
|
|
74
74
|
granular(): boolean;
|
|
75
|
-
apply(fs:
|
|
76
|
-
requestExpression(_fs:
|
|
77
|
-
getExpression(_fs:
|
|
75
|
+
apply(fs: FieldSpace, op: string, expr: ExpressionDef): ExprValue;
|
|
76
|
+
requestExpression(_fs: FieldSpace): ExprValue | undefined;
|
|
77
|
+
getExpression(_fs: FieldSpace): ExprValue;
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* TODO: This is sort of a hand clone of the "Range" class, they should
|
|
@@ -87,9 +87,9 @@ export declare class ForRange extends ExpressionDef {
|
|
|
87
87
|
elementType: string;
|
|
88
88
|
legalChildTypes: import("./ast-types").FragType[];
|
|
89
89
|
constructor(from: ExpressionDef, duration: ExpressionDef, timeframe: Timeframe);
|
|
90
|
-
apply(fs:
|
|
91
|
-
requestExpression(_fs:
|
|
92
|
-
getExpression(_fs:
|
|
90
|
+
apply(fs: FieldSpace, op: string, expr: ExpressionDef): ExprValue;
|
|
91
|
+
requestExpression(_fs: FieldSpace): ExprValue | undefined;
|
|
92
|
+
getExpression(_fs: FieldSpace): ExprValue;
|
|
93
93
|
}
|
|
94
94
|
export declare class ExprTimeExtract extends ExpressionDef {
|
|
95
95
|
readonly extractText: string;
|
|
@@ -98,12 +98,12 @@ export declare class ExprTimeExtract extends ExpressionDef {
|
|
|
98
98
|
static pluralMap: Record<string, ExtractUnit>;
|
|
99
99
|
static extractor(funcName: string): ExtractUnit | undefined;
|
|
100
100
|
constructor(extractText: string, args: ExpressionDef[]);
|
|
101
|
-
getExpression(fs:
|
|
101
|
+
getExpression(fs: FieldSpace): ExprValue;
|
|
102
102
|
}
|
|
103
103
|
export declare class ExprFunc extends ExpressionDef {
|
|
104
104
|
readonly name: string;
|
|
105
105
|
readonly args: ExpressionDef[];
|
|
106
106
|
elementType: string;
|
|
107
107
|
constructor(name: string, args: ExpressionDef[]);
|
|
108
|
-
getExpression(fs:
|
|
108
|
+
getExpression(fs: FieldSpace): ExprValue;
|
|
109
109
|
}
|
|
@@ -197,18 +197,17 @@ class GranularLiteral extends index_1.ExpressionDef {
|
|
|
197
197
|
if (lhs.dataType === "date" && !this.timeType) {
|
|
198
198
|
rangeType = "date";
|
|
199
199
|
}
|
|
200
|
-
const
|
|
201
|
-
const range = new index_1.Range(new index_1.ExprTime(rangeType, dialect.sqlLiteralTime(this.moment, rangeType, "UTC")), new index_1.ExprTime(rangeType, dialect.sqlLiteralTime(this.until, rangeType, "UTC")));
|
|
200
|
+
const range = new index_1.Range(new index_1.ExprTime(rangeType, (0, index_1.timeLiteral)(this.moment, rangeType, "UTC")), new index_1.ExprTime(rangeType, (0, index_1.timeLiteral)(this.until, rangeType, "UTC")));
|
|
202
201
|
return range.apply(fs, op, left);
|
|
203
202
|
}
|
|
204
203
|
return super.apply(fs, op, left);
|
|
205
204
|
}
|
|
206
|
-
getExpression(
|
|
205
|
+
getExpression(_fs) {
|
|
207
206
|
const dataType = this.timeType || "date";
|
|
208
207
|
const value = {
|
|
209
208
|
dataType,
|
|
210
209
|
aggregate: false,
|
|
211
|
-
value:
|
|
210
|
+
value: (0, index_1.timeLiteral)(this.moment, dataType, "UTC"),
|
|
212
211
|
};
|
|
213
212
|
// Literals with date resolution can be used as timestamps or dates,
|
|
214
213
|
// this is the third attempt to make that work. It still feels like
|
|
@@ -519,7 +518,7 @@ class ExprFunc extends index_1.ExpressionDef {
|
|
|
519
518
|
this.elementType = "function call()";
|
|
520
519
|
}
|
|
521
520
|
getExpression(fs) {
|
|
522
|
-
var _a, _b;
|
|
521
|
+
var _a, _b, _c;
|
|
523
522
|
let anyAggregate = false;
|
|
524
523
|
let collectType;
|
|
525
524
|
const funcCall = [`${this.name}(`];
|
|
@@ -537,8 +536,8 @@ class ExprFunc extends index_1.ExpressionDef {
|
|
|
537
536
|
funcCall.push(...expr.value);
|
|
538
537
|
}
|
|
539
538
|
funcCall.push(")");
|
|
540
|
-
const
|
|
541
|
-
const dataType = (_b = (_a =
|
|
539
|
+
const dialect = fs.dialectObj();
|
|
540
|
+
const dataType = (_c = (_b = (_a = dialect === null || dialect === void 0 ? void 0 : dialect.getFunctionInfo(this.name)) === null || _a === void 0 ? void 0 : _a.returnType) !== null && _b !== void 0 ? _b : collectType) !== null && _c !== void 0 ? _c : "number";
|
|
542
541
|
return {
|
|
543
542
|
dataType: dataType,
|
|
544
543
|
aggregate: anyAggregate,
|
|
@@ -6,3 +6,4 @@ export declare function castTimestampToDate(from: Expr, safe?: boolean): Expr;
|
|
|
6
6
|
export declare function castDateToTimestamp(from: Expr, safe?: boolean): Expr;
|
|
7
7
|
export declare function resolution(timeframe: string): TimeFieldType;
|
|
8
8
|
export declare function timeResult(t: TimeResult, tt: TimestampUnit | undefined): TimeResult | GranularResult;
|
|
9
|
+
export declare function timeLiteral(literalStr: string, timeType: TimeFieldType, tz: string): Expr;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* GNU General Public License for more details.
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.timeResult = exports.resolution = exports.castDateToTimestamp = exports.castTimestampToDate = exports.castTo = exports.timeOffset = void 0;
|
|
15
|
+
exports.timeLiteral = exports.timeResult = exports.resolution = exports.castDateToTimestamp = exports.castTimestampToDate = exports.castTo = exports.timeOffset = void 0;
|
|
16
16
|
function timeOffset(timeType, from, op, n, timeframe) {
|
|
17
17
|
return [
|
|
18
18
|
{
|
|
@@ -80,4 +80,15 @@ function timeResult(t, tt) {
|
|
|
80
80
|
return t;
|
|
81
81
|
}
|
|
82
82
|
exports.timeResult = timeResult;
|
|
83
|
+
function timeLiteral(literalStr, timeType, tz) {
|
|
84
|
+
const fragment = {
|
|
85
|
+
type: "dialect",
|
|
86
|
+
function: "timeLiteral",
|
|
87
|
+
literal: literalStr,
|
|
88
|
+
literalType: timeType,
|
|
89
|
+
timezone: tz,
|
|
90
|
+
};
|
|
91
|
+
return [fragment];
|
|
92
|
+
}
|
|
93
|
+
exports.timeLiteral = timeLiteral;
|
|
83
94
|
//# sourceMappingURL=time-utils.js.map
|
|
@@ -20,7 +20,7 @@ export interface FieldSpace {
|
|
|
20
20
|
structDef(): model.StructDef;
|
|
21
21
|
emptyStructDef(): model.StructDef;
|
|
22
22
|
lookup(symbol: FieldName[]): LookupResult;
|
|
23
|
-
|
|
23
|
+
dialectObj(): Dialect | undefined;
|
|
24
24
|
whenComplete: (step: () => void) => void;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
@@ -32,7 +32,7 @@ export declare class StaticSpace implements FieldSpace {
|
|
|
32
32
|
protected fromStruct: model.StructDef;
|
|
33
33
|
constructor(sourceStructDef: model.StructDef);
|
|
34
34
|
whenComplete(step: () => void): void;
|
|
35
|
-
|
|
35
|
+
dialectObj(): Dialect | undefined;
|
|
36
36
|
fromFieldDef(from: model.FieldDef): SpaceField;
|
|
37
37
|
private get map();
|
|
38
38
|
protected dropEntries(): void;
|
|
@@ -85,50 +85,55 @@ export declare class DynamicSpace extends StaticSpace {
|
|
|
85
85
|
addFieldDef(fd: model.FieldDef): void;
|
|
86
86
|
structDef(): model.StructDef;
|
|
87
87
|
}
|
|
88
|
-
declare type QuerySegType = "reduce" | "project" | "index";
|
|
89
88
|
/**
|
|
90
89
|
* A namespace for Query operations. The have an input and an
|
|
91
|
-
* output set of fields.
|
|
90
|
+
* output set of fields. The InputSpace is the QueryOperationSpace
|
|
91
|
+
* which is where all expressions are evaluated, and the output
|
|
92
|
+
* space is ResultSpace.
|
|
93
|
+
*
|
|
92
94
|
*/
|
|
93
|
-
export declare
|
|
94
|
-
|
|
95
|
-
astEl?: MalloyElement | undefined;
|
|
96
|
-
readonly queryInput: SourceSpace;
|
|
95
|
+
export declare class QuerySpace extends DynamicSpace {
|
|
96
|
+
readonly result: ResultSpace;
|
|
97
97
|
nestParent?: QuerySpace;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
extendList: string[];
|
|
99
|
+
constructor(input: SourceSpec, result: ResultSpace);
|
|
100
|
+
extendSource(extendField: Join | FieldDeclaration): void;
|
|
101
|
+
}
|
|
102
|
+
export declare abstract class ResultSpace extends DynamicSpace {
|
|
103
|
+
readonly queryInputSpace: FieldSpace;
|
|
104
|
+
readonly exprSpace: QuerySpace;
|
|
105
|
+
astEl?: MalloyElement | undefined;
|
|
106
|
+
abstract readonly segmentType: "reduce" | "project" | "index";
|
|
107
|
+
constructor(queryInputSpace: FieldSpace);
|
|
108
|
+
log(s: string): void;
|
|
102
109
|
addMembers(members: FieldCollectionMember[]): void;
|
|
103
110
|
addReference(ref: FieldReference): void;
|
|
104
111
|
addWild(wild: WildcardFieldReference): void;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
extendedInput?: DynamicSpace;
|
|
112
|
-
extendedFields: string[];
|
|
113
|
-
extendSource(extendField: Join | FieldDeclaration): void;
|
|
114
|
-
inputFS(): FieldSpace;
|
|
115
|
-
qfs(): FSPair;
|
|
112
|
+
/**
|
|
113
|
+
* Check for the definition of an ungrouping reference in the result space,
|
|
114
|
+
* or in the case of an exclude reference, if this query is nested
|
|
115
|
+
* in another query, in the result space of a query that this query
|
|
116
|
+
* is nested inside of.
|
|
117
|
+
*/
|
|
116
118
|
checkUngroup(fn: FieldName, isExclude: boolean): void;
|
|
117
|
-
private extendInto;
|
|
118
|
-
getPipeSegment(refineFrom: model.QuerySegment | undefined): model.QuerySegment;
|
|
119
119
|
addQueryItems(...qiList: QueryItem[]): void;
|
|
120
120
|
canContain(_qd: model.QueryFieldDef): boolean;
|
|
121
121
|
protected queryFieldDefs(): model.QueryFieldDef[];
|
|
122
|
+
getQuerySegment(rf: model.QuerySegment | undefined): model.QuerySegment;
|
|
123
|
+
getPipeSegment(refineFrom: model.QuerySegment | undefined): model.PipeSegment;
|
|
122
124
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Reduce and project queries use a "QuerySpace"
|
|
127
|
+
*/
|
|
128
|
+
export declare class ReduceFieldSpace extends ResultSpace {
|
|
129
|
+
readonly segmentType = "reduce";
|
|
125
130
|
}
|
|
126
|
-
export declare class ProjectFieldSpace extends
|
|
127
|
-
|
|
131
|
+
export declare class ProjectFieldSpace extends ResultSpace {
|
|
132
|
+
readonly segmentType = "project";
|
|
128
133
|
canContain(qd: model.QueryFieldDef): boolean;
|
|
129
134
|
}
|
|
130
|
-
export declare class IndexFieldSpace extends
|
|
131
|
-
|
|
135
|
+
export declare class IndexFieldSpace extends ResultSpace {
|
|
136
|
+
readonly segmentType = "index";
|
|
132
137
|
fieldList: Set<string>;
|
|
133
138
|
addReference(ref: FieldReference): void;
|
|
134
139
|
addWild(wild: WildcardFieldReference): void;
|
|
@@ -146,12 +151,7 @@ export declare class DefSpace implements FieldSpace {
|
|
|
146
151
|
structDef(): model.StructDef;
|
|
147
152
|
emptyStructDef(): model.StructDef;
|
|
148
153
|
lookup(symbol: FieldName[]): LookupResult;
|
|
149
|
-
|
|
154
|
+
dialectObj(): Dialect | undefined;
|
|
150
155
|
whenComplete(step: () => void): void;
|
|
151
156
|
}
|
|
152
|
-
export interface FSPair {
|
|
153
|
-
in: FieldSpace;
|
|
154
|
-
out: FieldSpace;
|
|
155
|
-
}
|
|
156
|
-
export declare function fsPair(inFS: FieldSpace, outFS?: FieldSpace): FSPair;
|
|
157
157
|
export {};
|