@malloydata/malloy 0.0.2 → 0.0.4

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.
Files changed (67) hide show
  1. package/README.md +12 -11
  2. package/dist/dialect/duckdb.d.ts +1 -1
  3. package/dist/dialect/postgres.d.ts +1 -1
  4. package/dist/index.d.ts +4 -4
  5. package/dist/lang/ast/ast-expr.d.ts +0 -1
  6. package/dist/lang/field-space.d.ts +9 -7
  7. package/dist/lang/lib/Malloy/MalloyLexer.d.ts +108 -106
  8. package/dist/lang/lib/Malloy/MalloyLexer.js +1019 -1006
  9. package/dist/lang/lib/Malloy/MalloyParser.d.ts +581 -590
  10. package/dist/lang/lib/Malloy/MalloyParser.js +1141 -1202
  11. package/dist/lang/lib/Malloy/MalloyParserListener.d.ts +2015 -0
  12. package/dist/lang/lib/Malloy/MalloyParserListener.js +4 -0
  13. package/dist/lang/lib/Malloy/MalloyParserVisitor.d.ts +1269 -0
  14. package/dist/lang/lib/Malloy/MalloyParserVisitor.js +4 -0
  15. package/dist/lang/parse-to-ast.d.ts +3 -4
  16. package/dist/lang/parse-to-ast.js +1 -1
  17. package/dist/lang/parse-tree-walkers/document-completion-walker.js +2 -0
  18. package/dist/lang/parse-tree-walkers/explore-query-walker.d.ts +2 -2
  19. package/dist/malloy.d.ts +1 -1
  20. package/dist/md5.d.ts +1 -0
  21. package/dist/md5.js +30 -0
  22. package/dist/model/malloy_types.d.ts +3 -1
  23. package/package.json +9 -14
  24. package/dist/connection_utils.js +0 -56
  25. package/dist/dialect/dialect-map.d.ts +0 -3
  26. package/dist/dialect/dialect-map.js +0 -33
  27. package/dist/dialect/dialect.js +0 -77
  28. package/dist/dialect/dialect_map.js +0 -35
  29. package/dist/dialect/duckdb.js +0 -349
  30. package/dist/dialect/index.js +0 -27
  31. package/dist/dialect/postgres.js +0 -308
  32. package/dist/dialect/standardsql.js +0 -361
  33. package/dist/index.js +0 -47
  34. package/dist/lang/ast/apply-expr.js +0 -231
  35. package/dist/lang/ast/ast-expr.js +0 -1051
  36. package/dist/lang/ast/ast-main.js +0 -2086
  37. package/dist/lang/ast/ast-time-expr.js +0 -549
  38. package/dist/lang/ast/ast-types.js +0 -215
  39. package/dist/lang/ast/index.js +0 -34
  40. package/dist/lang/ast/time-utils.js +0 -94
  41. package/dist/lang/field-space.js +0 -629
  42. package/dist/lang/field-utils.js +0 -33
  43. package/dist/lang/index.js +0 -22
  44. package/dist/lang/parse-log.js +0 -41
  45. package/dist/lang/reference-list.js +0 -80
  46. package/dist/lang/space-field.js +0 -346
  47. package/dist/lang/test/document-help-context-walker.spec.js +0 -45
  48. package/dist/lang/test/document-symbol-walker.spec.js +0 -100
  49. package/dist/lang/test/field-symbols.spec.js +0 -172
  50. package/dist/lang/test/parse.spec.js +0 -1936
  51. package/dist/lang/test/test-translator.js +0 -334
  52. package/dist/lang/zone.js +0 -97
  53. package/dist/malloy.js +0 -2354
  54. package/dist/model/index.js +0 -34
  55. package/dist/model/malloy-query.d.ts +0 -313
  56. package/dist/model/malloy-query.js +0 -2603
  57. package/dist/model/malloy-types.d.ts +0 -404
  58. package/dist/model/malloy-types.js +0 -242
  59. package/dist/model/malloy_query.js +0 -2996
  60. package/dist/model/malloy_types.js +0 -283
  61. package/dist/model/sql-block.d.ts +0 -11
  62. package/dist/model/sql-block.js +0 -38
  63. package/dist/model/sql_block.js +0 -41
  64. package/dist/model/utils.js +0 -84
  65. package/dist/runtime-types.d.ts +0 -116
  66. package/dist/runtime-types.js +0 -40
  67. package/dist/runtime_types.js +0 -15
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // Generated from MalloyParser.g4 by ANTLR 4.9.0-SNAPSHOT
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=MalloyParserVisitor.js.map
@@ -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 { MalloyVisitor } from "./lib/Malloy/MalloyVisitor";
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 MalloyVisitor<ast.MalloyElement> {
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.sqlBlock().text;
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 { MalloyListener } from "../lib/Malloy/MalloyListener";
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 MalloyListener {
22
+ export declare class ExploreQueryWalker implements MalloyParserListener {
23
23
  tokens: CommonTokenStream;
24
24
  exploreClauseRefs: ExploreClauseRef[];
25
25
  currentExploreClauseRef: ExploreClauseRef | undefined;
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 parseTableURL(tableURL: string): {
221
+ export declare function parseTableURI(tableURI: string): {
222
222
  connectionName?: string;
223
223
  tablePath: string;
224
224
  };
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
@@ -389,7 +389,7 @@ interface SubquerySource {
389
389
  /** where does the struct come from? */
390
390
  export declare type StructSource = {
391
391
  type: "table";
392
- tablePath?: string;
392
+ tablePath: string;
393
393
  } | {
394
394
  type: "nested";
395
395
  } | {
@@ -400,6 +400,8 @@ export declare type StructSource = {
400
400
  } | {
401
401
  type: "sql";
402
402
  method: "nested" | "lastStage";
403
+ } | {
404
+ type: "query_result";
403
405
  } | SubquerySource;
404
406
  /** struct that is intrinsic to the table */
405
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.2",
3
+ "version": "0.0.4",
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": "cd src/lang/grammar && cross-os 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,23 +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
- "md5": "^2.3.0",
22
- "url": "^0.11.0"
25
+ "md5": "^2.3.0"
23
26
  },
24
27
  "devDependencies": {
25
28
  "@types/lodash": "^4.14.165",
26
29
  "@types/luxon": "^1.26.4",
27
- "antlr4ts-cli": "^0.5.0-alpha.4",
28
- "path": "^0.12.7"
29
- },
30
- "cross-os": {
31
- "build-parser": {
32
- "darwin": "sh build-parser.sh",
33
- "linux": "sh build-parser.sh",
34
- "win32": "build-parser.cmd"
35
- }
30
+ "antlr4ts-cli": "^0.5.0-alpha.4"
36
31
  }
37
32
  }
@@ -1,56 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright 2022 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.toAsyncGenerator = void 0;
16
- async function* toAsyncGenerator(startStreaming) {
17
- let done = false;
18
- function getResults(startStreaming) {
19
- let resolve;
20
- const promise = new Promise((res) => {
21
- resolve = res;
22
- });
23
- startStreaming((error) => {
24
- resolve({ done: true, isError: true, error });
25
- }, (data) => {
26
- resolve({
27
- done: false,
28
- value: data,
29
- isError: false,
30
- next: new Promise((res) => {
31
- resolve = res;
32
- }),
33
- });
34
- }, () => {
35
- resolve({ done: true, isError: false });
36
- });
37
- return promise;
38
- }
39
- let next = getResults(startStreaming);
40
- while (!done) {
41
- const result = await next;
42
- if (result.done) {
43
- done = true;
44
- if (result.isError) {
45
- throw result.error;
46
- }
47
- break;
48
- }
49
- else {
50
- next = result.next;
51
- yield result.value;
52
- }
53
- }
54
- }
55
- exports.toAsyncGenerator = toAsyncGenerator;
56
- //# sourceMappingURL=connection_utils.js.map
@@ -1,3 +0,0 @@
1
- import { Dialect } from "./dialect";
2
- export declare function getDialect(name: string): Dialect;
3
- export declare function registerDialect(d: Dialect): void;
@@ -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
@@ -1,77 +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.Dialect = void 0;
16
- // Can't get these from "../model" because model includes this file
17
- // and that can create a circular reference problem. This is a patch
18
- // and really indicates a problem in the relationship between
19
- // dialect and model, it's going to come up again some time.
20
- const malloy_types_1 = require("../model/malloy_types");
21
- class Dialect {
22
- sqlFinalStage(_lastStageName, _fields) {
23
- throw new Error("Dialect has no final Stage but called Anyway");
24
- }
25
- // default implementation will probably work most of the time
26
- sqlDateToString(sqlDateExp) {
27
- return `CAST(DATE(${sqlDateExp}) AS ${this.stringTypeName} )`;
28
- }
29
- // BigQuery has some fieldNames that are Pseudo Fields and shouldn't be
30
- // included in projections.
31
- ignoreInProject(_fieldName) {
32
- return false;
33
- }
34
- getFunctionInfo(functionName) {
35
- return this.functionInfo[functionName.toLowerCase()];
36
- }
37
- dialectExpr(df) {
38
- switch (df.function) {
39
- case "now":
40
- return this.sqlNow();
41
- case "timeDiff":
42
- return this.sqlMeasureTime(df.left, df.right, df.units);
43
- case "delta":
44
- return this.sqlAlterTime(df.op, df.base, df.delta, df.units);
45
- case "trunc":
46
- return this.sqlTrunc(df.expr, df.units);
47
- case "extract":
48
- return this.sqlExtract(df.expr, df.units);
49
- case "cast":
50
- return this.sqlCast(df);
51
- case "regexpMatch":
52
- return this.sqlRegexpMatch(df.expr, df.regexp);
53
- case "div": {
54
- if (this.divisionIsInteger) {
55
- return (0, malloy_types_1.mkExpr) `${df.numerator}*1.0/${df.denominator}`;
56
- }
57
- return (0, malloy_types_1.mkExpr) `${df.numerator}/${df.denominator}`;
58
- }
59
- case "timeLiteral":
60
- return [this.sqlLiteralTime(df.literal, df.literalType, df.timezone)];
61
- }
62
- }
63
- sqlSumDistinct(_key, _value) {
64
- return "sqlSumDistinct called bu not implemented";
65
- }
66
- sqlSampleTable(tableSQL, sample) {
67
- if (sample !== undefined) {
68
- throw new Error(`Sampling is not supported on dialect ${this.name}.`);
69
- }
70
- return tableSQL;
71
- }
72
- sqlOrderBy(orderTerms) {
73
- return `ORDER BY ${orderTerms.join(",")}`;
74
- }
75
- }
76
- exports.Dialect = Dialect;
77
- //# sourceMappingURL=dialect.js.map
@@ -1,35 +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 _1 = require(".");
17
- const postgres_1 = require("./postgres");
18
- const standardsql_1 = require("./standardsql");
19
- const dialectMap = new Map();
20
- function getDialect(name) {
21
- const d = dialectMap.get(name);
22
- if (d === undefined) {
23
- throw new Error(`Unknown Dialect ${name}`);
24
- }
25
- return d;
26
- }
27
- exports.getDialect = getDialect;
28
- function registerDialect(d) {
29
- dialectMap.set(d.name, d);
30
- }
31
- exports.registerDialect = registerDialect;
32
- registerDialect(new postgres_1.PostgresDialect());
33
- registerDialect(new standardsql_1.StandardSQLDialect());
34
- registerDialect(new _1.DuckDBDialect());
35
- //# sourceMappingURL=dialect_map.js.map