@malloydata/malloy 0.0.434 → 0.0.436
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/foundation/build_targets.d.ts +5 -6
- package/dist/api/foundation/build_targets.js +74 -6
- package/dist/api/foundation/compile.d.ts +0 -1
- package/dist/api/foundation/compile.js +0 -3
- package/dist/api/foundation/core.d.ts +16 -4
- package/dist/api/foundation/core.js +23 -23
- package/dist/api/foundation/index.d.ts +1 -1
- package/dist/api/foundation/runtime.d.ts +21 -3
- package/dist/api/foundation/runtime.js +45 -54
- package/dist/api/foundation/types.d.ts +43 -4
- package/dist/connection/dbmeta.d.ts +29 -0
- package/dist/connection/dbmeta.js +46 -0
- package/dist/connection/index.d.ts +1 -0
- package/dist/connection/index.js +1 -0
- package/dist/dialect/databricks/databricks.d.ts +11 -12
- package/dist/dialect/databricks/databricks.js +24 -36
- package/dist/dialect/dialect.d.ts +70 -171
- package/dist/dialect/dialect.js +123 -92
- package/dist/dialect/dialect_map.js +2 -0
- package/dist/dialect/duckdb/duckdb.d.ts +2 -2
- package/dist/dialect/duckdb/duckdb.js +1 -1
- package/dist/dialect/index.d.ts +3 -2
- package/dist/dialect/index.js +4 -2
- package/dist/dialect/mysql/mysql.d.ts +11 -12
- package/dist/dialect/mysql/mysql.js +20 -32
- package/dist/dialect/pg_impl.d.ts +9 -10
- package/dist/dialect/pg_impl.js +27 -73
- package/dist/dialect/postgres/postgres.d.ts +4 -4
- package/dist/dialect/postgres/postgres.js +4 -12
- package/dist/dialect/snowflake/snowflake.d.ts +11 -13
- package/dist/dialect/snowflake/snowflake.js +30 -82
- package/dist/dialect/sqlserver/dialect_functions.d.ts +2 -0
- package/dist/dialect/sqlserver/dialect_functions.js +42 -0
- package/dist/dialect/sqlserver/function_overrides.d.ts +2 -0
- package/dist/dialect/sqlserver/function_overrides.js +55 -0
- package/dist/dialect/sqlserver/index.d.ts +1 -0
- package/dist/dialect/sqlserver/index.js +22 -0
- package/dist/dialect/sqlserver/sqlserver.d.ts +101 -0
- package/dist/dialect/sqlserver/sqlserver.js +537 -0
- package/dist/dialect/sqlserver/windows_zones.d.ts +1 -0
- package/dist/dialect/sqlserver/windows_zones.js +613 -0
- package/dist/dialect/standardsql/standardsql.d.ts +11 -16
- package/dist/dialect/standardsql/standardsql.js +22 -73
- package/dist/dialect/trino/trino.d.ts +16 -18
- package/dist/dialect/trino/trino.js +127 -181
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -4
- package/dist/lang/ast/expressions/boolean-value.d.ts +24 -0
- package/dist/lang/ast/expressions/boolean-value.js +41 -0
- package/dist/lang/ast/expressions/case.js +7 -0
- package/dist/lang/ast/expressions/expr-alternation-tree.js +11 -0
- package/dist/lang/ast/expressions/expr-cast.js +5 -0
- package/dist/lang/ast/expressions/expr-coalesce.js +4 -0
- package/dist/lang/ast/expressions/expr-func.js +13 -2
- package/dist/lang/ast/expressions/expr-minus.js +5 -2
- package/dist/lang/ast/expressions/expr-null.js +4 -0
- package/dist/lang/ast/expressions/pick-when.js +7 -0
- package/dist/lang/ast/field-space/index-field-space.js +13 -1
- package/dist/lang/ast/field-space/query-spaces.js +11 -0
- package/dist/lang/ast/query-builders/reduce-builder.js +1 -1
- package/dist/lang/ast/query-items/field-declaration.d.ts +5 -0
- package/dist/lang/ast/query-items/field-declaration.js +22 -16
- package/dist/lang/ast/query-items/field-references.d.ts +6 -0
- package/dist/lang/ast/query-items/field-references.js +23 -0
- package/dist/lang/ast/query-properties/filters.js +3 -1
- package/dist/lang/ast/source-elements/named-source.js +0 -2
- package/dist/lang/ast/source-elements/sql-source.js +0 -3
- package/dist/lang/ast/source-elements/table-source.js +1 -2
- package/dist/lang/ast/statements/import-statement.js +17 -0
- package/dist/lang/ast/types/expression-def.js +17 -2
- package/dist/lang/ast/types/malloy-element.d.ts +24 -8
- package/dist/lang/ast/types/malloy-element.js +63 -44
- package/dist/lang/ast/view-elements/reference-view.js +4 -0
- package/dist/lang/ast/view-elements/refine-utils.js +1 -0
- package/dist/lang/composite-source-utils.js +10 -17
- package/dist/lang/parse-log.d.ts +12 -0
- package/dist/lang/parse-log.js +2 -0
- package/dist/lang/parse-malloy.d.ts +17 -2
- package/dist/lang/parse-malloy.js +48 -14
- package/dist/lang/parse-tree-walkers/find-external-references.d.ts +3 -3
- package/dist/lang/parse-tree-walkers/find-external-references.js +17 -16
- package/dist/lang/test/test-translator.d.ts +11 -1
- package/dist/lang/test/test-translator.js +51 -3
- package/dist/model/expression_compiler.js +9 -8
- package/dist/model/filter_compilers.js +13 -12
- package/dist/model/given_binding.d.ts +8 -0
- package/dist/model/given_binding.js +13 -0
- package/dist/model/index.d.ts +1 -1
- package/dist/model/index.js +2 -1
- package/dist/model/query_query.d.ts +3 -1
- package/dist/model/query_query.js +157 -139
- package/dist/model/source_def_utils.d.ts +7 -1
- package/dist/model/source_def_utils.js +20 -0
- package/dist/model/sql_compiled.d.ts +19 -20
- package/dist/model/sql_compiled.js +29 -17
- package/dist/test/index.js +16 -8
- package/dist/test/matchers.d.ts +1 -1
- package/dist/test/matchers.js +1 -1
- package/dist/test/test-models.js +6 -13
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/femto-config.motly +13 -1
- package/package.json +7 -5
|
@@ -8,6 +8,7 @@ exports.getCompiledSQL = getCompiledSQL;
|
|
|
8
8
|
exports.expandSQLSegments = expandSQLSegments;
|
|
9
9
|
exports.buildIdOptions = buildIdOptions;
|
|
10
10
|
exports.persistedTableFor = persistedTableFor;
|
|
11
|
+
exports.givenUsageOfRelation = givenUsageOfRelation;
|
|
11
12
|
exports.getSourceSQL = getSourceSQL;
|
|
12
13
|
const malloy_types_1 = require("./malloy_types");
|
|
13
14
|
const source_def_utils_1 = require("./source_def_utils");
|
|
@@ -50,23 +51,9 @@ function expandSegment(segment, opts, compileQuery) {
|
|
|
50
51
|
// Query segment
|
|
51
52
|
return expandQuery(segment, opts, compileQuery);
|
|
52
53
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Project compile options down to what a BuildID is computed under.
|
|
55
|
-
*
|
|
56
|
-
* `virtualMap` decides which table a virtual source reads, so it changes the
|
|
57
|
-
* SQL and has to be in the key; the builder supplies its own.
|
|
58
|
-
*
|
|
59
|
-
* `resolvedGivens` is deliberately absent even though it also changes the SQL.
|
|
60
|
-
* The builder has no way to produce one — `Runtime.getBuildTargets` takes no
|
|
61
|
-
* givens and `PersistSource.getSQL` never resolves them — so including it makes
|
|
62
|
-
* the two sides disagree: the compiler folds `$IS_ADMIN` to a literal while the
|
|
63
|
-
* builder re-derives it from the declaration and emits `'admin'='admin'`. Both
|
|
64
|
-
* sides therefore compile givens the same way, by not resolving them. The
|
|
65
|
-
* consequence — a source whose SQL depends on a supplied given cannot be
|
|
66
|
-
* persisted, and says so badly — is #3041.
|
|
67
|
-
*/
|
|
54
|
+
/** Project compile options down to what a BuildID is computed under. */
|
|
68
55
|
function buildIdOptions(opts) {
|
|
69
|
-
return { virtualMap: opts.virtualMap };
|
|
56
|
+
return { virtualMap: opts.virtualMap, resolvedGivens: opts.resolvedGivens };
|
|
70
57
|
}
|
|
71
58
|
/**
|
|
72
59
|
* Ask the manifest what table backs a persistable source.
|
|
@@ -100,12 +87,37 @@ function persistedTableFor(source, opts, compileQuery) {
|
|
|
100
87
|
const named = source.sourceID
|
|
101
88
|
? `Persisted source '${source.sourceID}'`
|
|
102
89
|
: 'Persisted source';
|
|
90
|
+
const perValue = givenUsageOfRelation(source).length > 0
|
|
91
|
+
? ' This source reads givens, and no table was built for the given ' +
|
|
92
|
+
'values this query supplies.'
|
|
93
|
+
: '';
|
|
103
94
|
const base = `${named} not found in manifest (buildId: ${buildId}); ` +
|
|
104
|
-
'strict manifest mode forbids fallback to live compilation.'
|
|
95
|
+
'strict manifest mode forbids fallback to live compilation.' +
|
|
96
|
+
perValue;
|
|
105
97
|
throw new malloy_compile_error_1.MalloyCompileError(buildManifest.loadError ? `${base}\n ${buildManifest.loadError}` : base, 'runtime-manifest-strict-miss', source.location);
|
|
106
98
|
}
|
|
107
99
|
return undefined;
|
|
108
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* The givens a persisted source's SQL reads — the relation, not the source.
|
|
103
|
+
* A `where:` added by `extend` is applied by the query that reads the table,
|
|
104
|
+
* so it is not here, and a given used only there does not split the table by
|
|
105
|
+
* value. Mirrors `getSourceSQL`: what that compiles, this reports on.
|
|
106
|
+
*/
|
|
107
|
+
function givenUsageOfRelation(source) {
|
|
108
|
+
var _a, _b;
|
|
109
|
+
if (source.type === 'query_source') {
|
|
110
|
+
return (_a = source.query.givenUsage) !== null && _a !== void 0 ? _a : [];
|
|
111
|
+
}
|
|
112
|
+
return ((_b = source.selectSegments) !== null && _b !== void 0 ? _b : []).flatMap(segment => {
|
|
113
|
+
var _a;
|
|
114
|
+
if ((0, malloy_types_1.isSegmentSQL)(segment))
|
|
115
|
+
return [];
|
|
116
|
+
if ((0, malloy_types_1.isSegmentSource)(segment))
|
|
117
|
+
return givenUsageOfRelation(segment);
|
|
118
|
+
return (_a = segment.givenUsage) !== null && _a !== void 0 ? _a : [];
|
|
119
|
+
});
|
|
120
|
+
}
|
|
109
121
|
/**
|
|
110
122
|
* Expand a PersistableSourceDef as a `%{ }` segment.
|
|
111
123
|
* Always returns a subquery form: (SELECT * FROM table) or (inline SQL)
|
package/dist/test/index.js
CHANGED
|
@@ -113,14 +113,20 @@ function databasesFromEnvironmentOr(defaultDatabases) {
|
|
|
113
113
|
: defaultDatabases;
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
|
-
* A replacement for [describe()] that mimics [describe.skip()]
|
|
116
|
+
* A replacement for [describe()] that mimics [describe.skip()].
|
|
117
|
+
*
|
|
118
|
+
* Built on demand, not at module scope: this module is also imported outside
|
|
119
|
+
* jest (scripts that construct a test connection), where the jest globals do
|
|
120
|
+
* not exist.
|
|
117
121
|
*/
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
})
|
|
122
|
+
function makeDescribeSkip() {
|
|
123
|
+
return Object.assign((name, fn) => describe.skip(name, fn), {
|
|
124
|
+
skip: describe.skip,
|
|
125
|
+
// eslint-disable-next-line no-restricted-properties
|
|
126
|
+
only: describe.only,
|
|
127
|
+
each: (() => () => it.skip('skipped', () => { })),
|
|
128
|
+
});
|
|
129
|
+
}
|
|
124
130
|
/**
|
|
125
131
|
* Confirms that one or more of the databases being tested overlaps with
|
|
126
132
|
* the databases a test suite can accept. If there is overlap, return a tuple
|
|
@@ -130,7 +136,9 @@ const describeSkip = Object.assign((name, fn) => describe.skip(name, fn), {
|
|
|
130
136
|
function describeIfDatabaseAvailable(acceptableDatabases) {
|
|
131
137
|
const currentDatabases = databasesFromEnvironmentOr(acceptableDatabases);
|
|
132
138
|
const overlap = acceptableDatabases.filter(d => currentDatabases.includes(d));
|
|
133
|
-
return overlap.length > 0
|
|
139
|
+
return overlap.length > 0
|
|
140
|
+
? [describe, overlap]
|
|
141
|
+
: [makeDescribeSkip(), overlap];
|
|
134
142
|
}
|
|
135
143
|
function brokenIn(dialectName, connectionName) {
|
|
136
144
|
return dialectName === connectionName;
|
package/dist/test/matchers.d.ts
CHANGED
package/dist/test/matchers.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
/**
|
|
8
8
|
* Import this module to register Jest matchers (toMatchResult, toEqualResult).
|
|
9
9
|
*
|
|
10
|
-
* Usage in jest.config.
|
|
10
|
+
* Usage in jest.config.ts:
|
|
11
11
|
* setupFilesAfterEnv: ['@malloydata/malloy/test/matchers']
|
|
12
12
|
*
|
|
13
13
|
* Or import directly in a test file:
|
package/dist/test/test-models.js
CHANGED
|
@@ -229,19 +229,12 @@ function generateSQL(dialect, rows) {
|
|
|
229
229
|
.join(', ');
|
|
230
230
|
const innerQuery = selects.join('\nUNION ALL ');
|
|
231
231
|
// Generate ORDER BY based on dialect preference
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
orderByClause = `ORDER BY ${rowIdColumn}`;
|
|
241
|
-
}
|
|
242
|
-
// Presto/Trino ignores ORDER BY on a subquery without LIMIT
|
|
243
|
-
orderByClause += ` LIMIT ${rows.length}`;
|
|
244
|
-
const sql = `SELECT ${quotedColumns}\nFROM (\n SELECT *\n FROM (\n${innerQuery}\n ) AS t_sorted\n ${orderByClause}\n) AS t_result\n`;
|
|
232
|
+
const orderTerm = dialect.orderByClause === 'ordinal'
|
|
233
|
+
? `${columnList.length + 1}`
|
|
234
|
+
: rowIdColumn;
|
|
235
|
+
// Presto/Trino ignores ORDER BY on a subquery without a row limit
|
|
236
|
+
const orderByClause = dialect.sqlOrderByLimit([orderTerm], rows.length);
|
|
237
|
+
const sql = `SELECT ${quotedColumns}\nFROM (\n SELECT *\n FROM (\n${innerQuery}\n ) AS t_sorted\n ${orderByClause}) AS t_result\n`;
|
|
245
238
|
return sql;
|
|
246
239
|
}
|
|
247
240
|
/**
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MALLOY_VERSION = "0.0.
|
|
1
|
+
export declare const MALLOY_VERSION = "0.0.436";
|
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.436';
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
package/femto-config.motly
CHANGED
|
@@ -28,6 +28,18 @@ tokenNames: {
|
|
|
28
28
|
commands = ["node src/lang/grammar/build_token_names.js"]
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
# A pure function of the two CLDR files, so a cldr-core/cldr-bcp47 bump
|
|
32
|
+
# regenerates it on the next build.
|
|
33
|
+
windowsZones: {
|
|
34
|
+
inputs = [
|
|
35
|
+
"src/dialect/sqlserver/build_windows_zones.js",
|
|
36
|
+
"../../node_modules/cldr-core/supplemental/windowsZones.json",
|
|
37
|
+
"../../node_modules/cldr-bcp47/bcp47/timezone.json"
|
|
38
|
+
]
|
|
39
|
+
outputs = ["src/dialect/sqlserver/windows_zones.ts"]
|
|
40
|
+
commands = ["node src/dialect/sqlserver/build_windows_zones.js"]
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
codegen: {
|
|
32
|
-
deps = [parser, tokenNames]
|
|
44
|
+
deps = [parser, tokenNames, windowsZones]
|
|
33
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.436",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"url": "https://github.com/malloydata/malloy"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
|
-
"test": "
|
|
43
|
+
"test": "echo 'Read the Testing section of the repo-root CONTEXT.md for information on testing in this monorepo'; exit 1",
|
|
44
44
|
"codegen": "node ../../scripts/femto-build.js codegen",
|
|
45
45
|
"build-parser": "node src/lang/grammar/build_parser.js",
|
|
46
46
|
"clean": "tsc --build --clean && rm -f tsconfig.tsbuildinfo && node ../../scripts/femto-build.js --clean && rm -rf src/lang/lib dist",
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"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"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@malloydata/malloy-filter": "0.0.
|
|
55
|
-
"@malloydata/malloy-interfaces": "0.0.
|
|
56
|
-
"@malloydata/malloy-tag": "0.0.
|
|
54
|
+
"@malloydata/malloy-filter": "0.0.436",
|
|
55
|
+
"@malloydata/malloy-interfaces": "0.0.436",
|
|
56
|
+
"@malloydata/malloy-tag": "0.0.436",
|
|
57
57
|
"@noble/hashes": "^1.8.0",
|
|
58
58
|
"antlr4ts": "^0.5.0-alpha.4",
|
|
59
59
|
"assert": "^2.0.0",
|
|
@@ -67,6 +67,8 @@
|
|
|
67
67
|
"@types/lodash": "^4.17.24",
|
|
68
68
|
"@types/luxon": "^3.7.2",
|
|
69
69
|
"antlr4ts-cli": "^0.5.0-alpha.4",
|
|
70
|
+
"cldr-bcp47": "^48.2.0",
|
|
71
|
+
"cldr-core": "^48.2.0",
|
|
70
72
|
"jest-diff": "^30.4.1"
|
|
71
73
|
}
|
|
72
74
|
}
|