@malloydata/malloy 0.0.279 → 0.0.280
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/annotation.js +3 -4
- package/dist/api/asynchronous.js +21 -12
- package/dist/api/core.js +29 -20
- package/dist/api/index.js +17 -7
- package/dist/api/sessioned.js +20 -11
- package/dist/api/stateless.js +20 -11
- package/dist/api/util.js +6 -6
- package/dist/connection_utils.js +1 -2
- package/dist/dialect/dialect.js +3 -3
- package/dist/dialect/dialect_map.js +3 -4
- package/dist/dialect/functions/malloy_standard_functions.d.ts +1 -0
- package/dist/dialect/functions/malloy_standard_functions.js +9 -3
- package/dist/dialect/functions/util.d.ts +1 -1
- package/dist/dialect/functions/util.js +21 -22
- package/dist/dialect/trino/dialect_functions.js +18 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -8
- package/dist/lang/ast/ast-utils.js +1 -2
- package/dist/lang/ast/expressions/binary-boolean.js +17 -7
- package/dist/lang/ast/expressions/binary-numeric.js +17 -7
- package/dist/lang/ast/expressions/boolean.js +17 -7
- package/dist/lang/ast/expressions/case.js +17 -7
- package/dist/lang/ast/expressions/expr-aggregate-function.js +17 -7
- package/dist/lang/ast/expressions/expr-array-literal.js +17 -7
- package/dist/lang/ast/expressions/expr-coalesce.js +17 -7
- package/dist/lang/ast/expressions/expr-compare.js +17 -7
- package/dist/lang/ast/expressions/expr-count-distinct.js +17 -7
- package/dist/lang/ast/expressions/expr-func.js +17 -7
- package/dist/lang/ast/expressions/expr-granular-time.js +17 -7
- package/dist/lang/ast/expressions/expr-logical-op.js +17 -7
- package/dist/lang/ast/expressions/expr-max.js +17 -7
- package/dist/lang/ast/expressions/expr-min.js +17 -7
- package/dist/lang/ast/expressions/expr-minus.js +17 -7
- package/dist/lang/ast/expressions/expr-not.js +17 -7
- package/dist/lang/ast/expressions/expr-props.d.ts +36 -36
- package/dist/lang/ast/expressions/expr-props.js +17 -7
- package/dist/lang/ast/expressions/expr-record-literal.js +17 -7
- package/dist/lang/ast/expressions/expr-ungroup.js +17 -7
- package/dist/lang/ast/expressions/for-range.js +17 -7
- package/dist/lang/ast/expressions/pick-when.js +17 -7
- package/dist/lang/ast/field-space/dynamic-space.js +17 -7
- package/dist/lang/ast/field-space/include-utils.js +2 -3
- package/dist/lang/ast/field-space/query-spaces.js +17 -7
- package/dist/lang/ast/field-space/reference-field.js +17 -7
- package/dist/lang/ast/field-space/struct-space-field-base.js +17 -7
- package/dist/lang/ast/field-space/view-field.d.ts +31 -31
- package/dist/lang/ast/field-space/view-field.js +17 -7
- package/dist/lang/ast/query-items/field-declaration.js +17 -7
- package/dist/lang/ast/query-items/typecheck_utils.js +8 -9
- package/dist/lang/ast/query-properties/nest.js +17 -7
- package/dist/lang/ast/query-utils.js +3 -4
- package/dist/lang/ast/struct-utils.js +3 -4
- package/dist/lang/ast/time-utils.js +4 -5
- package/dist/lang/ast/typedesc-utils.js +7 -7
- package/dist/lang/ast/types/binary_operators.js +3 -4
- package/dist/lang/ast/types/expr-value.js +7 -8
- package/dist/lang/ast/types/expression-def.js +21 -11
- package/dist/lang/ast/types/field-collection-member.js +1 -2
- package/dist/lang/ast/types/field-prop-statement.js +1 -2
- package/dist/lang/ast/types/global-name-space.js +2 -2
- package/dist/lang/ast/types/granular-result.js +1 -2
- package/dist/lang/ast/types/malloy-element.js +3 -3
- package/dist/lang/ast/types/noteable.js +3 -4
- package/dist/lang/ast/types/query-element.js +1 -2
- package/dist/lang/ast/types/query-extend-property.js +1 -2
- package/dist/lang/ast/types/query-property.js +1 -2
- package/dist/lang/ast/types/source-property.js +1 -2
- package/dist/lang/ast/types/space-entry.js +2 -2
- package/dist/lang/ast/types/space-param.js +17 -7
- package/dist/lang/ast/view-elements/refine-utils.js +1 -2
- package/dist/lang/field-utils.js +2 -3
- package/dist/lang/lib/Malloy/MalloyLexer.js +17 -7
- package/dist/lang/lib/Malloy/MalloyParser.js +17 -7
- package/dist/lang/malloy-to-ast.js +17 -7
- package/dist/lang/malloy-to-stable-query.js +19 -9
- package/dist/lang/parse-log.js +2 -2
- package/dist/lang/parse-malloy.js +17 -7
- package/dist/lang/parse-tree-walkers/document-completion-walker.js +1 -2
- package/dist/lang/parse-tree-walkers/document-help-context-walker.js +1 -2
- package/dist/lang/parse-tree-walkers/document-symbol-walker.js +1 -2
- package/dist/lang/parse-tree-walkers/explore-query-walker.js +2 -2
- package/dist/lang/parse-tree-walkers/find-external-references.js +3 -4
- package/dist/lang/parse-tree-walkers/find-table-path-walker.js +1 -2
- package/dist/lang/parse-tree-walkers/model-annotation-walker.js +1 -2
- package/dist/lang/parse-utils.js +8 -9
- package/dist/lang/run-malloy-parser.js +1 -2
- package/dist/lang/test/expr-to-str.js +1 -2
- package/dist/lang/test/test-translator.js +18 -18
- package/dist/lang/translate-response.js +1 -2
- package/dist/lang/utils.js +6 -7
- package/dist/malloy.d.ts +0 -2
- package/dist/model/composite_source_utils.js +17 -18
- package/dist/model/filter_compilers.d.ts +1 -1
- package/dist/model/malloy_query.js +3 -3
- package/dist/model/malloy_types.d.ts +1 -3
- package/dist/model/malloy_types.js +64 -65
- package/dist/model/materialization/utils.js +2 -3
- package/dist/model/sql_block.js +2 -3
- package/dist/model/utils.js +10 -10
- package/dist/test/index.d.ts +0 -1
- package/dist/test/index.js +3 -4
- package/dist/to_stable.d.ts +1 -0
- package/dist/to_stable.js +41 -34
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
|
@@ -23,25 +23,83 @@
|
|
|
23
23
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
exports.
|
|
26
|
+
exports.TD = exports.ValueType = void 0;
|
|
27
|
+
exports.exprHasKids = exprHasKids;
|
|
28
|
+
exports.exprHasE = exprHasE;
|
|
29
|
+
exports.exprIsLeaf = exprIsLeaf;
|
|
30
|
+
exports.isAsymmetricExpr = isAsymmetricExpr;
|
|
31
|
+
exports.mkTemporal = mkTemporal;
|
|
32
|
+
exports.isRawCast = isRawCast;
|
|
33
|
+
exports.isFilterExprType = isFilterExprType;
|
|
34
|
+
exports.isParameterType = isParameterType;
|
|
35
|
+
exports.paramHasValue = paramHasValue;
|
|
36
|
+
exports.expressionIsScalar = expressionIsScalar;
|
|
37
|
+
exports.expressionIsAggregate = expressionIsAggregate;
|
|
38
|
+
exports.expressionIsUngroupedAggregate = expressionIsUngroupedAggregate;
|
|
39
|
+
exports.expressionInvolvesAggregate = expressionInvolvesAggregate;
|
|
40
|
+
exports.expressionIsCalculation = expressionIsCalculation;
|
|
41
|
+
exports.expressionIsAnalytic = expressionIsAnalytic;
|
|
42
|
+
exports.isExpressionTypeLEQ = isExpressionTypeLEQ;
|
|
43
|
+
exports.maxExpressionType = maxExpressionType;
|
|
44
|
+
exports.maxOfExpressionTypes = maxOfExpressionTypes;
|
|
45
|
+
exports.hasExpression = hasExpression;
|
|
46
|
+
exports.isTemporalType = isTemporalType;
|
|
47
|
+
exports.isAtomicFieldType = isAtomicFieldType;
|
|
48
|
+
exports.canOrderBy = canOrderBy;
|
|
49
|
+
exports.isCastType = isCastType;
|
|
50
|
+
exports.fieldIsIntrinsic = fieldIsIntrinsic;
|
|
51
|
+
exports.mkFieldDef = mkFieldDef;
|
|
52
|
+
exports.mkArrayDef = mkArrayDef;
|
|
53
|
+
exports.isRepeatedRecordFunctionParam = isRepeatedRecordFunctionParam;
|
|
54
|
+
exports.isRepeatedRecord = isRepeatedRecord;
|
|
55
|
+
exports.isBasicArray = isBasicArray;
|
|
56
|
+
exports.isMatrixOperation = isMatrixOperation;
|
|
57
|
+
exports.isJoinable = isJoinable;
|
|
58
|
+
exports.isJoined = isJoined;
|
|
59
|
+
exports.isJoinedSource = isJoinedSource;
|
|
60
|
+
exports.isDateUnit = isDateUnit;
|
|
61
|
+
exports.isTimestampUnit = isTimestampUnit;
|
|
62
|
+
exports.isExtractUnit = isExtractUnit;
|
|
63
|
+
exports.refIsStructDef = refIsStructDef;
|
|
64
|
+
exports.segmentHasErrors = segmentHasErrors;
|
|
65
|
+
exports.structHasErrors = structHasErrors;
|
|
66
|
+
exports.isReduceSegment = isReduceSegment;
|
|
67
|
+
exports.isPartialSegment = isPartialSegment;
|
|
68
|
+
exports.isProjectSegment = isProjectSegment;
|
|
69
|
+
exports.isQuerySegment = isQuerySegment;
|
|
70
|
+
exports.isSamplingRows = isSamplingRows;
|
|
71
|
+
exports.isSamplingPercent = isSamplingPercent;
|
|
72
|
+
exports.isSamplingEnable = isSamplingEnable;
|
|
73
|
+
exports.isRawSegment = isRawSegment;
|
|
74
|
+
exports.isIndexSegment = isIndexSegment;
|
|
75
|
+
exports.isSegmentSQL = isSegmentSQL;
|
|
76
|
+
exports.sourceBase = sourceBase;
|
|
77
|
+
exports.isSourceDef = isSourceDef;
|
|
78
|
+
exports.isBaseTable = isBaseTable;
|
|
79
|
+
exports.isLiteral = isLiteral;
|
|
80
|
+
exports.mergeEvalSpaces = mergeEvalSpaces;
|
|
81
|
+
exports.isBasicAtomic = isBasicAtomic;
|
|
82
|
+
exports.getIdentifier = getIdentifier;
|
|
83
|
+
exports.isTurtle = isTurtle;
|
|
84
|
+
exports.isAtomic = isAtomic;
|
|
85
|
+
exports.isValueString = isValueString;
|
|
86
|
+
exports.isValueNumber = isValueNumber;
|
|
87
|
+
exports.isValueBoolean = isValueBoolean;
|
|
88
|
+
exports.isValueTimestamp = isValueTimestamp;
|
|
89
|
+
exports.isValueDate = isValueDate;
|
|
28
90
|
function exprHasKids(e) {
|
|
29
91
|
return 'kids' in e;
|
|
30
92
|
}
|
|
31
|
-
exports.exprHasKids = exprHasKids;
|
|
32
93
|
function exprHasE(e) {
|
|
33
94
|
return 'e' in e;
|
|
34
95
|
}
|
|
35
|
-
exports.exprHasE = exprHasE;
|
|
36
96
|
function exprIsLeaf(e) {
|
|
37
97
|
return !(exprHasKids(e) || exprHasE(e));
|
|
38
98
|
}
|
|
39
|
-
exports.exprIsLeaf = exprIsLeaf;
|
|
40
99
|
function isAsymmetricExpr(f) {
|
|
41
100
|
return (f.node === 'aggregate' &&
|
|
42
101
|
['sum', 'avg', 'count', 'distinct'].includes(f.function));
|
|
43
102
|
}
|
|
44
|
-
exports.isAsymmetricExpr = isAsymmetricExpr;
|
|
45
103
|
/**
|
|
46
104
|
* Return true if this node can be turned into a temporal node by simply
|
|
47
105
|
* appending a time type to the typedef. The type systsem makes this hard
|
|
@@ -66,15 +124,12 @@ function mkTemporal(e, timeType) {
|
|
|
66
124
|
}
|
|
67
125
|
return e;
|
|
68
126
|
}
|
|
69
|
-
exports.mkTemporal = mkTemporal;
|
|
70
127
|
function isRawCast(te) {
|
|
71
128
|
return 'dstSQLType' in te;
|
|
72
129
|
}
|
|
73
|
-
exports.isRawCast = isRawCast;
|
|
74
130
|
function isFilterExprType(s) {
|
|
75
131
|
return ['string', 'number', 'boolean', 'date', 'timestamp'].includes(s);
|
|
76
132
|
}
|
|
77
|
-
exports.isFilterExprType = isFilterExprType;
|
|
78
133
|
function isParameterType(t) {
|
|
79
134
|
return [
|
|
80
135
|
'string',
|
|
@@ -86,40 +141,32 @@ function isParameterType(t) {
|
|
|
86
141
|
'error',
|
|
87
142
|
].includes(t);
|
|
88
143
|
}
|
|
89
|
-
exports.isParameterType = isParameterType;
|
|
90
144
|
function paramHasValue(p) {
|
|
91
145
|
return p.value !== null;
|
|
92
146
|
}
|
|
93
|
-
exports.paramHasValue = paramHasValue;
|
|
94
147
|
function expressionIsScalar(e) {
|
|
95
148
|
return e === undefined || e === 'scalar';
|
|
96
149
|
}
|
|
97
|
-
exports.expressionIsScalar = expressionIsScalar;
|
|
98
150
|
function expressionIsAggregate(e) {
|
|
99
151
|
return e === 'aggregate' || e === 'ungrouped_aggregate';
|
|
100
152
|
}
|
|
101
|
-
exports.expressionIsAggregate = expressionIsAggregate;
|
|
102
153
|
function expressionIsUngroupedAggregate(e) {
|
|
103
154
|
return e === 'ungrouped_aggregate';
|
|
104
155
|
}
|
|
105
|
-
exports.expressionIsUngroupedAggregate = expressionIsUngroupedAggregate;
|
|
106
156
|
function expressionInvolvesAggregate(e) {
|
|
107
157
|
return (e === 'aggregate' ||
|
|
108
158
|
e === 'ungrouped_aggregate' ||
|
|
109
159
|
e === 'aggregate_analytic');
|
|
110
160
|
}
|
|
111
|
-
exports.expressionInvolvesAggregate = expressionInvolvesAggregate;
|
|
112
161
|
function expressionIsCalculation(e) {
|
|
113
162
|
return (e === 'aggregate' ||
|
|
114
163
|
e === 'scalar_analytic' ||
|
|
115
164
|
e === 'aggregate_analytic' ||
|
|
116
165
|
e === 'ungrouped_aggregate');
|
|
117
166
|
}
|
|
118
|
-
exports.expressionIsCalculation = expressionIsCalculation;
|
|
119
167
|
function expressionIsAnalytic(e) {
|
|
120
168
|
return e === 'aggregate_analytic' || e === 'scalar_analytic';
|
|
121
169
|
}
|
|
122
|
-
exports.expressionIsAnalytic = expressionIsAnalytic;
|
|
123
170
|
function expressionTypeLevel(e) {
|
|
124
171
|
return {
|
|
125
172
|
scalar: 0,
|
|
@@ -132,7 +179,6 @@ function expressionTypeLevel(e) {
|
|
|
132
179
|
function isExpressionTypeLEQ(e1, e2) {
|
|
133
180
|
return e1 === e2 || expressionTypeLevel(e1) < expressionTypeLevel(e2);
|
|
134
181
|
}
|
|
135
|
-
exports.isExpressionTypeLEQ = isExpressionTypeLEQ;
|
|
136
182
|
// TODO rename this to be like `combineExpressionTypes`
|
|
137
183
|
function maxExpressionType(e1, e2) {
|
|
138
184
|
// TODO handle the case where e1 is analytic and e2 is ungrouped_aggregate
|
|
@@ -157,19 +203,15 @@ function maxExpressionType(e1, e2) {
|
|
|
157
203
|
}
|
|
158
204
|
return ret;
|
|
159
205
|
}
|
|
160
|
-
exports.maxExpressionType = maxExpressionType;
|
|
161
206
|
function maxOfExpressionTypes(types) {
|
|
162
207
|
return types.reduce(maxExpressionType, 'scalar');
|
|
163
208
|
}
|
|
164
|
-
exports.maxOfExpressionTypes = maxOfExpressionTypes;
|
|
165
209
|
function hasExpression(f) {
|
|
166
210
|
return 'e' in f;
|
|
167
211
|
}
|
|
168
|
-
exports.hasExpression = hasExpression;
|
|
169
212
|
function isTemporalType(s) {
|
|
170
213
|
return s === 'date' || s === 'timestamp';
|
|
171
214
|
}
|
|
172
|
-
exports.isTemporalType = isTemporalType;
|
|
173
215
|
function isAtomicFieldType(s) {
|
|
174
216
|
return [
|
|
175
217
|
'string',
|
|
@@ -184,20 +226,16 @@ function isAtomicFieldType(s) {
|
|
|
184
226
|
'error',
|
|
185
227
|
].includes(s);
|
|
186
228
|
}
|
|
187
|
-
exports.isAtomicFieldType = isAtomicFieldType;
|
|
188
229
|
function canOrderBy(s) {
|
|
189
230
|
return ['string', 'number', 'date', 'boolean', 'date', 'timestamp'].includes(s);
|
|
190
231
|
}
|
|
191
|
-
exports.canOrderBy = canOrderBy;
|
|
192
232
|
function isCastType(s) {
|
|
193
233
|
return ['string', 'number', 'date', 'timestamp', 'boolean', 'json'].includes(s);
|
|
194
234
|
}
|
|
195
|
-
exports.isCastType = isCastType;
|
|
196
235
|
// this field definition represents something in the database.
|
|
197
236
|
function fieldIsIntrinsic(f) {
|
|
198
237
|
return isAtomicFieldType(f.type) && !hasExpression(f);
|
|
199
238
|
}
|
|
200
|
-
exports.fieldIsIntrinsic = fieldIsIntrinsic;
|
|
201
239
|
function mkFieldDef(atd, name) {
|
|
202
240
|
if (isBasicArray(atd)) {
|
|
203
241
|
return mkArrayDef(atd.elementTypeDef, name);
|
|
@@ -212,7 +250,6 @@ function mkFieldDef(atd, name) {
|
|
|
212
250
|
}
|
|
213
251
|
return { ...atd, name };
|
|
214
252
|
}
|
|
215
|
-
exports.mkFieldDef = mkFieldDef;
|
|
216
253
|
function mkArrayDef(ofType, name) {
|
|
217
254
|
if (ofType.type === 'record') {
|
|
218
255
|
return {
|
|
@@ -235,23 +272,18 @@ function mkArrayDef(ofType, name) {
|
|
|
235
272
|
],
|
|
236
273
|
};
|
|
237
274
|
}
|
|
238
|
-
exports.mkArrayDef = mkArrayDef;
|
|
239
275
|
function isRepeatedRecordFunctionParam(paramT) {
|
|
240
276
|
return (paramT.type === 'array' && paramT.elementTypeDef.type === 'record_element');
|
|
241
277
|
}
|
|
242
|
-
exports.isRepeatedRecordFunctionParam = isRepeatedRecordFunctionParam;
|
|
243
278
|
function isRepeatedRecord(fd) {
|
|
244
279
|
return fd.type === 'array' && fd.elementTypeDef.type === 'record_element';
|
|
245
280
|
}
|
|
246
|
-
exports.isRepeatedRecord = isRepeatedRecord;
|
|
247
281
|
function isBasicArray(td) {
|
|
248
282
|
return td.type === 'array' && td.elementTypeDef.type !== 'record_element';
|
|
249
283
|
}
|
|
250
|
-
exports.isBasicArray = isBasicArray;
|
|
251
284
|
function isMatrixOperation(x) {
|
|
252
285
|
return ['left', 'right', 'full', 'inner'].includes(x);
|
|
253
286
|
}
|
|
254
|
-
exports.isMatrixOperation = isMatrixOperation;
|
|
255
287
|
function isJoinable(sd) {
|
|
256
288
|
return [
|
|
257
289
|
'composite',
|
|
@@ -262,27 +294,21 @@ function isJoinable(sd) {
|
|
|
262
294
|
'record',
|
|
263
295
|
].includes(sd.type);
|
|
264
296
|
}
|
|
265
|
-
exports.isJoinable = isJoinable;
|
|
266
297
|
function isJoined(sd) {
|
|
267
298
|
return 'join' in sd;
|
|
268
299
|
}
|
|
269
|
-
exports.isJoined = isJoined;
|
|
270
300
|
function isJoinedSource(sd) {
|
|
271
301
|
return isSourceDef(sd) && isJoined(sd);
|
|
272
302
|
}
|
|
273
|
-
exports.isJoinedSource = isJoinedSource;
|
|
274
303
|
function isDateUnit(str) {
|
|
275
304
|
return ['day', 'week', 'month', 'quarter', 'year'].includes(str);
|
|
276
305
|
}
|
|
277
|
-
exports.isDateUnit = isDateUnit;
|
|
278
306
|
function isTimestampUnit(s) {
|
|
279
307
|
return isDateUnit(s) || ['hour', 'minute', 'second'].includes(s);
|
|
280
308
|
}
|
|
281
|
-
exports.isTimestampUnit = isTimestampUnit;
|
|
282
309
|
function isExtractUnit(s) {
|
|
283
310
|
return isTimestampUnit(s) || s === 'day_of_week' || s === 'day_of_year';
|
|
284
311
|
}
|
|
285
|
-
exports.isExtractUnit = isExtractUnit;
|
|
286
312
|
/** Value types distinguished by their usage in generated SQL, particularly with respect to filters. */
|
|
287
313
|
var ValueType;
|
|
288
314
|
(function (ValueType) {
|
|
@@ -294,7 +320,6 @@ var ValueType;
|
|
|
294
320
|
function refIsStructDef(ref) {
|
|
295
321
|
return typeof ref !== 'string';
|
|
296
322
|
}
|
|
297
|
-
exports.refIsStructDef = refIsStructDef;
|
|
298
323
|
function segmentHasErrors(segment) {
|
|
299
324
|
if (segment.type === 'reduce' ||
|
|
300
325
|
segment.type === 'project' ||
|
|
@@ -310,58 +335,45 @@ function segmentHasErrors(segment) {
|
|
|
310
335
|
}
|
|
311
336
|
return false;
|
|
312
337
|
}
|
|
313
|
-
exports.segmentHasErrors = segmentHasErrors;
|
|
314
338
|
function structHasErrors(struct) {
|
|
315
339
|
return struct.fields.some(f => f.type === 'error');
|
|
316
340
|
}
|
|
317
|
-
exports.structHasErrors = structHasErrors;
|
|
318
341
|
function isReduceSegment(pe) {
|
|
319
342
|
return pe.type === 'reduce';
|
|
320
343
|
}
|
|
321
|
-
exports.isReduceSegment = isReduceSegment;
|
|
322
344
|
function isPartialSegment(pe) {
|
|
323
345
|
return pe.type === 'partial';
|
|
324
346
|
}
|
|
325
|
-
exports.isPartialSegment = isPartialSegment;
|
|
326
347
|
function isProjectSegment(pe) {
|
|
327
348
|
return pe.type === 'project';
|
|
328
349
|
}
|
|
329
|
-
exports.isProjectSegment = isProjectSegment;
|
|
330
350
|
function isQuerySegment(pe) {
|
|
331
351
|
return isProjectSegment(pe) || isReduceSegment(pe);
|
|
332
352
|
}
|
|
333
|
-
exports.isQuerySegment = isQuerySegment;
|
|
334
353
|
function isSamplingRows(s) {
|
|
335
354
|
return s.rows !== undefined;
|
|
336
355
|
}
|
|
337
|
-
exports.isSamplingRows = isSamplingRows;
|
|
338
356
|
function isSamplingPercent(s) {
|
|
339
357
|
return s.percent !== undefined;
|
|
340
358
|
}
|
|
341
|
-
exports.isSamplingPercent = isSamplingPercent;
|
|
342
359
|
function isSamplingEnable(s) {
|
|
343
360
|
return s.enable !== undefined;
|
|
344
361
|
}
|
|
345
|
-
exports.isSamplingEnable = isSamplingEnable;
|
|
346
362
|
function isRawSegment(pe) {
|
|
347
363
|
return pe.type === 'raw';
|
|
348
364
|
}
|
|
349
|
-
exports.isRawSegment = isRawSegment;
|
|
350
365
|
function isIndexSegment(pe) {
|
|
351
366
|
return pe.type === 'index';
|
|
352
367
|
}
|
|
353
|
-
exports.isIndexSegment = isIndexSegment;
|
|
354
368
|
function isSegmentSQL(f) {
|
|
355
369
|
return 'sql' in f;
|
|
356
370
|
}
|
|
357
|
-
exports.isSegmentSQL = isSegmentSQL;
|
|
358
371
|
// The gesture {...sourceStruct moreProperties} happens everywhere, now that
|
|
359
372
|
// structs aren't all identical, we need a way to make one from any of the
|
|
360
373
|
// exisitng structs
|
|
361
374
|
function sourceBase(sd) {
|
|
362
375
|
return { ...sd };
|
|
363
376
|
}
|
|
364
|
-
exports.sourceBase = sourceBase;
|
|
365
377
|
function isSourceDef(sd) {
|
|
366
378
|
return (sd.type === 'table' ||
|
|
367
379
|
sd.type === 'sql_select' ||
|
|
@@ -371,7 +383,6 @@ function isSourceDef(sd) {
|
|
|
371
383
|
sd.type === 'nest_source' ||
|
|
372
384
|
sd.type === 'composite');
|
|
373
385
|
}
|
|
374
|
-
exports.isSourceDef = isSourceDef;
|
|
375
386
|
/** Is this the "FROM" table of a query tree */
|
|
376
387
|
function isBaseTable(def) {
|
|
377
388
|
if (isJoinedSource(def)) {
|
|
@@ -382,11 +393,9 @@ function isBaseTable(def) {
|
|
|
382
393
|
}
|
|
383
394
|
return false;
|
|
384
395
|
}
|
|
385
|
-
exports.isBaseTable = isBaseTable;
|
|
386
396
|
function isLiteral(evalSpace) {
|
|
387
397
|
return evalSpace === 'literal';
|
|
388
398
|
}
|
|
389
|
-
exports.isLiteral = isLiteral;
|
|
390
399
|
function mergeEvalSpaces(...evalSpaces) {
|
|
391
400
|
if (evalSpaces.length <= 1 && evalSpaces.every(e => e === 'literal')) {
|
|
392
401
|
return 'literal';
|
|
@@ -399,7 +408,6 @@ function mergeEvalSpaces(...evalSpaces) {
|
|
|
399
408
|
}
|
|
400
409
|
return 'input';
|
|
401
410
|
}
|
|
402
|
-
exports.mergeEvalSpaces = mergeEvalSpaces;
|
|
403
411
|
function isBasicAtomic(fd) {
|
|
404
412
|
return (fd.type === 'string' ||
|
|
405
413
|
isTemporalType(fd.type) ||
|
|
@@ -409,7 +417,6 @@ function isBasicAtomic(fd) {
|
|
|
409
417
|
fd.type === 'sql native' ||
|
|
410
418
|
fd.type === 'error');
|
|
411
419
|
}
|
|
412
|
-
exports.isBasicAtomic = isBasicAtomic;
|
|
413
420
|
/** Get the output name for a NamedObject */
|
|
414
421
|
function getIdentifier(n) {
|
|
415
422
|
if (n.as !== undefined) {
|
|
@@ -417,35 +424,27 @@ function getIdentifier(n) {
|
|
|
417
424
|
}
|
|
418
425
|
return n.name;
|
|
419
426
|
}
|
|
420
|
-
exports.getIdentifier = getIdentifier;
|
|
421
427
|
function isTurtle(def) {
|
|
422
428
|
return def.type === 'turtle';
|
|
423
429
|
}
|
|
424
|
-
exports.isTurtle = isTurtle;
|
|
425
430
|
function isAtomic(def) {
|
|
426
431
|
return isAtomicFieldType(def.type);
|
|
427
432
|
}
|
|
428
|
-
exports.isAtomic = isAtomic;
|
|
429
433
|
function isValueString(value, field) {
|
|
430
434
|
return field.type === 'string';
|
|
431
435
|
}
|
|
432
|
-
exports.isValueString = isValueString;
|
|
433
436
|
function isValueNumber(value, field) {
|
|
434
437
|
return field.type === 'number';
|
|
435
438
|
}
|
|
436
|
-
exports.isValueNumber = isValueNumber;
|
|
437
439
|
function isValueBoolean(value, field) {
|
|
438
440
|
return field.type === 'boolean';
|
|
439
441
|
}
|
|
440
|
-
exports.isValueBoolean = isValueBoolean;
|
|
441
442
|
function isValueTimestamp(value, field) {
|
|
442
443
|
return field.type === 'timestamp';
|
|
443
444
|
}
|
|
444
|
-
exports.isValueTimestamp = isValueTimestamp;
|
|
445
445
|
function isValueDate(value, field) {
|
|
446
446
|
return field.type === 'date';
|
|
447
447
|
}
|
|
448
|
-
exports.isValueDate = isValueDate;
|
|
449
448
|
/**
|
|
450
449
|
* A set of utilities for asking questions TypeDef/TypeDesc
|
|
451
450
|
* (which is OK because TypeDesc is an extension of a TypeDef)
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.shouldMaterialize = shouldMaterialize;
|
|
10
|
+
exports.buildQueryMaterializationSpec = buildQueryMaterializationSpec;
|
|
10
11
|
const utils_1 = require("../utils");
|
|
11
12
|
const annotation_1 = require("../../annotation");
|
|
12
13
|
function shouldMaterialize(annotation) {
|
|
@@ -17,7 +18,6 @@ function shouldMaterialize(annotation) {
|
|
|
17
18
|
const sourceTag = (0, annotation_1.annotationToTag)(clonedAnnotation).tag;
|
|
18
19
|
return sourceTag.has('materialize');
|
|
19
20
|
}
|
|
20
|
-
exports.shouldMaterialize = shouldMaterialize;
|
|
21
21
|
function buildQueryMaterializationSpec(path, queryName, materializatedTablePrefix) {
|
|
22
22
|
if (!queryName) {
|
|
23
23
|
throw new Error(`Query tagged to materialize, but its name is not specified. ${path}`);
|
|
@@ -38,5 +38,4 @@ function buildQueryMaterializationSpec(path, queryName, materializatedTablePrefi
|
|
|
38
38
|
id,
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
exports.buildQueryMaterializationSpec = buildQueryMaterializationSpec;
|
|
42
41
|
//# sourceMappingURL=utils.js.map
|
package/dist/model/sql_block.js
CHANGED
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.
|
|
25
|
+
exports.compileSQLInterpolation = compileSQLInterpolation;
|
|
26
|
+
exports.sqlKey = sqlKey;
|
|
26
27
|
const malloy_query_1 = require("./malloy_query");
|
|
27
28
|
const malloy_types_1 = require("./malloy_types");
|
|
28
29
|
const utils_1 = require("./utils");
|
|
@@ -55,9 +56,7 @@ function compileSQLInterpolation(select, connection, partialModel) {
|
|
|
55
56
|
selectStr,
|
|
56
57
|
};
|
|
57
58
|
}
|
|
58
|
-
exports.compileSQLInterpolation = compileSQLInterpolation;
|
|
59
59
|
function sqlKey(connectionName, sql) {
|
|
60
60
|
return `sql://${connectionName}/${(0, utils_1.generateHash)(sql)}`;
|
|
61
61
|
}
|
|
62
|
-
exports.sqlKey = sqlKey;
|
|
63
62
|
//# sourceMappingURL=sql_block.js.map
|
package/dist/model/utils.js
CHANGED
|
@@ -22,7 +22,16 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.
|
|
25
|
+
exports.AndChain = void 0;
|
|
26
|
+
exports.indent = indent;
|
|
27
|
+
exports.generateSQLStringLiteral = generateSQLStringLiteral;
|
|
28
|
+
exports.generateHash = generateHash;
|
|
29
|
+
exports.joinWith = joinWith;
|
|
30
|
+
exports.range = range;
|
|
31
|
+
exports.exprKids = exprKids;
|
|
32
|
+
exports.exprWalk = exprWalk;
|
|
33
|
+
exports.exprMap = exprMap;
|
|
34
|
+
exports.composeSQLExpr = composeSQLExpr;
|
|
26
35
|
const uuid_1 = require("uuid");
|
|
27
36
|
const malloy_types_1 = require("./malloy_types");
|
|
28
37
|
/** simple indent function */
|
|
@@ -31,7 +40,6 @@ function indent(s) {
|
|
|
31
40
|
const lastNewline = /\n {2}$/;
|
|
32
41
|
return s.replace(re, '$1 ').replace(lastNewline, '\n');
|
|
33
42
|
}
|
|
34
|
-
exports.indent = indent;
|
|
35
43
|
/**
|
|
36
44
|
* Generate a SQL string literal from a given `input` string, safe, e.g., to be used in `WHERE` clauses.
|
|
37
45
|
*/
|
|
@@ -39,7 +47,6 @@ function generateSQLStringLiteral(input) {
|
|
|
39
47
|
const escapedString = input.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
|
|
40
48
|
return `'${escapedString}'`;
|
|
41
49
|
}
|
|
42
|
-
exports.generateSQLStringLiteral = generateSQLStringLiteral;
|
|
43
50
|
/**
|
|
44
51
|
* WHERE and HAVING clauses are built out of a chain of boolean experssions
|
|
45
52
|
* joined with AND.
|
|
@@ -97,7 +104,6 @@ function generateHash(input) {
|
|
|
97
104
|
const MALLOY_UUID = '76c17e9d-f3ce-5f2d-bfde-98ad3d2a37f6';
|
|
98
105
|
return (0, uuid_1.v5)(input, MALLOY_UUID);
|
|
99
106
|
}
|
|
100
|
-
exports.generateHash = generateHash;
|
|
101
107
|
function joinWith(els, sep) {
|
|
102
108
|
const result = [];
|
|
103
109
|
for (let i = 0; i < els.length; i++) {
|
|
@@ -108,11 +114,9 @@ function joinWith(els, sep) {
|
|
|
108
114
|
}
|
|
109
115
|
return result;
|
|
110
116
|
}
|
|
111
|
-
exports.joinWith = joinWith;
|
|
112
117
|
function range(start, end) {
|
|
113
118
|
return Array.from({ length: end - start }, (_, index) => index + start);
|
|
114
119
|
}
|
|
115
|
-
exports.range = range;
|
|
116
120
|
function* exprKids(eNode) {
|
|
117
121
|
if ((0, malloy_types_1.exprHasKids)(eNode)) {
|
|
118
122
|
for (const kidEnt of Object.values(eNode.kids)) {
|
|
@@ -128,7 +132,6 @@ function* exprKids(eNode) {
|
|
|
128
132
|
yield eNode.e;
|
|
129
133
|
}
|
|
130
134
|
}
|
|
131
|
-
exports.exprKids = exprKids;
|
|
132
135
|
function* exprWalk(eNode, order = 'post') {
|
|
133
136
|
if (order === 'pre') {
|
|
134
137
|
yield eNode;
|
|
@@ -140,7 +143,6 @@ function* exprWalk(eNode, order = 'post') {
|
|
|
140
143
|
yield eNode;
|
|
141
144
|
}
|
|
142
145
|
}
|
|
143
|
-
exports.exprWalk = exprWalk;
|
|
144
146
|
function exprMap(eNode, mapFunc) {
|
|
145
147
|
let mapExpr = { ...eNode };
|
|
146
148
|
if ((0, malloy_types_1.exprHasKids)(eNode)) {
|
|
@@ -161,7 +163,6 @@ function exprMap(eNode, mapFunc) {
|
|
|
161
163
|
}
|
|
162
164
|
return mapFunc(mapExpr);
|
|
163
165
|
}
|
|
164
|
-
exports.exprMap = exprMap;
|
|
165
166
|
/**
|
|
166
167
|
* Take a mixed array of strings and Expr and turn it into an SQLExpr
|
|
167
168
|
* expression node.
|
|
@@ -194,5 +195,4 @@ function composeSQLExpr(from) {
|
|
|
194
195
|
}
|
|
195
196
|
return ret;
|
|
196
197
|
}
|
|
197
|
-
exports.composeSQLExpr = composeSQLExpr;
|
|
198
198
|
//# sourceMappingURL=utils.js.map
|
package/dist/test/index.d.ts
CHANGED
package/dist/test/index.js
CHANGED
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.
|
|
25
|
+
exports.databasesFromEnvironmentOr = databasesFromEnvironmentOr;
|
|
26
|
+
exports.describeIfDatabaseAvailable = describeIfDatabaseAvailable;
|
|
27
|
+
exports.brokenIn = brokenIn;
|
|
26
28
|
/**
|
|
27
29
|
* Accepts databases in env, either via comma-separated dialect list
|
|
28
30
|
* (MALLOY_DATABASES=) or a single database (MALLOY_DATABASE=). returns either
|
|
@@ -35,7 +37,6 @@ function databasesFromEnvironmentOr(defaultDatabases) {
|
|
|
35
37
|
? [process.env['MALLOY_DATABASE']]
|
|
36
38
|
: defaultDatabases;
|
|
37
39
|
}
|
|
38
|
-
exports.databasesFromEnvironmentOr = databasesFromEnvironmentOr;
|
|
39
40
|
/**
|
|
40
41
|
* A replacement for [describe()] that mimics [describe.skip()]
|
|
41
42
|
*/
|
|
@@ -56,9 +57,7 @@ function describeIfDatabaseAvailable(acceptableDatabases) {
|
|
|
56
57
|
const overlap = acceptableDatabases.filter(d => currentDatabases.includes(d));
|
|
57
58
|
return overlap.length > 0 ? [describe, overlap] : [describeSkip, overlap];
|
|
58
59
|
}
|
|
59
|
-
exports.describeIfDatabaseAvailable = describeIfDatabaseAvailable;
|
|
60
60
|
function brokenIn(dialectName, connectionName) {
|
|
61
61
|
return dialectName === connectionName;
|
|
62
62
|
}
|
|
63
|
-
exports.brokenIn = brokenIn;
|
|
64
63
|
//# sourceMappingURL=index.js.map
|
package/dist/to_stable.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type * as Malloy from '@malloydata/malloy-interfaces';
|
|
2
2
|
import type { FieldDef, ModelDef, ResultStructMetadataDef, SourceDef } from './model';
|
|
3
|
+
export declare function sourceDefToSourceInfo(sourceDef: SourceDef): Malloy.SourceInfo;
|
|
3
4
|
export declare function modelDefToModelInfo(modelDef: ModelDef): Malloy.ModelInfo;
|
|
4
5
|
export declare function convertFieldInfos(source: SourceDef, fields: FieldDef[]): Malloy.FieldInfo[];
|
|
5
6
|
export declare function getResultStructMetadataAnnotation(field: SourceDef, resultMetadata: ResultStructMetadataDef): Malloy.Annotation | undefined;
|
package/dist/to_stable.js
CHANGED
|
@@ -6,11 +6,47 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.sourceDefToSourceInfo = sourceDefToSourceInfo;
|
|
10
|
+
exports.modelDefToModelInfo = modelDefToModelInfo;
|
|
11
|
+
exports.convertFieldInfos = convertFieldInfos;
|
|
12
|
+
exports.getResultStructMetadataAnnotation = getResultStructMetadataAnnotation;
|
|
10
13
|
const model_1 = require("./model");
|
|
11
14
|
const malloy_query_1 = require("./model/malloy_query");
|
|
12
15
|
const annotation_1 = require("./annotation");
|
|
13
16
|
const malloy_tag_1 = require("@malloydata/malloy-tag");
|
|
17
|
+
function sourceDefToSourceInfo(sourceDef) {
|
|
18
|
+
var _a;
|
|
19
|
+
const parameters = sourceDef.parameters && Object.entries(sourceDef.parameters).length > 0
|
|
20
|
+
? Object.entries(sourceDef.parameters).map(([name, parameter]) => {
|
|
21
|
+
if ((0, model_1.isAtomic)(parameter)) {
|
|
22
|
+
return {
|
|
23
|
+
name,
|
|
24
|
+
type: typeDefToType(parameter),
|
|
25
|
+
default_value: convertParameterDefaultValue(parameter.value),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
name,
|
|
30
|
+
type: {
|
|
31
|
+
kind: 'filter_expression_type',
|
|
32
|
+
filter_type: {
|
|
33
|
+
kind: `${parameter.filterType}_type`,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
default_value: convertParameterDefaultValue(parameter.value),
|
|
37
|
+
};
|
|
38
|
+
})
|
|
39
|
+
: undefined;
|
|
40
|
+
const sourceInfo = {
|
|
41
|
+
name: (_a = sourceDef.as) !== null && _a !== void 0 ? _a : sourceDef.name,
|
|
42
|
+
schema: {
|
|
43
|
+
fields: convertFieldInfos(sourceDef, sourceDef.fields),
|
|
44
|
+
},
|
|
45
|
+
parameters,
|
|
46
|
+
annotations: getAnnotationsFromField(sourceDef),
|
|
47
|
+
};
|
|
48
|
+
return sourceInfo;
|
|
49
|
+
}
|
|
14
50
|
function modelDefToModelInfo(modelDef) {
|
|
15
51
|
const modelInfo = {
|
|
16
52
|
entries: [],
|
|
@@ -20,37 +56,11 @@ function modelDefToModelInfo(modelDef) {
|
|
|
20
56
|
if (!modelDef.exports.includes(name))
|
|
21
57
|
continue;
|
|
22
58
|
if ((0, model_1.isSourceDef)(entry)) {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
if ((0, model_1.isAtomic)(parameter)) {
|
|
26
|
-
return {
|
|
27
|
-
name,
|
|
28
|
-
type: typeDefToType(parameter),
|
|
29
|
-
default_value: convertParameterDefaultValue(parameter.value),
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
name,
|
|
34
|
-
type: {
|
|
35
|
-
kind: 'filter_expression_type',
|
|
36
|
-
filter_type: {
|
|
37
|
-
kind: `${parameter.filterType}_type`,
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
default_value: convertParameterDefaultValue(parameter.value),
|
|
41
|
-
};
|
|
42
|
-
})
|
|
43
|
-
: undefined;
|
|
44
|
-
const sourceInfo = {
|
|
59
|
+
const sourceInfo = sourceDefToSourceInfo(entry);
|
|
60
|
+
modelInfo.entries.push({
|
|
45
61
|
kind: 'source',
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
fields: convertFieldInfos(entry, entry.fields),
|
|
49
|
-
},
|
|
50
|
-
parameters,
|
|
51
|
-
annotations: getAnnotationsFromField(entry),
|
|
52
|
-
};
|
|
53
|
-
modelInfo.entries.push(sourceInfo);
|
|
62
|
+
...sourceInfo,
|
|
63
|
+
});
|
|
54
64
|
}
|
|
55
65
|
else if (entry.type === 'query') {
|
|
56
66
|
const outputStruct = (0, malloy_query_1.getResultStructDefForQuery)(modelDef, entry);
|
|
@@ -93,7 +103,6 @@ function modelDefToModelInfo(modelDef) {
|
|
|
93
103
|
}
|
|
94
104
|
return modelInfo;
|
|
95
105
|
}
|
|
96
|
-
exports.modelDefToModelInfo = modelDefToModelInfo;
|
|
97
106
|
function convertParameterDefaultValue(value) {
|
|
98
107
|
if (value === null)
|
|
99
108
|
return undefined;
|
|
@@ -195,7 +204,6 @@ function convertFieldInfos(source, fields) {
|
|
|
195
204
|
}
|
|
196
205
|
return result;
|
|
197
206
|
}
|
|
198
|
-
exports.convertFieldInfos = convertFieldInfos;
|
|
199
207
|
function getResultMetadataAnnotation(field, resultMetadata) {
|
|
200
208
|
const tag = malloy_tag_1.Tag.withPrefix('#(malloy) ');
|
|
201
209
|
let hasAny = false;
|
|
@@ -273,7 +281,6 @@ function getResultStructMetadataAnnotation(field, resultMetadata) {
|
|
|
273
281
|
}
|
|
274
282
|
: undefined;
|
|
275
283
|
}
|
|
276
|
-
exports.getResultStructMetadataAnnotation = getResultStructMetadataAnnotation;
|
|
277
284
|
function typeDefToType(field) {
|
|
278
285
|
if ((0, model_1.isBasicAtomic)(field)) {
|
|
279
286
|
switch (field.type) {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MALLOY_VERSION = "0.0.
|
|
1
|
+
export declare const MALLOY_VERSION = "0.0.280";
|
package/dist/version.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MALLOY_VERSION = void 0;
|
|
4
4
|
// generated with 'generate-version-file' script; do not edit manually
|
|
5
|
-
exports.MALLOY_VERSION = '0.0.
|
|
5
|
+
exports.MALLOY_VERSION = '0.0.280';
|
|
6
6
|
//# sourceMappingURL=version.js.map
|