@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
|
@@ -22,8 +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.
|
|
26
|
-
exports.isValueDate = exports.isValueTimestamp = exports.isValueBoolean = exports.isValueNumber = exports.isValueString = exports.
|
|
25
|
+
exports.mergeEvalSpaces = exports.isLiteral = exports.isScalarArray = exports.isBaseTable = exports.isSourceDef = exports.sourceBase = exports.isSegmentSQL = exports.isIndexSegment = exports.isRawSegment = exports.isSamplingEnable = exports.isSamplingPercent = exports.isSamplingRows = exports.isQuerySegment = exports.isProjectSegment = exports.isPartialSegment = exports.isReduceSegment = exports.structHasErrors = exports.segmentHasErrors = exports.refIsStructDef = exports.isByExpression = exports.isByName = exports.ValueType = exports.isExtractUnit = exports.isTimestampUnit = exports.isDateUnit = exports.isJoinedSource = exports.isJoined = exports.isJoinable = exports.isMatrixOperation = exports.isRepeatedRecord = exports.arrayEachFields = exports.fieldIsIntrinsic = exports.isCastType = exports.isAtomicFieldType = exports.isTemporalField = exports.hasExpression = exports.maxOfExpressionTypes = exports.maxExpressionType = exports.isExpressionTypeLEQ = exports.expressionIsAnalytic = exports.expressionIsCalculation = exports.expressionInvolvesAggregate = exports.expressionIsUngroupedAggregate = exports.expressionIsAggregate = exports.expressionIsScalar = exports.paramHasValue = exports.isAsymmetricExpr = exports.exprIsLeaf = exports.exprHasE = exports.exprHasKids = void 0;
|
|
26
|
+
exports.isValueDate = exports.isValueTimestamp = exports.isValueBoolean = exports.isValueNumber = exports.isValueString = exports.getAtomicFields = exports.isAtomic = exports.isTurtleDef = exports.modelObjIsSource = exports.getIdentifier = void 0;
|
|
27
27
|
function exprHasKids(e) {
|
|
28
28
|
return 'kids' in e;
|
|
29
29
|
}
|
|
@@ -116,15 +116,15 @@ function maxOfExpressionTypes(types) {
|
|
|
116
116
|
return types.reduce(maxExpressionType, 'scalar');
|
|
117
117
|
}
|
|
118
118
|
exports.maxOfExpressionTypes = maxOfExpressionTypes;
|
|
119
|
-
/** Grants access to the expression
|
|
119
|
+
/** Grants access to the expression properties of a FieldDef */
|
|
120
120
|
function hasExpression(f) {
|
|
121
|
-
return
|
|
121
|
+
return 'e' in f;
|
|
122
122
|
}
|
|
123
123
|
exports.hasExpression = hasExpression;
|
|
124
|
-
function
|
|
124
|
+
function isTemporalField(s) {
|
|
125
125
|
return s === 'date' || s === 'timestamp';
|
|
126
126
|
}
|
|
127
|
-
exports.
|
|
127
|
+
exports.isTemporalField = isTemporalField;
|
|
128
128
|
function isAtomicFieldType(s) {
|
|
129
129
|
return [
|
|
130
130
|
'string',
|
|
@@ -134,6 +134,8 @@ function isAtomicFieldType(s) {
|
|
|
134
134
|
'boolean',
|
|
135
135
|
'json',
|
|
136
136
|
'sql native',
|
|
137
|
+
'record',
|
|
138
|
+
'array',
|
|
137
139
|
'error',
|
|
138
140
|
].includes(s);
|
|
139
141
|
}
|
|
@@ -143,19 +145,37 @@ function isCastType(s) {
|
|
|
143
145
|
}
|
|
144
146
|
exports.isCastType = isCastType;
|
|
145
147
|
// this field definition represents something in the database.
|
|
146
|
-
function
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
function fieldIsIntrinsic(f) {
|
|
149
|
+
return isAtomicFieldType(f.type) && !hasExpression(f);
|
|
150
|
+
}
|
|
151
|
+
exports.fieldIsIntrinsic = fieldIsIntrinsic;
|
|
152
|
+
function arrayEachFields(arrayOf) {
|
|
153
|
+
return [
|
|
154
|
+
{ name: 'each', ...arrayOf, e: { node: 'field', path: ['value'] } },
|
|
155
|
+
{ name: 'value', ...arrayOf },
|
|
156
|
+
];
|
|
157
|
+
}
|
|
158
|
+
exports.arrayEachFields = arrayEachFields;
|
|
159
|
+
function isRepeatedRecord(fd) {
|
|
160
|
+
return fd.type === 'array' && fd.elementTypeDef.type === 'record_element';
|
|
161
|
+
}
|
|
162
|
+
exports.isRepeatedRecord = isRepeatedRecord;
|
|
163
|
+
function isMatrixOperation(x) {
|
|
164
|
+
return ['left', 'right', 'full', 'inner'].includes(x);
|
|
165
|
+
}
|
|
166
|
+
exports.isMatrixOperation = isMatrixOperation;
|
|
167
|
+
function isJoinable(sd) {
|
|
168
|
+
return ['table', 'sql_select', 'query_source', 'array', 'record'].includes(sd.type);
|
|
169
|
+
}
|
|
170
|
+
exports.isJoinable = isJoinable;
|
|
171
|
+
function isJoined(fd) {
|
|
172
|
+
return 'join' in fd;
|
|
173
|
+
}
|
|
174
|
+
exports.isJoined = isJoined;
|
|
175
|
+
function isJoinedSource(sd) {
|
|
176
|
+
return isSourceDef(sd) && isJoined(sd);
|
|
157
177
|
}
|
|
158
|
-
exports.
|
|
178
|
+
exports.isJoinedSource = isJoinedSource;
|
|
159
179
|
function isDateUnit(str) {
|
|
160
180
|
return ['day', 'week', 'month', 'quarter', 'year'].includes(str);
|
|
161
181
|
}
|
|
@@ -191,7 +211,7 @@ function isByExpression(by) {
|
|
|
191
211
|
}
|
|
192
212
|
exports.isByExpression = isByExpression;
|
|
193
213
|
function refIsStructDef(ref) {
|
|
194
|
-
return typeof ref !== 'string'
|
|
214
|
+
return typeof ref !== 'string';
|
|
195
215
|
}
|
|
196
216
|
exports.refIsStructDef = refIsStructDef;
|
|
197
217
|
function segmentHasErrors(segment) {
|
|
@@ -250,18 +270,41 @@ function isIndexSegment(pe) {
|
|
|
250
270
|
return pe.type === 'index';
|
|
251
271
|
}
|
|
252
272
|
exports.isIndexSegment = isIndexSegment;
|
|
253
|
-
function
|
|
254
|
-
return
|
|
255
|
-
}
|
|
256
|
-
exports.
|
|
257
|
-
|
|
258
|
-
|
|
273
|
+
function isSegmentSQL(f) {
|
|
274
|
+
return 'sql' in f;
|
|
275
|
+
}
|
|
276
|
+
exports.isSegmentSQL = isSegmentSQL;
|
|
277
|
+
// The gesture {...sourceStruct moreProperties} happens everywhere, now that
|
|
278
|
+
// structs aren't all identical, we need a way to make one from any of the
|
|
279
|
+
// exisitng structs
|
|
280
|
+
function sourceBase(sd) {
|
|
281
|
+
return { ...sd };
|
|
282
|
+
}
|
|
283
|
+
exports.sourceBase = sourceBase;
|
|
284
|
+
function isSourceDef(sd) {
|
|
285
|
+
return (sd.type === 'table' ||
|
|
286
|
+
sd.type === 'sql_select' ||
|
|
287
|
+
sd.type === 'query_source' ||
|
|
288
|
+
sd.type === 'query_result' ||
|
|
289
|
+
sd.type === 'finalize' ||
|
|
290
|
+
sd.type === 'nest_source');
|
|
291
|
+
}
|
|
292
|
+
exports.isSourceDef = isSourceDef;
|
|
293
|
+
/** Is this the "FROM" table of a query tree */
|
|
294
|
+
function isBaseTable(def) {
|
|
295
|
+
if (isJoined(def)) {
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
if (isSourceDef(def)) {
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
return false;
|
|
259
302
|
}
|
|
260
|
-
exports.
|
|
261
|
-
function
|
|
262
|
-
return
|
|
303
|
+
exports.isBaseTable = isBaseTable;
|
|
304
|
+
function isScalarArray(def) {
|
|
305
|
+
return def.type === 'array' && def.elementTypeDef.type !== 'record_element';
|
|
263
306
|
}
|
|
264
|
-
exports.
|
|
307
|
+
exports.isScalarArray = isScalarArray;
|
|
265
308
|
function isLiteral(evalSpace) {
|
|
266
309
|
return evalSpace === 'literal';
|
|
267
310
|
}
|
|
@@ -276,28 +319,6 @@ function mergeEvalSpaces(...evalSpaces) {
|
|
|
276
319
|
return 'input';
|
|
277
320
|
}
|
|
278
321
|
exports.mergeEvalSpaces = mergeEvalSpaces;
|
|
279
|
-
function isSQLBlockStruct(sd) {
|
|
280
|
-
const src = sd.structSource;
|
|
281
|
-
return src.type === 'sql' && src.method === 'subquery';
|
|
282
|
-
}
|
|
283
|
-
exports.isSQLBlockStruct = isSQLBlockStruct;
|
|
284
|
-
function isFieldTypeDef(f) {
|
|
285
|
-
return (f.type === 'string' ||
|
|
286
|
-
f.type === 'date' ||
|
|
287
|
-
f.type === 'number' ||
|
|
288
|
-
f.type === 'timestamp' ||
|
|
289
|
-
f.type === 'boolean' ||
|
|
290
|
-
f.type === 'json');
|
|
291
|
-
}
|
|
292
|
-
exports.isFieldTypeDef = isFieldTypeDef;
|
|
293
|
-
function isFieldTimeBased(f) {
|
|
294
|
-
return f.type === 'date' || f.type === 'timestamp';
|
|
295
|
-
}
|
|
296
|
-
exports.isFieldTimeBased = isFieldTimeBased;
|
|
297
|
-
function isFieldStructDef(f) {
|
|
298
|
-
return f.type === 'struct';
|
|
299
|
-
}
|
|
300
|
-
exports.isFieldStructDef = isFieldStructDef;
|
|
301
322
|
/** Get the output name for a NamedObject */
|
|
302
323
|
function getIdentifier(n) {
|
|
303
324
|
if (n.as !== undefined) {
|
|
@@ -306,46 +327,22 @@ function getIdentifier(n) {
|
|
|
306
327
|
return n.name;
|
|
307
328
|
}
|
|
308
329
|
exports.getIdentifier = getIdentifier;
|
|
330
|
+
function modelObjIsSource(nmo) {
|
|
331
|
+
return isSourceDef(nmo);
|
|
332
|
+
}
|
|
333
|
+
exports.modelObjIsSource = modelObjIsSource;
|
|
309
334
|
function isTurtleDef(def) {
|
|
310
335
|
return def.type === 'turtle';
|
|
311
336
|
}
|
|
312
337
|
exports.isTurtleDef = isTurtleDef;
|
|
313
|
-
function
|
|
338
|
+
function isAtomic(def) {
|
|
314
339
|
return isAtomicFieldType(def.type);
|
|
315
340
|
}
|
|
316
|
-
exports.
|
|
317
|
-
function
|
|
318
|
-
|
|
319
|
-
if ('resultMetadata' in field) {
|
|
320
|
-
return ((_a = field.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) === 'dimension';
|
|
321
|
-
}
|
|
322
|
-
return false;
|
|
323
|
-
}
|
|
324
|
-
exports.isDimensional = isDimensional;
|
|
325
|
-
function isPhysical(field) {
|
|
326
|
-
return ((isFieldTypeDef(field) && field.e === undefined) ||
|
|
327
|
-
(isFieldStructDef(field) &&
|
|
328
|
-
(field.structSource.type === 'nested' ||
|
|
329
|
-
field.structSource.type === 'inline')));
|
|
330
|
-
}
|
|
331
|
-
exports.isPhysical = isPhysical;
|
|
332
|
-
function getDimensions(structDef) {
|
|
333
|
-
return structDef.fields.filter(isDimensional);
|
|
334
|
-
}
|
|
335
|
-
exports.getDimensions = getDimensions;
|
|
336
|
-
function getPhysicalFields(structDef) {
|
|
337
|
-
return structDef.fields.filter(isPhysical);
|
|
338
|
-
}
|
|
339
|
-
exports.getPhysicalFields = getPhysicalFields;
|
|
340
|
-
function isMeasureLike(field) {
|
|
341
|
-
var _a, _b;
|
|
342
|
-
if ('resultMetadata' in field) {
|
|
343
|
-
return (((_a = field.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) === 'measure' ||
|
|
344
|
-
((_b = field.resultMetadata) === null || _b === void 0 ? void 0 : _b.fieldKind) === 'struct');
|
|
345
|
-
}
|
|
346
|
-
return false;
|
|
341
|
+
exports.isAtomic = isAtomic;
|
|
342
|
+
function getAtomicFields(structDef) {
|
|
343
|
+
return structDef.fields.filter(isAtomic);
|
|
347
344
|
}
|
|
348
|
-
exports.
|
|
345
|
+
exports.getAtomicFields = getAtomicFields;
|
|
349
346
|
function isValueString(value, field) {
|
|
350
347
|
return field.type === 'string';
|
|
351
348
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SQLSentence, SQLPhraseSegment } from './malloy_types';
|
|
2
2
|
/**
|
|
3
|
-
* The factory for
|
|
3
|
+
* The factory for SQLSentences. Exists because the name is computed
|
|
4
4
|
* from the components of the block and that name needs to be
|
|
5
|
-
* unique, but predictable.
|
|
5
|
+
* unique, but predictable so that it can be used to cache schema fetches.
|
|
6
6
|
*/
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function makeSQLSentence(select: SQLPhraseSegment[], connection: string): SQLSentence;
|
package/dist/model/sql_block.js
CHANGED
|
@@ -22,25 +22,22 @@
|
|
|
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.makeSQLSentence = void 0;
|
|
26
26
|
const malloy_types_1 = require("./malloy_types");
|
|
27
27
|
const utils_1 = require("./utils");
|
|
28
28
|
/**
|
|
29
|
-
* The factory for
|
|
29
|
+
* The factory for SQLSentences. Exists because the name is computed
|
|
30
30
|
* from the components of the block and that name needs to be
|
|
31
|
-
* unique, but predictable.
|
|
31
|
+
* unique, but predictable so that it can be used to cache schema fetches.
|
|
32
32
|
*/
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
name: `
|
|
33
|
+
function makeSQLSentence(select, connection) {
|
|
34
|
+
return {
|
|
35
|
+
name: `sql://${connection}/${nameFor(select)}`,
|
|
36
|
+
connection,
|
|
36
37
|
select,
|
|
37
38
|
};
|
|
38
|
-
if (connection) {
|
|
39
|
-
theBlock.connection = connection;
|
|
40
|
-
}
|
|
41
|
-
return theBlock;
|
|
42
39
|
}
|
|
43
|
-
exports.
|
|
40
|
+
exports.makeSQLSentence = makeSQLSentence;
|
|
44
41
|
// This feels like wrongness on toast, before SQL contained a query we
|
|
45
42
|
// could compute a stable hash from the select property to use to
|
|
46
43
|
// indentify this piece of SQL. Now the actual SQL isn't known until
|
|
@@ -50,7 +47,7 @@ exports.makeSQLBlock = makeSQLBlock;
|
|
|
50
47
|
// here for later, and that the whole "how to determine the name of a query"
|
|
51
48
|
// algorithm needs to change
|
|
52
49
|
function nameFor(select) {
|
|
53
|
-
const phrases = select.map(el => (0, malloy_types_1.
|
|
50
|
+
const phrases = select.map(el => (0, malloy_types_1.isSegmentSQL)(el) ? el.sql : JSON.stringify(el));
|
|
54
51
|
return (0, utils_1.generateHash)(phrases.join(';'));
|
|
55
52
|
}
|
|
56
53
|
//# sourceMappingURL=sql_block.js.map
|
package/dist/tags.js
CHANGED
|
@@ -280,10 +280,10 @@ class TagErrorListener {
|
|
|
280
280
|
this.log.push(logMsg);
|
|
281
281
|
}
|
|
282
282
|
semanticError(cx, code, msg) {
|
|
283
|
+
const left = this.fromChar + cx.start.charPositionInLine;
|
|
283
284
|
const errAt = {
|
|
284
285
|
line: this.atLine,
|
|
285
|
-
|
|
286
|
-
character: 0,
|
|
286
|
+
character: left,
|
|
287
287
|
};
|
|
288
288
|
const range = { start: errAt, end: errAt };
|
|
289
289
|
const logMsg = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MALLOY_VERSION = "0.0.195";
|
package/dist/version.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.195-
|
|
3
|
+
"version": "0.0.195-dev241007154000",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"clean": "tsc --build --clean && rm -rf src/lang/lib dist",
|
|
38
38
|
"build": "npm run build-parser && tsc --build",
|
|
39
39
|
"malloyc": "ts-node ../../scripts/malloy-to-json",
|
|
40
|
-
"prepublishOnly": "npm run clean && npm run build"
|
|
40
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
41
|
+
"generate-version-file": "VERSION=$(npm pkg get version --workspaces=false | tr -d \\\")\necho \"// generated with 'generate-version-file' script; do not edit manually\\nexport const MALLOY_VERSION = '$VERSION';\" > src/version.ts"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
44
|
"antlr4ts": "^0.5.0-alpha.4",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { StructDef } from '../../model/malloy_types';
|
|
2
|
-
import { FieldSpace } from './types/field-space';
|
|
3
|
-
export type SourceSpec = StructDef | FieldSpace;
|
|
4
|
-
/**
|
|
5
|
-
* Based on how things are constructed, a DynamicSpace can be seeded
|
|
6
|
-
* with a StructDef, or from another field space.
|
|
7
|
-
*/
|
|
8
|
-
export declare class SpaceSeed {
|
|
9
|
-
readonly sourceSpec: SourceSpec;
|
|
10
|
-
private readonly spaceSpec;
|
|
11
|
-
private asFS?;
|
|
12
|
-
private asStruct?;
|
|
13
|
-
constructor(sourceSpec: SourceSpec);
|
|
14
|
-
get structDef(): StructDef;
|
|
15
|
-
get fieldSpace(): FieldSpace;
|
|
16
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2023 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
* a copy of this software and associated documentation files
|
|
7
|
-
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
-
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
-
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
-
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
-
* subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be
|
|
14
|
-
* included in all copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
-
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.SpaceSeed = void 0;
|
|
26
|
-
const static_space_1 = require("./field-space/static-space");
|
|
27
|
-
function isFieldSpace(x) {
|
|
28
|
-
return x.type === 'fieldSpace';
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Based on how things are constructed, a DynamicSpace can be seeded
|
|
32
|
-
* with a StructDef, or from another field space.
|
|
33
|
-
*/
|
|
34
|
-
class SpaceSeed {
|
|
35
|
-
constructor(sourceSpec) {
|
|
36
|
-
this.sourceSpec = sourceSpec;
|
|
37
|
-
this.spaceSpec = sourceSpec;
|
|
38
|
-
}
|
|
39
|
-
get structDef() {
|
|
40
|
-
if (isFieldSpace(this.spaceSpec)) {
|
|
41
|
-
if (!this.asStruct) {
|
|
42
|
-
this.asStruct = this.spaceSpec.structDef();
|
|
43
|
-
}
|
|
44
|
-
return this.asStruct;
|
|
45
|
-
}
|
|
46
|
-
return this.spaceSpec;
|
|
47
|
-
}
|
|
48
|
-
get fieldSpace() {
|
|
49
|
-
if (isFieldSpace(this.spaceSpec)) {
|
|
50
|
-
return this.spaceSpec;
|
|
51
|
-
}
|
|
52
|
-
if (!this.asFS) {
|
|
53
|
-
this.asFS = new static_space_1.StaticSpace(this.spaceSpec);
|
|
54
|
-
}
|
|
55
|
-
return this.asFS;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.SpaceSeed = SpaceSeed;
|
|
59
|
-
//# sourceMappingURL=space-seed.js.map
|