@malloydata/malloy 0.0.243 → 0.0.244-dev250318232227
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/api/asynchronous.js +3 -2
- package/dist/api/core.d.ts +0 -2
- package/dist/api/core.js +8 -29
- package/dist/api/util.d.ts +3 -0
- package/dist/api/util.js +23 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -2
- package/dist/lang/index.d.ts +1 -0
- package/dist/lang/index.js +3 -1
- package/dist/lang/malloy-to-ast.js +1 -1
- package/dist/lang/malloy-to-stable-query.d.ts +4 -1
- package/dist/lang/malloy-to-stable-query.js +74 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
package/dist/api/asynchronous.js
CHANGED
|
@@ -31,6 +31,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.runQuery = exports.compileQuery = exports.compileSource = exports.compileModel = void 0;
|
|
33
33
|
const Core = __importStar(require("./core"));
|
|
34
|
+
const util_1 = require("./util");
|
|
34
35
|
async function fetchNeeds(needs, fetchers) {
|
|
35
36
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
36
37
|
var _h, _j;
|
|
@@ -170,7 +171,7 @@ async function runQuery(request, fetchers) {
|
|
|
170
171
|
url: defaultURL,
|
|
171
172
|
severity: 'error',
|
|
172
173
|
message: 'Internal error: Compiler did not generate SQL',
|
|
173
|
-
range:
|
|
174
|
+
range: util_1.DEFAULT_LOG_RANGE,
|
|
174
175
|
},
|
|
175
176
|
],
|
|
176
177
|
};
|
|
@@ -195,7 +196,7 @@ async function runQuery(request, fetchers) {
|
|
|
195
196
|
url: defaultURL,
|
|
196
197
|
severity: 'error',
|
|
197
198
|
message: `Error running SQL: ${error.message}`,
|
|
198
|
-
range:
|
|
199
|
+
range: util_1.DEFAULT_LOG_RANGE,
|
|
199
200
|
},
|
|
200
201
|
],
|
|
201
202
|
};
|
package/dist/api/core.d.ts
CHANGED
|
@@ -31,8 +31,6 @@ export declare function newCompileSourceState(request: Malloy.CompileSourceReque
|
|
|
31
31
|
export declare function statedCompileModel(state: CompileModelState): Malloy.CompileModelResponse;
|
|
32
32
|
export declare function statedCompileSource(state: CompileModelState, name: string): Malloy.CompileSourceResponse;
|
|
33
33
|
export declare function _statedCompileModel(state: CompileModelState): CompileResponse;
|
|
34
|
-
export declare const DEFAULT_LOG_RANGE: Malloy.DocumentRange;
|
|
35
|
-
export declare function mapLogs(logs: LogMessage[], defaultURL: string): Malloy.LogMessage[];
|
|
36
34
|
export declare function compileModel(request: Malloy.CompileModelRequest, state?: CompileModelState): Malloy.CompileModelResponse;
|
|
37
35
|
export declare function compileSource(request: Malloy.CompileSourceRequest): Malloy.CompileSourceResponse;
|
|
38
36
|
export declare function hasErrors(log: Malloy.LogMessage[] | undefined): boolean;
|
package/dist/api/core.js
CHANGED
|
@@ -29,7 +29,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
29
29
|
return result;
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.statedCompileQuery = exports.newCompileQueryState = exports.hasErrors = exports.compileSource = exports.compileModel = exports.
|
|
32
|
+
exports.statedCompileQuery = exports.newCompileQueryState = exports.hasErrors = exports.compileSource = exports.compileModel = exports._statedCompileModel = exports.statedCompileSource = exports.statedCompileModel = exports.newCompileSourceState = exports.newCompileModelState = exports.updateCompileModelState = exports.compileQuery = void 0;
|
|
33
33
|
const Malloy = __importStar(require("@malloydata/malloy-interfaces"));
|
|
34
34
|
const lang_1 = require("../lang");
|
|
35
35
|
const model_1 = require("../model");
|
|
@@ -37,6 +37,7 @@ const to_stable_1 = require("../to_stable");
|
|
|
37
37
|
const sql_block_1 = require("../model/sql_block");
|
|
38
38
|
const annotation_1 = require("../annotation");
|
|
39
39
|
const malloy_tag_1 = require("@malloydata/malloy-tag");
|
|
40
|
+
const util_1 = require("./util");
|
|
40
41
|
// TODO find where this should go...
|
|
41
42
|
function tableKey(connectionName, tablePath) {
|
|
42
43
|
return `${connectionName}:${tablePath}`;
|
|
@@ -305,30 +306,8 @@ function _statedCompileModel(state) {
|
|
|
305
306
|
}
|
|
306
307
|
}
|
|
307
308
|
exports._statedCompileModel = _statedCompileModel;
|
|
308
|
-
exports.DEFAULT_LOG_RANGE = {
|
|
309
|
-
start: {
|
|
310
|
-
line: 0,
|
|
311
|
-
character: 0,
|
|
312
|
-
},
|
|
313
|
-
end: {
|
|
314
|
-
line: 0,
|
|
315
|
-
character: 0,
|
|
316
|
-
},
|
|
317
|
-
};
|
|
318
|
-
function mapLogs(logs, defaultURL) {
|
|
319
|
-
return logs.map(log => {
|
|
320
|
-
var _a, _b, _c, _d;
|
|
321
|
-
return ({
|
|
322
|
-
severity: log.severity,
|
|
323
|
-
message: log.message,
|
|
324
|
-
range: (_b = (_a = log.at) === null || _a === void 0 ? void 0 : _a.range) !== null && _b !== void 0 ? _b : exports.DEFAULT_LOG_RANGE,
|
|
325
|
-
url: (_d = (_c = log.at) === null || _c === void 0 ? void 0 : _c.url) !== null && _d !== void 0 ? _d : defaultURL,
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
exports.mapLogs = mapLogs;
|
|
330
309
|
function wrapResponse(response, defaultURL) {
|
|
331
|
-
const logs = response.logs ? mapLogs(response.logs, defaultURL) : undefined;
|
|
310
|
+
const logs = response.logs ? (0, util_1.mapLogs)(response.logs, defaultURL) : undefined;
|
|
332
311
|
if (response.compilerNeeds) {
|
|
333
312
|
return { compiler_needs: response.compilerNeeds, logs };
|
|
334
313
|
}
|
|
@@ -352,7 +331,7 @@ function compileSource(request) {
|
|
|
352
331
|
exports.compileSource = compileSource;
|
|
353
332
|
// Given the URL to a model and a name of a queryable thing, get a StableSourceDef
|
|
354
333
|
function extractSource(result, name, defaultURL) {
|
|
355
|
-
const logs = result.logs ? mapLogs(result.logs, defaultURL) : undefined;
|
|
334
|
+
const logs = result.logs ? (0, util_1.mapLogs)(result.logs, defaultURL) : undefined;
|
|
356
335
|
if (result.model) {
|
|
357
336
|
const source = result.model.entries.find(e => e.name === name);
|
|
358
337
|
if (source === undefined) {
|
|
@@ -363,7 +342,7 @@ function extractSource(result, name, defaultURL) {
|
|
|
363
342
|
url: defaultURL,
|
|
364
343
|
severity: 'error',
|
|
365
344
|
message: `Model does not contain a source named ${name}`,
|
|
366
|
-
range:
|
|
345
|
+
range: util_1.DEFAULT_LOG_RANGE,
|
|
367
346
|
},
|
|
368
347
|
],
|
|
369
348
|
};
|
|
@@ -405,7 +384,7 @@ function statedCompileQuery(state) {
|
|
|
405
384
|
const result = _statedCompileModel(state);
|
|
406
385
|
// TODO this can expose the internal URL... is there a better way to handle URL-less errors from the compiler?
|
|
407
386
|
const defaultURL = state.translator.sourceURL;
|
|
408
|
-
const logs = result.logs ? mapLogs(result.logs, defaultURL) : undefined;
|
|
387
|
+
const logs = result.logs ? (0, util_1.mapLogs)(result.logs, defaultURL) : undefined;
|
|
409
388
|
if (result.model) {
|
|
410
389
|
const queries = result.modelDef.queryList;
|
|
411
390
|
if (queries.length === 0) {
|
|
@@ -416,7 +395,7 @@ function statedCompileQuery(state) {
|
|
|
416
395
|
url: defaultURL,
|
|
417
396
|
severity: 'error',
|
|
418
397
|
message: 'Internal error: No queries found',
|
|
419
|
-
range:
|
|
398
|
+
range: util_1.DEFAULT_LOG_RANGE,
|
|
420
399
|
},
|
|
421
400
|
],
|
|
422
401
|
};
|
|
@@ -462,7 +441,7 @@ function statedCompileQuery(state) {
|
|
|
462
441
|
url: defaultURL,
|
|
463
442
|
severity: 'error',
|
|
464
443
|
message: `Internal compiler error: ${error.message}`,
|
|
465
|
-
range:
|
|
444
|
+
range: util_1.DEFAULT_LOG_RANGE,
|
|
466
445
|
},
|
|
467
446
|
],
|
|
468
447
|
};
|
package/dist/api/util.d.ts
CHANGED
|
@@ -3,7 +3,10 @@ import type { Result } from '../malloy';
|
|
|
3
3
|
import type { QueryData } from '../model';
|
|
4
4
|
import type { Connection, InfoConnection } from './connection';
|
|
5
5
|
import type * as Malloy from '@malloydata/malloy-interfaces';
|
|
6
|
+
import type { LogMessage } from '../lang';
|
|
6
7
|
export declare function wrapLegacyInfoConnection(connection: LegacyInfoConnection): InfoConnection;
|
|
7
8
|
export declare function wrapLegacyConnection(connection: LegacyConnection): Connection;
|
|
8
9
|
export declare function mapData(data: QueryData, schema: Malloy.Schema): Malloy.Data;
|
|
9
10
|
export declare function wrapResult(result: Result): Malloy.Result;
|
|
11
|
+
export declare const DEFAULT_LOG_RANGE: Malloy.DocumentRange;
|
|
12
|
+
export declare function mapLogs(logs: LogMessage[], defaultURL: string): Malloy.LogMessage[];
|
package/dist/api/util.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.wrapResult = exports.mapData = exports.wrapLegacyConnection = exports.wrapLegacyInfoConnection = void 0;
|
|
9
|
+
exports.mapLogs = exports.DEFAULT_LOG_RANGE = exports.wrapResult = exports.mapData = exports.wrapLegacyConnection = exports.wrapLegacyInfoConnection = void 0;
|
|
10
10
|
const malloy_tag_1 = require("@malloydata/malloy-tag");
|
|
11
11
|
const annotation_1 = require("../annotation");
|
|
12
12
|
const to_stable_1 = require("../to_stable");
|
|
@@ -212,4 +212,26 @@ function wrapResult(result) {
|
|
|
212
212
|
};
|
|
213
213
|
}
|
|
214
214
|
exports.wrapResult = wrapResult;
|
|
215
|
+
exports.DEFAULT_LOG_RANGE = {
|
|
216
|
+
start: {
|
|
217
|
+
line: 0,
|
|
218
|
+
character: 0,
|
|
219
|
+
},
|
|
220
|
+
end: {
|
|
221
|
+
line: 0,
|
|
222
|
+
character: 0,
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
function mapLogs(logs, defaultURL) {
|
|
226
|
+
return logs.map(log => {
|
|
227
|
+
var _a, _b, _c, _d;
|
|
228
|
+
return ({
|
|
229
|
+
severity: log.severity,
|
|
230
|
+
message: log.message,
|
|
231
|
+
range: (_b = (_a = log.at) === null || _a === void 0 ? void 0 : _a.range) !== null && _b !== void 0 ? _b : exports.DEFAULT_LOG_RANGE,
|
|
232
|
+
url: (_d = (_c = log.at) === null || _c === void 0 ? void 0 : _c.url) !== null && _d !== void 0 ? _d : defaultURL,
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
exports.mapLogs = mapLogs;
|
|
215
237
|
//# sourceMappingURL=util.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { DuckDBDialect, StandardSQLDialect, TrinoDialect, PostgresDialect, Snowf
|
|
|
2
2
|
export type { DialectFieldList, DialectFunctionOverloadDef, QueryInfo, MalloyStandardFunctionImplementations, DefinitionBlueprint, DefinitionBlueprintMap, OverloadedDefinitionBlueprint, TinyToken, } from './dialect';
|
|
3
3
|
export type { QueryDataRow, StructDef, TableSourceDef, SQLSourceDef, SourceDef, JoinFieldDef, NamedSourceDefs, MalloyQueryData, DateUnit, ExtractUnit, TimestampUnit, TemporalFieldType, QueryData, QueryValue, Expr, FilterCondition, Argument, Parameter, FieldDef, PipeSegment, QueryFieldDef, IndexFieldDef, TurtleDef, SearchValueMapResult, SearchIndexResult, ModelDef, Query, QueryResult, QueryRunStats, NamedQuery, NamedModelObject, ExpressionType, FunctionDef, FunctionOverloadDef, FunctionParameterDef, ExpressionValueType, TypeDesc, FunctionParamTypeDesc, DocumentLocation, DocumentRange, DocumentPosition, Sampling, Annotation, LeafAtomicTypeDef, LeafAtomicDef, AtomicTypeDef, AtomicFieldDef, ArrayDef, ArrayTypeDef, RecordTypeDef, RepeatedRecordTypeDef, RecordDef, RepeatedRecordDef, RecordLiteralNode, ArrayLiteralNode, } from './model';
|
|
4
4
|
export { isSourceDef, Segment, isLeafAtomic, isJoined, isJoinedSource, isSamplingEnable, isSamplingPercent, isSamplingRows, isRepeatedRecord, isScalarArray, mkArrayDef, mkFieldDef, expressionIsAggregate, expressionIsAnalytic, expressionIsCalculation, expressionIsScalar, expressionIsUngroupedAggregate, indent, composeSQLExpr, } from './model';
|
|
5
|
-
export { MalloyTranslator, } from './lang';
|
|
5
|
+
export { malloyToQuery, MalloyTranslator, } from './lang';
|
|
6
6
|
export type { LogMessage, TranslateResponse } from './lang';
|
|
7
7
|
export { Model, Malloy, Runtime, AtomicFieldType, ConnectionRuntime, SingleConnectionRuntime, EmptyURLReader, InMemoryURLReader, FixedConnectionMap, MalloyError, JoinRelationship, SourceRelationship, DateTimeframe, TimestampTimeframe, PreparedResult, Result, QueryMaterializer, CSVWriter, JSONWriter, Parse, DataWriter, Explore, InMemoryModelCache, CacheManager, } from './malloy';
|
|
8
8
|
export type { PreparedQuery, Field, AtomicField, ExploreField, QueryField, SortableField, DataArray, DataRecord, DataColumn, DataArrayOrRecord, Loggable, ModelMaterializer, DocumentTablePath, DocumentSymbol, ResultJSON, PreparedResultJSON, PreparedResultMaterializer, ExploreMaterializer, WriteStream, SerializedExplore, ModelCache, CachedModel, DateField, TimestampField, } from './malloy';
|
package/dist/index.js
CHANGED
|
@@ -23,8 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
exports.annotationToTaglines = exports.annotationToTag = exports.sqlKey = exports.API = exports.modelDefToModelInfo = exports.toAsyncGenerator = exports.CacheManager = exports.InMemoryModelCache = exports.Explore = exports.DataWriter = exports.Parse = exports.JSONWriter = exports.CSVWriter = exports.QueryMaterializer = exports.Result = exports.PreparedResult = exports.TimestampTimeframe = exports.DateTimeframe = exports.SourceRelationship = exports.JoinRelationship = exports.MalloyError = exports.FixedConnectionMap = void 0;
|
|
26
|
+
exports.EmptyURLReader = exports.SingleConnectionRuntime = exports.ConnectionRuntime = exports.AtomicFieldType = exports.Runtime = exports.Malloy = exports.Model = exports.MalloyTranslator = exports.malloyToQuery = exports.composeSQLExpr = exports.indent = exports.expressionIsUngroupedAggregate = exports.expressionIsScalar = exports.expressionIsCalculation = exports.expressionIsAnalytic = exports.expressionIsAggregate = exports.mkFieldDef = exports.mkArrayDef = exports.isScalarArray = exports.isRepeatedRecord = exports.isSamplingRows = exports.isSamplingPercent = exports.isSamplingEnable = exports.isJoinedSource = exports.isJoined = exports.isLeafAtomic = exports.Segment = exports.isSourceDef = exports.TinyParser = exports.Dialect = exports.spread = exports.literal = exports.variadicParam = exports.param = exports.makeParam = exports.sql = exports.maxScalar = exports.minAggregate = exports.anyExprType = exports.minScalar = exports.overload = exports.qtz = exports.arg = exports.registerDialect = exports.MySQLDialect = exports.SnowflakeDialect = exports.PostgresDialect = exports.TrinoDialect = exports.StandardSQLDialect = exports.DuckDBDialect = void 0;
|
|
27
|
+
exports.annotationToTaglines = exports.annotationToTag = exports.sqlKey = exports.API = exports.modelDefToModelInfo = exports.toAsyncGenerator = exports.CacheManager = exports.InMemoryModelCache = exports.Explore = exports.DataWriter = exports.Parse = exports.JSONWriter = exports.CSVWriter = exports.QueryMaterializer = exports.Result = exports.PreparedResult = exports.TimestampTimeframe = exports.DateTimeframe = exports.SourceRelationship = exports.JoinRelationship = exports.MalloyError = exports.FixedConnectionMap = exports.InMemoryURLReader = void 0;
|
|
28
28
|
/*
|
|
29
29
|
* Copyright 2023 Google LLC
|
|
30
30
|
*
|
|
@@ -92,6 +92,7 @@ Object.defineProperty(exports, "expressionIsUngroupedAggregate", { enumerable: t
|
|
|
92
92
|
Object.defineProperty(exports, "indent", { enumerable: true, get: function () { return model_1.indent; } });
|
|
93
93
|
Object.defineProperty(exports, "composeSQLExpr", { enumerable: true, get: function () { return model_1.composeSQLExpr; } });
|
|
94
94
|
var lang_1 = require("./lang");
|
|
95
|
+
Object.defineProperty(exports, "malloyToQuery", { enumerable: true, get: function () { return lang_1.malloyToQuery; } });
|
|
95
96
|
// Needed for tests only
|
|
96
97
|
Object.defineProperty(exports, "MalloyTranslator", { enumerable: true, get: function () { return lang_1.MalloyTranslator; } });
|
|
97
98
|
var malloy_1 = require("./malloy");
|
package/dist/lang/index.d.ts
CHANGED
|
@@ -6,3 +6,4 @@ export type { ExploreClauseRef } from './parse-tree-walkers/explore-query-walker
|
|
|
6
6
|
export type { DocumentSymbol } from './parse-tree-walkers/document-symbol-walker';
|
|
7
7
|
export type { DocumentCompletion } from './parse-tree-walkers/document-completion-walker';
|
|
8
8
|
export type { LogMessage } from './parse-log';
|
|
9
|
+
export { malloyToQuery } from './malloy-to-stable-query';
|
package/dist/lang/index.js
CHANGED
|
@@ -22,10 +22,12 @@
|
|
|
22
22
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.exploreQueryWalkerBuilder = exports.MalloyTranslation = exports.MalloyTranslator = void 0;
|
|
25
|
+
exports.malloyToQuery = exports.exploreQueryWalkerBuilder = exports.MalloyTranslation = exports.MalloyTranslator = void 0;
|
|
26
26
|
var parse_malloy_1 = require("./parse-malloy");
|
|
27
27
|
Object.defineProperty(exports, "MalloyTranslator", { enumerable: true, get: function () { return parse_malloy_1.MalloyTranslator; } });
|
|
28
28
|
Object.defineProperty(exports, "MalloyTranslation", { enumerable: true, get: function () { return parse_malloy_1.MalloyTranslation; } });
|
|
29
29
|
var explore_query_walker_1 = require("./parse-tree-walkers/explore-query-walker");
|
|
30
30
|
Object.defineProperty(exports, "exploreQueryWalkerBuilder", { enumerable: true, get: function () { return explore_query_walker_1.exploreQueryWalkerBuilder; } });
|
|
31
|
+
var malloy_to_stable_query_1 = require("./malloy-to-stable-query");
|
|
32
|
+
Object.defineProperty(exports, "malloyToQuery", { enumerable: true, get: function () { return malloy_to_stable_query_1.malloyToQuery; } });
|
|
31
33
|
//# sourceMappingURL=index.js.map
|
|
@@ -1369,7 +1369,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
1369
1369
|
const fieldNameCx = fcx.fieldName();
|
|
1370
1370
|
if (fieldNameCx) {
|
|
1371
1371
|
return this.astAt(new ast.AccessModifierFieldReference([
|
|
1372
|
-
this.astAt(
|
|
1372
|
+
this.astAt(this.getFieldName(fieldNameCx), fcx),
|
|
1373
1373
|
]), fieldNameCx);
|
|
1374
1374
|
}
|
|
1375
1375
|
const wildcardCx = fcx.collectionWildCard();
|
|
@@ -66,7 +66,10 @@ export declare class MalloyToQuery extends AbstractParseTreeVisitor<Node> implem
|
|
|
66
66
|
field: Malloy.Field;
|
|
67
67
|
} | null;
|
|
68
68
|
getFieldExpression(cx: parse.FieldExprContext): Malloy.Expression | null;
|
|
69
|
-
|
|
69
|
+
stripQuote(s: string, q: string): string;
|
|
70
|
+
getFilterString(cx: parse.FilterStringContext): string | null;
|
|
71
|
+
getWhereExpr(cx: parse.FieldExprContext): Malloy.Where | null;
|
|
72
|
+
getWhere(whereCx: parse.WhereStatementContext): Malloy.Where[] | null;
|
|
70
73
|
protected combineAnnotations(...a: (Malloy.Annotation[] | undefined)[]): Malloy.Annotation[] | undefined;
|
|
71
74
|
}
|
|
72
75
|
export declare function malloyToQuery(code: string): {
|
|
@@ -36,8 +36,8 @@ const parse_log_1 = require("./parse-log");
|
|
|
36
36
|
const parse_utils_1 = require("./parse-utils");
|
|
37
37
|
const malloy_types_1 = require("../model/malloy_types");
|
|
38
38
|
const run_malloy_parser_1 = require("./run-malloy-parser");
|
|
39
|
-
const core_1 = require("../api/core");
|
|
40
39
|
const utils_1 = require("./utils");
|
|
40
|
+
const util_1 = require("../api/util");
|
|
41
41
|
const MLQs = 'Malloy query documents';
|
|
42
42
|
/**
|
|
43
43
|
* ANTLR visitor pattern parse tree traversal. Generates a Malloy
|
|
@@ -626,11 +626,80 @@ class MalloyToQuery extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor
|
|
|
626
626
|
}
|
|
627
627
|
return null;
|
|
628
628
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
629
|
+
stripQuote(s, q) {
|
|
630
|
+
return s.slice(s.indexOf(q) + q.length, s.lastIndexOf(q));
|
|
631
|
+
}
|
|
632
|
+
getFilterString(cx) {
|
|
633
|
+
const trip = cx.tripFilterString();
|
|
634
|
+
const tick = cx.tickFilterString();
|
|
635
|
+
if (trip) {
|
|
636
|
+
const bq3 = trip.BQ3_FILTER();
|
|
637
|
+
const dq3 = trip.DQ3_FILTER();
|
|
638
|
+
const sq3 = trip.SQ3_FILTER();
|
|
639
|
+
if (bq3) {
|
|
640
|
+
return this.stripQuote(bq3.text, '```');
|
|
641
|
+
}
|
|
642
|
+
else if (dq3) {
|
|
643
|
+
return this.stripQuote(dq3.text, '"""');
|
|
644
|
+
}
|
|
645
|
+
else if (sq3) {
|
|
646
|
+
return this.stripQuote(sq3.text, "'''");
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
else if (tick) {
|
|
650
|
+
const bq = tick.BQ_FILTER();
|
|
651
|
+
const dq = tick.DQ_FILTER();
|
|
652
|
+
const sq = tick.SQ_FILTER();
|
|
653
|
+
if (bq) {
|
|
654
|
+
return this.stripQuote(bq.text, '`');
|
|
655
|
+
}
|
|
656
|
+
else if (dq) {
|
|
657
|
+
return this.stripQuote(dq.text, '"');
|
|
658
|
+
}
|
|
659
|
+
else if (sq) {
|
|
660
|
+
return this.stripQuote(sq.text, "'");
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
return null;
|
|
664
|
+
}
|
|
665
|
+
getWhereExpr(cx) {
|
|
666
|
+
if (cx instanceof parse.ExprCompareContext) {
|
|
667
|
+
if (cx.compareOp().MATCH()) {
|
|
668
|
+
const lhs = cx.fieldExpr()[0];
|
|
669
|
+
const rhs = cx.fieldExpr()[1];
|
|
670
|
+
if (lhs instanceof parse.ExprFieldPathContext &&
|
|
671
|
+
rhs instanceof parse.ExprLiteralContext) {
|
|
672
|
+
const { path, name } = this.getFieldPath(lhs.fieldPath());
|
|
673
|
+
const literal = rhs.literal();
|
|
674
|
+
if (literal instanceof parse.FilterString_stubContext) {
|
|
675
|
+
const stringFilter = this.getFilterString(literal.filterString());
|
|
676
|
+
if (stringFilter === null)
|
|
677
|
+
return null;
|
|
678
|
+
return {
|
|
679
|
+
filter: {
|
|
680
|
+
kind: 'filter_string',
|
|
681
|
+
field_reference: {
|
|
682
|
+
name,
|
|
683
|
+
path,
|
|
684
|
+
},
|
|
685
|
+
filter: stringFilter,
|
|
686
|
+
},
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
this.notAllowed(cx, 'Filters other than comparisons with filter strings');
|
|
632
693
|
return null;
|
|
633
694
|
}
|
|
695
|
+
getWhere(whereCx) {
|
|
696
|
+
const exprs = whereCx.filterClauseList().fieldExpr();
|
|
697
|
+
const where = exprs.map(exprCx => this.getWhereExpr(exprCx));
|
|
698
|
+
if (where.some(w => w === null)) {
|
|
699
|
+
return null;
|
|
700
|
+
}
|
|
701
|
+
return where;
|
|
702
|
+
}
|
|
634
703
|
combineAnnotations(...a) {
|
|
635
704
|
const annotations = a.flatMap(a => a !== null && a !== void 0 ? a : []);
|
|
636
705
|
return annotations.length > 0 ? annotations : undefined;
|
|
@@ -644,7 +713,7 @@ function malloyToQuery(code) {
|
|
|
644
713
|
const parse = (0, run_malloy_parser_1.runMalloyParser)(code, url, sourceInfo, logger);
|
|
645
714
|
const secondPass = new MalloyToQuery(parse, logger);
|
|
646
715
|
const query = secondPass.visit(parse.root);
|
|
647
|
-
const logs = (0,
|
|
716
|
+
const logs = (0, util_1.mapLogs)(logger.getLog(), url);
|
|
648
717
|
if (query === null) {
|
|
649
718
|
return { logs };
|
|
650
719
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MALLOY_VERSION = "0.0.
|
|
1
|
+
export declare const MALLOY_VERSION = "0.0.244";
|
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.244';
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.244-dev250318232227",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
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"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@malloydata/malloy-filter": "^0.0.
|
|
45
|
-
"@malloydata/malloy-interfaces": "^0.0.
|
|
46
|
-
"@malloydata/malloy-tag": "^0.0.
|
|
44
|
+
"@malloydata/malloy-filter": "^0.0.244-dev250318232227",
|
|
45
|
+
"@malloydata/malloy-interfaces": "^0.0.244-dev250318232227",
|
|
46
|
+
"@malloydata/malloy-tag": "^0.0.244-dev250318232227",
|
|
47
47
|
"antlr4ts": "^0.5.0-alpha.4",
|
|
48
48
|
"assert": "^2.0.0",
|
|
49
49
|
"jest-diff": "^29.6.2",
|