@malloydata/malloy 0.0.1 → 0.0.3
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/README.md +12 -11
- package/dist/dialect/dialect.d.ts +1 -1
- package/dist/dialect/dialect.js +13 -0
- package/dist/dialect/duckdb.d.ts +1 -1
- package/dist/dialect/duckdb.js +35 -37
- package/dist/dialect/postgres.d.ts +1 -1
- package/dist/dialect/postgres.js +15 -8
- package/dist/dialect/standardsql.js +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- 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 +24 -39
- package/dist/lang/ast/ast-main.d.ts +14 -14
- package/dist/lang/ast/ast-main.js +36 -45
- 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 +43 -41
- package/dist/lang/field-space.js +115 -135
- package/dist/lang/lib/Malloy/MalloyLexer.d.ts +108 -106
- package/dist/lang/lib/Malloy/MalloyLexer.js +1019 -1006
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +581 -590
- package/dist/lang/lib/Malloy/MalloyParser.js +1141 -1202
- package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +2015 -0
- package/dist/lang/lib/Malloy/MalloyParserListener.js +4 -0
- package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +1269 -0
- package/dist/lang/lib/Malloy/MalloyParserVisitor.js +4 -0
- package/dist/lang/parse-to-ast.d.ts +3 -4
- package/dist/lang/parse-to-ast.js +1 -1
- package/dist/lang/parse-tree-walkers/document-completion-walker.js +2 -0
- package/dist/lang/parse-tree-walkers/explore-query-walker.d.ts +2 -2
- package/dist/lang/space-field.d.ts +10 -7
- package/dist/lang/space-field.js +11 -4
- package/dist/lang/test/field-symbols.spec.js +2 -2
- package/dist/lang/test/parse.spec.js +16 -1
- package/dist/lang/test/test-translator.js +1 -1
- package/dist/malloy.d.ts +1 -1
- package/dist/malloy.js +11 -5
- package/dist/md5.d.ts +1 -0
- package/dist/md5.js +30 -0
- package/dist/model/malloy_query.js +10 -6
- package/dist/model/malloy_types.d.ts +15 -2
- package/package.json +9 -13
- package/dist/dialect/dialect-map.d.ts +0 -3
- package/dist/dialect/dialect-map.js +0 -33
- package/dist/model/malloy-query.d.ts +0 -313
- package/dist/model/malloy-query.js +0 -2603
- package/dist/model/malloy-types.d.ts +0 -404
- package/dist/model/malloy-types.js +0 -242
- package/dist/model/sql-block.d.ts +0 -11
- package/dist/model/sql-block.js +0 -38
- package/dist/runtime-types.d.ts +0 -116
- package/dist/runtime-types.js +0 -40
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { ParserRuleContext } from "antlr4ts";
|
|
2
2
|
import type { ParseTree } from "antlr4ts/tree";
|
|
3
3
|
import { AbstractParseTreeVisitor } from "antlr4ts/tree/AbstractParseTreeVisitor";
|
|
4
|
-
import {
|
|
4
|
+
import { MalloyParserVisitor } from "./lib/Malloy/MalloyParserVisitor";
|
|
5
5
|
import * as parse from "./lib/Malloy/MalloyParser";
|
|
6
6
|
import * as ast from "./ast";
|
|
7
|
-
import { MessageLogger } from "./parse-log";
|
|
7
|
+
import { LogSeverity, MessageLogger } from "./parse-log";
|
|
8
8
|
import { MalloyParseRoot } from "./parse-malloy";
|
|
9
|
-
import { LogSeverity } from "./parse-log";
|
|
10
9
|
/**
|
|
11
10
|
* ANTLR visitor pattern parse tree traversal. Generates a Malloy
|
|
12
11
|
* AST from an ANTLR parse tree.
|
|
13
12
|
*/
|
|
14
|
-
export declare class MalloyToAST extends AbstractParseTreeVisitor<ast.MalloyElement> implements
|
|
13
|
+
export declare class MalloyToAST extends AbstractParseTreeVisitor<ast.MalloyElement> implements MalloyParserVisitor<ast.MalloyElement> {
|
|
15
14
|
readonly parse: MalloyParseRoot;
|
|
16
15
|
readonly msgLog: MessageLogger;
|
|
17
16
|
constructor(parse: MalloyParseRoot, msgLog: MessageLogger);
|
|
@@ -917,7 +917,7 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
917
917
|
return this.visitSQLStatementDef(pcx.sqlStatementDef());
|
|
918
918
|
}
|
|
919
919
|
visitSQLStatementDef(pcx) {
|
|
920
|
-
const commands = pcx.
|
|
920
|
+
const commands = pcx.SQL_STRING().text;
|
|
921
921
|
const sqlStmt = new ast.SQLStatement({
|
|
922
922
|
select: commands.slice(2, commands.length - 2),
|
|
923
923
|
connection: this.optionalText(pcx.connectionName()),
|
|
@@ -26,6 +26,7 @@ const EXPLORE_PROPERTIES = [
|
|
|
26
26
|
"accept",
|
|
27
27
|
"except",
|
|
28
28
|
"query",
|
|
29
|
+
"declare",
|
|
29
30
|
];
|
|
30
31
|
const QUERY_PROPERTIES = [
|
|
31
32
|
"group_by",
|
|
@@ -38,6 +39,7 @@ const QUERY_PROPERTIES = [
|
|
|
38
39
|
"where",
|
|
39
40
|
"having",
|
|
40
41
|
"nest",
|
|
42
|
+
"declare",
|
|
41
43
|
];
|
|
42
44
|
const MODEL_PROPERTIES = ["source", "explore", "query", "sql"];
|
|
43
45
|
class DocumentCompletionWalker {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommonTokenStream } from "antlr4ts";
|
|
2
2
|
import { ParseTree } from "antlr4ts/tree";
|
|
3
|
-
import {
|
|
3
|
+
import { MalloyParserListener } from "../lib/Malloy/MalloyParserListener";
|
|
4
4
|
declare type SimpleRange = [number | undefined, number | undefined];
|
|
5
5
|
export interface FilterRef {
|
|
6
6
|
text: string;
|
|
@@ -19,7 +19,7 @@ export interface ExploreClauseRef {
|
|
|
19
19
|
filterLists: FilterList[];
|
|
20
20
|
range: SimpleRange;
|
|
21
21
|
}
|
|
22
|
-
export declare class ExploreQueryWalker implements
|
|
22
|
+
export declare class ExploreQueryWalker implements MalloyParserListener {
|
|
23
23
|
tokens: CommonTokenStream;
|
|
24
24
|
exploreClauseRefs: ExploreClauseRef[];
|
|
25
25
|
currentExploreClauseRef: ExploreClauseRef | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as model from "../model/malloy_types";
|
|
2
|
-
import { FieldSpace,
|
|
2
|
+
import { FieldSpace, DynamicSpace, QuerySpace } from "./field-space";
|
|
3
3
|
import { FieldValueType, FieldDeclaration, TurtleDecl, HasParameter, Join, FieldReference } from "./ast";
|
|
4
4
|
interface FieldType {
|
|
5
5
|
type: FieldValueType;
|
|
@@ -28,7 +28,7 @@ export declare class AbstractParameter extends SpaceParam {
|
|
|
28
28
|
export declare abstract class SpaceField extends SpaceEntry {
|
|
29
29
|
readonly refType = "field";
|
|
30
30
|
protected fieldTypeFromFieldDef(def: model.FieldDef): FieldType;
|
|
31
|
-
getQueryFieldDef(_fs:
|
|
31
|
+
getQueryFieldDef(_fs: FieldSpace): model.QueryFieldDef | undefined;
|
|
32
32
|
fieldDef(): model.FieldDef | undefined;
|
|
33
33
|
}
|
|
34
34
|
export declare class RenameSpaceField extends SpaceField {
|
|
@@ -43,7 +43,7 @@ export declare class WildSpaceField extends SpaceField {
|
|
|
43
43
|
readonly wildText: string;
|
|
44
44
|
constructor(wildText: string);
|
|
45
45
|
type(): FieldType;
|
|
46
|
-
getQueryFieldDef(_fs:
|
|
46
|
+
getQueryFieldDef(_fs: FieldSpace): model.QueryFieldDef;
|
|
47
47
|
}
|
|
48
48
|
export declare class StructSpaceField extends SpaceField {
|
|
49
49
|
protected sourceDef: model.StructDef;
|
|
@@ -67,7 +67,8 @@ export declare class ColumnSpaceField extends SpaceField {
|
|
|
67
67
|
export declare abstract class QueryField extends SpaceField {
|
|
68
68
|
protected inSpace: FieldSpace;
|
|
69
69
|
constructor(inSpace: FieldSpace);
|
|
70
|
-
getQueryFieldDef(
|
|
70
|
+
abstract getQueryFieldDef(fs: FieldSpace): model.QueryFieldDef | undefined;
|
|
71
|
+
abstract fieldDef(): model.FieldDef;
|
|
71
72
|
type(): FieldType;
|
|
72
73
|
}
|
|
73
74
|
export declare class QueryFieldAST extends QueryField {
|
|
@@ -76,6 +77,7 @@ export declare class QueryFieldAST extends QueryField {
|
|
|
76
77
|
renameAs?: string;
|
|
77
78
|
nestParent?: QuerySpace;
|
|
78
79
|
constructor(fs: FieldSpace, turtle: TurtleDecl, name: string);
|
|
80
|
+
getQueryFieldDef(fs: FieldSpace): model.QueryFieldDef;
|
|
79
81
|
fieldDef(): model.TurtleDef;
|
|
80
82
|
}
|
|
81
83
|
export declare class QueryFieldStruct extends QueryField {
|
|
@@ -83,6 +85,7 @@ export declare class QueryFieldStruct extends QueryField {
|
|
|
83
85
|
constructor(fs: FieldSpace, turtleDef: model.TurtleDef);
|
|
84
86
|
rename(name: string): void;
|
|
85
87
|
fieldDef(): model.TurtleDef;
|
|
88
|
+
getQueryFieldDef(_fs: FieldSpace): model.QueryFieldDef | undefined;
|
|
86
89
|
}
|
|
87
90
|
/**
|
|
88
91
|
* FilteredAliasedName
|
|
@@ -96,13 +99,13 @@ export declare class FANSPaceField extends SpaceField {
|
|
|
96
99
|
name(): string;
|
|
97
100
|
private filtersPresent;
|
|
98
101
|
fieldDef(): model.FieldDef | undefined;
|
|
99
|
-
getQueryFieldDef(_fs:
|
|
102
|
+
getQueryFieldDef(_fs: FieldSpace): model.QueryFieldDef;
|
|
100
103
|
type(): FieldType;
|
|
101
104
|
}
|
|
102
105
|
export declare class ReferenceField extends SpaceField {
|
|
103
106
|
readonly fieldRef: FieldReference;
|
|
104
107
|
constructor(fieldRef: FieldReference);
|
|
105
|
-
getQueryFieldDef(fs:
|
|
108
|
+
getQueryFieldDef(fs: FieldSpace): model.QueryFieldDef | undefined;
|
|
106
109
|
type(): FieldType;
|
|
107
110
|
}
|
|
108
111
|
export declare class ExpressionFieldFromAst extends SpaceField {
|
|
@@ -113,7 +116,7 @@ export declare class ExpressionFieldFromAst extends SpaceField {
|
|
|
113
116
|
constructor(space: DynamicSpace, exprDef: FieldDeclaration);
|
|
114
117
|
get name(): string;
|
|
115
118
|
fieldDef(): model.FieldDef;
|
|
116
|
-
getQueryFieldDef(fs:
|
|
119
|
+
getQueryFieldDef(fs: FieldSpace): model.QueryFieldDef;
|
|
117
120
|
type(): FieldType;
|
|
118
121
|
}
|
|
119
122
|
export {};
|
package/dist/lang/space-field.js
CHANGED
|
@@ -176,9 +176,6 @@ class QueryField extends SpaceField {
|
|
|
176
176
|
super();
|
|
177
177
|
this.inSpace = inSpace;
|
|
178
178
|
}
|
|
179
|
-
getQueryFieldDef(_fs) {
|
|
180
|
-
return this.fieldDef();
|
|
181
|
-
}
|
|
182
179
|
type() {
|
|
183
180
|
return { type: "turtle" };
|
|
184
181
|
}
|
|
@@ -190,6 +187,13 @@ class QueryFieldAST extends QueryField {
|
|
|
190
187
|
this.turtle = turtle;
|
|
191
188
|
this.name = name;
|
|
192
189
|
}
|
|
190
|
+
getQueryFieldDef(fs) {
|
|
191
|
+
const def = this.turtle.getFieldDef(fs, this.nestParent);
|
|
192
|
+
if (this.renameAs) {
|
|
193
|
+
def.as = this.renameAs;
|
|
194
|
+
}
|
|
195
|
+
return def;
|
|
196
|
+
}
|
|
193
197
|
fieldDef() {
|
|
194
198
|
const def = this.turtle.getFieldDef(this.inSpace, this.nestParent);
|
|
195
199
|
if (this.renameAs) {
|
|
@@ -213,6 +217,9 @@ class QueryFieldStruct extends QueryField {
|
|
|
213
217
|
fieldDef() {
|
|
214
218
|
return this.turtleDef;
|
|
215
219
|
}
|
|
220
|
+
getQueryFieldDef(_fs) {
|
|
221
|
+
return this.fieldDef();
|
|
222
|
+
}
|
|
216
223
|
}
|
|
217
224
|
exports.QueryFieldStruct = QueryFieldStruct;
|
|
218
225
|
/**
|
|
@@ -297,7 +304,7 @@ class ReferenceField extends SpaceField {
|
|
|
297
304
|
}
|
|
298
305
|
getQueryFieldDef(fs) {
|
|
299
306
|
// Lookup string and generate error if it isn't defined.
|
|
300
|
-
const check = this.fieldRef.getField(fs
|
|
307
|
+
const check = this.fieldRef.getField(fs);
|
|
301
308
|
if (check.error) {
|
|
302
309
|
this.fieldRef.log(check.error);
|
|
303
310
|
}
|
|
@@ -25,7 +25,7 @@ describe("structdef comprehension", () => {
|
|
|
25
25
|
type: "struct",
|
|
26
26
|
name: "test",
|
|
27
27
|
dialect: "standardsql",
|
|
28
|
-
structSource: { type: "table" },
|
|
28
|
+
structSource: { type: "table", tablePath: "test" },
|
|
29
29
|
structRelationship: { type: "basetable", connectionName: "test" },
|
|
30
30
|
fields: [field],
|
|
31
31
|
};
|
|
@@ -122,7 +122,7 @@ describe("structdef comprehension", () => {
|
|
|
122
122
|
{ type: "field", path: "t.a" },
|
|
123
123
|
],
|
|
124
124
|
},
|
|
125
|
-
structSource: { type: "table" },
|
|
125
|
+
structSource: { type: "table", tablePath: "t" },
|
|
126
126
|
fields: [{ type: "string", name: "a" }],
|
|
127
127
|
};
|
|
128
128
|
const struct = mkStructDef(field);
|
|
@@ -233,7 +233,7 @@ class BetaExpression extends Testable {
|
|
|
233
233
|
const aStruct = this.internalModel.contents.ab;
|
|
234
234
|
if (aStruct.type === "struct") {
|
|
235
235
|
const tstFS = new field_space_1.StaticSpace(aStruct);
|
|
236
|
-
const exprDef = exprAst.getExpression(
|
|
236
|
+
const exprDef = exprAst.getExpression(tstFS);
|
|
237
237
|
if (inspectCompile) {
|
|
238
238
|
console.log("EXPRESSION: ", (0, test_translator_1.pretty)(exprDef));
|
|
239
239
|
}
|
|
@@ -1124,6 +1124,21 @@ describe("error handling", () => {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
`).compileToFailWith("Output already has a field named 'astr'");
|
|
1126
1126
|
});
|
|
1127
|
+
test("rejoin a query is renamed", modelOK(`
|
|
1128
|
+
source: querySrc is from(
|
|
1129
|
+
table('malloytest.flights')->{
|
|
1130
|
+
group_by: origin
|
|
1131
|
+
nest: nested is { group_by: destination }
|
|
1132
|
+
}
|
|
1133
|
+
)
|
|
1134
|
+
|
|
1135
|
+
source: refineQuerySrc is querySrc {
|
|
1136
|
+
join_one: rejoin is querySrc on 7=8
|
|
1137
|
+
query: broken is {
|
|
1138
|
+
group_by: rejoin.nested.destination
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
`));
|
|
1127
1142
|
});
|
|
1128
1143
|
function getSelectOneStruct(sqlBlock) {
|
|
1129
1144
|
return {
|
|
@@ -27,7 +27,7 @@ const mockSchema = {
|
|
|
27
27
|
type: "struct",
|
|
28
28
|
name: "aTable",
|
|
29
29
|
dialect: "standardsql",
|
|
30
|
-
structSource: { type: "table" },
|
|
30
|
+
structSource: { type: "table", tablePath: "aTable" },
|
|
31
31
|
structRelationship: { type: "basetable", connectionName: "test" },
|
|
32
32
|
fields: [
|
|
33
33
|
{ type: "string", name: "astr" },
|
package/dist/malloy.d.ts
CHANGED
|
@@ -218,7 +218,7 @@ export declare class PreparedQuery {
|
|
|
218
218
|
get preparedResult(): PreparedResult;
|
|
219
219
|
get dialect(): string;
|
|
220
220
|
}
|
|
221
|
-
export declare function
|
|
221
|
+
export declare function parseTableURI(tableURI: string): {
|
|
222
222
|
connectionName?: string;
|
|
223
223
|
tablePath: string;
|
|
224
224
|
};
|
package/dist/malloy.js
CHANGED
|
@@ -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.CSVWriter = exports.JSONWriter = exports.DataWriter = exports.DataRecord = exports.DataArray = exports.Result = exports.ExploreMaterializer = exports.SQLBlockMaterializer = exports.PreparedResultMaterializer = exports.QueryMaterializer = exports.ModelMaterializer = exports.SingleConnectionRuntime = exports.ConnectionRuntime = exports.Runtime = exports.ExploreField = exports.JoinRelationship = exports.QueryField = exports.Query = exports.StringField = exports.BooleanField = exports.NumberField = exports.TimestampField = exports.DateField = exports.TimestampTimeframe = exports.DateTimeframe = exports.AtomicField = exports.AtomicFieldType = exports.Explore = exports.SourceRelationship = exports.FixedConnectionMap = exports.InMemoryURLReader = exports.EmptyURLReader = exports.PreparedResult = exports.DocumentCompletion = exports.DocumentSymbol = exports.DocumentPosition = exports.DocumentRange = exports.DocumentHighlight = exports.Parse = exports.
|
|
15
|
+
exports.CSVWriter = exports.JSONWriter = exports.DataWriter = exports.DataRecord = exports.DataArray = exports.Result = exports.ExploreMaterializer = exports.SQLBlockMaterializer = exports.PreparedResultMaterializer = exports.QueryMaterializer = exports.ModelMaterializer = exports.SingleConnectionRuntime = exports.ConnectionRuntime = exports.Runtime = exports.ExploreField = exports.JoinRelationship = exports.QueryField = exports.Query = exports.StringField = exports.BooleanField = exports.NumberField = exports.TimestampField = exports.DateField = exports.TimestampTimeframe = exports.DateTimeframe = exports.AtomicField = exports.AtomicFieldType = exports.Explore = exports.SourceRelationship = exports.FixedConnectionMap = exports.InMemoryURLReader = exports.EmptyURLReader = exports.PreparedResult = exports.DocumentCompletion = exports.DocumentSymbol = exports.DocumentPosition = exports.DocumentRange = exports.DocumentHighlight = exports.Parse = exports.parseTableURI = exports.PreparedQuery = exports.Model = exports.MalloyError = exports.Malloy = void 0;
|
|
16
16
|
const lang_1 = require("./lang");
|
|
17
17
|
const model_1 = require("./model");
|
|
18
18
|
class Malloy {
|
|
@@ -99,7 +99,7 @@ class Malloy {
|
|
|
99
99
|
// collect tables by connection name since there may be multiple connections
|
|
100
100
|
const tablesByConnection = new Map();
|
|
101
101
|
for (const connectionTableString of result.tables) {
|
|
102
|
-
const { connectionName } =
|
|
102
|
+
const { connectionName } = parseTableURI(connectionTableString);
|
|
103
103
|
let connectionToTablesMap = tablesByConnection.get(connectionName);
|
|
104
104
|
if (!connectionToTablesMap) {
|
|
105
105
|
connectionToTablesMap = [connectionTableString];
|
|
@@ -136,6 +136,9 @@ class Malloy {
|
|
|
136
136
|
const sqlRefsByConnection = new Map();
|
|
137
137
|
for (const missingSQLSchemaRef of result.sqlStructs) {
|
|
138
138
|
const connectionName = missingSQLSchemaRef.connection;
|
|
139
|
+
// if (connectionName === undefined) {
|
|
140
|
+
// throw new Error("Oops have not made it required here yet...");
|
|
141
|
+
// }
|
|
139
142
|
let connectionToSQLReferencesMap = sqlRefsByConnection.get(connectionName);
|
|
140
143
|
if (!connectionToSQLReferencesMap) {
|
|
141
144
|
connectionToSQLReferencesMap = [missingSQLSchemaRef];
|
|
@@ -434,8 +437,8 @@ class PreparedQuery {
|
|
|
434
437
|
}
|
|
435
438
|
}
|
|
436
439
|
exports.PreparedQuery = PreparedQuery;
|
|
437
|
-
function
|
|
438
|
-
const [firstPart, secondPart] =
|
|
440
|
+
function parseTableURI(tableURI) {
|
|
441
|
+
const [firstPart, secondPart] = tableURI.split(":");
|
|
439
442
|
if (secondPart) {
|
|
440
443
|
return { connectionName: firstPart, tablePath: secondPart };
|
|
441
444
|
}
|
|
@@ -443,7 +446,7 @@ function parseTableURL(tableURL) {
|
|
|
443
446
|
return { tablePath: firstPart };
|
|
444
447
|
}
|
|
445
448
|
}
|
|
446
|
-
exports.
|
|
449
|
+
exports.parseTableURI = parseTableURI;
|
|
447
450
|
/**
|
|
448
451
|
* A parsed Malloy document.
|
|
449
452
|
*/
|
|
@@ -2066,6 +2069,9 @@ class DataTimestamp extends ScalarData {
|
|
|
2066
2069
|
if (this._value instanceof Date) {
|
|
2067
2070
|
return this._value;
|
|
2068
2071
|
}
|
|
2072
|
+
else if (typeof this._value === "number") {
|
|
2073
|
+
return new Date(super.value);
|
|
2074
|
+
}
|
|
2069
2075
|
else if (typeof this._value !== "string") {
|
|
2070
2076
|
return new Date(this._value.value);
|
|
2071
2077
|
}
|
package/dist/md5.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const md5: (val: string) => string;
|
package/dist/md5.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.md5 = void 0;
|
|
27
|
+
const crypto = __importStar(require("crypto"));
|
|
28
|
+
const md5 = (val) => crypto.createHash("md5").update(val).digest("hex");
|
|
29
|
+
exports.md5 = md5;
|
|
30
|
+
//# sourceMappingURL=md5.js.map
|
|
@@ -21,7 +21,6 @@ const standardsql_1 = require("../dialect/standardsql");
|
|
|
21
21
|
const dialect_1 = require("../dialect");
|
|
22
22
|
const malloy_types_1 = require("./malloy_types");
|
|
23
23
|
const utils_1 = require("./utils");
|
|
24
|
-
const malloy_1 = require("../malloy");
|
|
25
24
|
const md5_1 = __importDefault(require("md5"));
|
|
26
25
|
// quote a string for SQL use. Perhaps should be in dialect.
|
|
27
26
|
function generateSQLStringLiteral(sourceString) {
|
|
@@ -769,7 +768,7 @@ class FieldInstanceResult {
|
|
|
769
768
|
addStructToJoin(qs, query, mayNeedUniqueKey, joinStack) {
|
|
770
769
|
var _a;
|
|
771
770
|
const name = qs.getIdentifier();
|
|
772
|
-
// we're already chasing the
|
|
771
|
+
// we're already chasing the dependency for this join.
|
|
773
772
|
if (joinStack.indexOf(name) !== -1) {
|
|
774
773
|
return;
|
|
775
774
|
}
|
|
@@ -1264,6 +1263,12 @@ class QueryQuery extends QueryField {
|
|
|
1264
1263
|
switch (expr.function) {
|
|
1265
1264
|
case "now":
|
|
1266
1265
|
break;
|
|
1266
|
+
case "div":
|
|
1267
|
+
expressions.push(expr.denominator);
|
|
1268
|
+
expressions.push(expr.numerator);
|
|
1269
|
+
break;
|
|
1270
|
+
case "timeLiteral":
|
|
1271
|
+
break;
|
|
1267
1272
|
case "timeDiff":
|
|
1268
1273
|
expressions.push(expr.left.value, expr.right.value);
|
|
1269
1274
|
break;
|
|
@@ -1570,8 +1575,7 @@ class QueryQuery extends QueryField {
|
|
|
1570
1575
|
type: "basetable",
|
|
1571
1576
|
connectionName: this.parent.connectionName,
|
|
1572
1577
|
},
|
|
1573
|
-
|
|
1574
|
-
structSource: { type: "table" },
|
|
1578
|
+
structSource: { type: "query_result" },
|
|
1575
1579
|
resultMetadata: this.getResultMetadata(this.rootResult),
|
|
1576
1580
|
type: "struct",
|
|
1577
1581
|
};
|
|
@@ -2353,7 +2357,7 @@ FROM ${resultStage}\n`);
|
|
|
2353
2357
|
type: "basetable",
|
|
2354
2358
|
connectionName: this.parent.connectionName,
|
|
2355
2359
|
},
|
|
2356
|
-
structSource: { type: "
|
|
2360
|
+
structSource: { type: "query_result" },
|
|
2357
2361
|
};
|
|
2358
2362
|
}
|
|
2359
2363
|
}
|
|
@@ -2648,7 +2652,7 @@ class QueryStruct extends QueryNode {
|
|
|
2648
2652
|
structSourceSQL(stageWriter) {
|
|
2649
2653
|
switch (this.fieldDef.structSource.type) {
|
|
2650
2654
|
case "table": {
|
|
2651
|
-
const
|
|
2655
|
+
const tablePath = this.fieldDef.structSource.tablePath;
|
|
2652
2656
|
return this.dialect.quoteTablePath(tablePath);
|
|
2653
2657
|
}
|
|
2654
2658
|
case "sql":
|
|
@@ -173,7 +173,18 @@ export interface RegexpMatchFragment extends DialectFragmentBase {
|
|
|
173
173
|
expr: Expr;
|
|
174
174
|
regexp: string;
|
|
175
175
|
}
|
|
176
|
-
export
|
|
176
|
+
export interface DivFragment extends DialectFragmentBase {
|
|
177
|
+
function: "div";
|
|
178
|
+
numerator: Expr;
|
|
179
|
+
denominator: Expr;
|
|
180
|
+
}
|
|
181
|
+
export interface TimeLiteralFragment extends DialectFragmentBase {
|
|
182
|
+
function: "timeLiteral";
|
|
183
|
+
literal: string;
|
|
184
|
+
literalType: TimeFieldType;
|
|
185
|
+
timezone: string;
|
|
186
|
+
}
|
|
187
|
+
export declare type DialectFragment = DivFragment | TimeLiteralFragment | NowFragment | TimeDeltaFragment | TimeDiffFragment | TimeTruncFragment | TypecastFragment | TimeExtractFragment | RegexpMatchFragment;
|
|
177
188
|
export declare type Fragment = string | ApplyFragment | ApplyValueFragment | FieldFragment | ParameterFragment | FilterFragment | AggregateFragment | UngroupFragment | DialectFragment;
|
|
178
189
|
export declare type Expr = Fragment[];
|
|
179
190
|
export interface TypedValue {
|
|
@@ -378,7 +389,7 @@ interface SubquerySource {
|
|
|
378
389
|
/** where does the struct come from? */
|
|
379
390
|
export declare type StructSource = {
|
|
380
391
|
type: "table";
|
|
381
|
-
tablePath
|
|
392
|
+
tablePath: string;
|
|
382
393
|
} | {
|
|
383
394
|
type: "nested";
|
|
384
395
|
} | {
|
|
@@ -389,6 +400,8 @@ export declare type StructSource = {
|
|
|
389
400
|
} | {
|
|
390
401
|
type: "sql";
|
|
391
402
|
method: "nested" | "lastStage";
|
|
403
|
+
} | {
|
|
404
|
+
type: "query_result";
|
|
392
405
|
} | SubquerySource;
|
|
393
406
|
/** struct that is intrinsic to the table */
|
|
394
407
|
export interface StructDef extends NamedObject, ResultStructMetadata, Filtered {
|
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"license": "GPL-2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"homepage": "https://github.com/looker-open-source/malloy#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/looker-open-source/malloy"
|
|
11
|
+
},
|
|
7
12
|
"scripts": {
|
|
8
13
|
"test": "jest --config=../../jest.config.js",
|
|
9
|
-
"build-parser": "
|
|
14
|
+
"build-parser": "node src/lang/grammar/build_parser.js",
|
|
10
15
|
"testLang": "npm run test --testPathPattern=packages/malloy/src/lang",
|
|
11
16
|
"clean": "rm -rf src/lang/lib",
|
|
12
17
|
"build": "npm run build-parser && tsc --build",
|
|
@@ -15,22 +20,13 @@
|
|
|
15
20
|
"dependencies": {
|
|
16
21
|
"antlr4ts": "^0.5.0-alpha.4",
|
|
17
22
|
"assert": "^2.0.0",
|
|
18
|
-
"blueimp-md5": "^2.19.0",
|
|
19
23
|
"lodash": "^4.17.20",
|
|
20
24
|
"luxon": "^1.26.0",
|
|
21
|
-
"
|
|
25
|
+
"md5": "^2.3.0"
|
|
22
26
|
},
|
|
23
27
|
"devDependencies": {
|
|
24
28
|
"@types/lodash": "^4.14.165",
|
|
25
29
|
"@types/luxon": "^1.26.4",
|
|
26
|
-
"antlr4ts-cli": "^0.5.0-alpha.4"
|
|
27
|
-
"path": "^0.12.7"
|
|
28
|
-
},
|
|
29
|
-
"cross-os": {
|
|
30
|
-
"build-parser": {
|
|
31
|
-
"darwin": "sh build-parser.sh",
|
|
32
|
-
"linux": "sh build-parser.sh",
|
|
33
|
-
"win32": "build-parser.cmd"
|
|
34
|
-
}
|
|
30
|
+
"antlr4ts-cli": "^0.5.0-alpha.4"
|
|
35
31
|
}
|
|
36
32
|
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2021 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* This program is free software; you can redistribute it and/or
|
|
6
|
-
* modify it under the terms of the GNU General Public License
|
|
7
|
-
* version 2 as published by the Free Software Foundation.
|
|
8
|
-
*
|
|
9
|
-
* This program is distributed in the hope that it will be useful,
|
|
10
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
* GNU General Public License for more details.
|
|
13
|
-
*/
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.registerDialect = exports.getDialect = void 0;
|
|
16
|
-
const postgres_1 = require("./postgres");
|
|
17
|
-
const standardsql_1 = require("./standardsql");
|
|
18
|
-
const dialectMap = new Map();
|
|
19
|
-
function getDialect(name) {
|
|
20
|
-
const d = dialectMap.get(name);
|
|
21
|
-
if (d === undefined) {
|
|
22
|
-
throw new Error(`Unknown Dialect ${name}`);
|
|
23
|
-
}
|
|
24
|
-
return d;
|
|
25
|
-
}
|
|
26
|
-
exports.getDialect = getDialect;
|
|
27
|
-
function registerDialect(d) {
|
|
28
|
-
dialectMap.set(d.name, d);
|
|
29
|
-
}
|
|
30
|
-
exports.registerDialect = registerDialect;
|
|
31
|
-
registerDialect(new postgres_1.PostgresDialect());
|
|
32
|
-
registerDialect(new standardsql_1.StandardSQLDialect());
|
|
33
|
-
//# sourceMappingURL=dialect-map.js.map
|