@malloydata/malloy 0.0.239-dev250226010331 → 0.0.239-dev250227145856
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.d.ts +13 -0
- package/dist/api/asynchronous.js +205 -0
- package/dist/api/asynchronous.spec.d.ts +1 -0
- package/dist/api/asynchronous.spec.js +238 -0
- package/dist/api/connection.d.ts +12 -0
- package/dist/api/connection.js +9 -0
- package/dist/api/core.d.ts +37 -0
- package/dist/api/core.js +448 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +36 -0
- package/dist/api/sessioned.d.ts +10 -0
- package/dist/api/sessioned.js +210 -0
- package/dist/api/sessioned.spec.d.ts +1 -0
- package/dist/api/sessioned.spec.js +417 -0
- package/dist/api/stateless.d.ts +4 -0
- package/dist/api/stateless.js +46 -0
- package/dist/api/stateless.spec.d.ts +1 -0
- package/dist/api/stateless.spec.js +394 -0
- package/dist/connection/base_connection.d.ts +3 -2
- package/dist/connection/base_connection.js +3 -1
- package/dist/connection/types.d.ts +2 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +28 -1
- package/dist/lang/ast/source-elements/sql-source.d.ts +4 -4
- package/dist/lang/ast/source-elements/sql-source.js +20 -12
- package/dist/lang/malloy-to-ast.d.ts +1 -1
- package/dist/lang/parse-malloy.js +0 -1
- package/dist/lang/test/locations.spec.js +1 -1
- package/dist/lang/test/parse-expects.js +1 -1
- package/dist/lang/test/parse.spec.js +18 -15
- package/dist/lang/test/sql-block.spec.js +18 -21
- package/dist/lang/test/test-translator.d.ts +5 -3
- package/dist/lang/test/test-translator.js +10 -10
- package/dist/lang/translate-response.d.ts +6 -3
- package/dist/malloy.d.ts +2 -4
- package/dist/malloy.js +11 -45
- package/dist/model/malloy_types.d.ts +0 -5
- package/dist/model/sql_block.d.ts +4 -7
- package/dist/model/sql_block.js +31 -21
- package/dist/to_stable.js +9 -0
- package/package.json +3 -3
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as Malloy from '@malloydata/malloy-interfaces';
|
|
2
|
+
import { InfoConnection, Connection, LookupConnection } from './connection';
|
|
3
|
+
import { URLReader } from '../runtime_types';
|
|
4
|
+
import { CacheManager } from '../malloy';
|
|
5
|
+
export interface CompilerNeedFetch<T extends InfoConnection> {
|
|
6
|
+
connections: LookupConnection<T>;
|
|
7
|
+
urls: URLReader;
|
|
8
|
+
cacheManager?: CacheManager;
|
|
9
|
+
}
|
|
10
|
+
export declare function compileModel(request: Malloy.CompileModelRequest, fetchers: CompilerNeedFetch<InfoConnection>): Promise<Malloy.CompileModelResponse>;
|
|
11
|
+
export declare function compileSource(request: Malloy.CompileSourceRequest, fetchers: CompilerNeedFetch<InfoConnection>): Promise<Malloy.CompileSourceResponse>;
|
|
12
|
+
export declare function compileQuery(request: Malloy.CompileQueryRequest, fetchers: CompilerNeedFetch<InfoConnection>): Promise<Malloy.CompileQueryResponse>;
|
|
13
|
+
export declare function runQuery(request: Malloy.CompileQueryRequest, fetchers: CompilerNeedFetch<Connection>): Promise<Malloy.CompileQueryResponse>;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.runQuery = exports.compileQuery = exports.compileSource = exports.compileModel = void 0;
|
|
33
|
+
const Core = __importStar(require("./core"));
|
|
34
|
+
async function fetchNeeds(needs, fetchers) {
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
36
|
+
var _h, _j;
|
|
37
|
+
if (needs === undefined) {
|
|
38
|
+
throw new Error("Expected compiler to have needs because it didn't return a result");
|
|
39
|
+
}
|
|
40
|
+
const result = {};
|
|
41
|
+
if (needs.connections) {
|
|
42
|
+
for (const connection of needs.connections) {
|
|
43
|
+
const info = await fetchers.connections.lookupConnection(connection.name);
|
|
44
|
+
(_a = result.connections) !== null && _a !== void 0 ? _a : (result.connections = []);
|
|
45
|
+
result.connections.push({
|
|
46
|
+
...connection,
|
|
47
|
+
dialect: info.dialectName,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (needs.files) {
|
|
52
|
+
for (const file of needs.files) {
|
|
53
|
+
// TODO handle checking if the cache has the file...
|
|
54
|
+
const info = await fetchers.urls.readURL(new URL(file.url));
|
|
55
|
+
(_b = result.files) !== null && _b !== void 0 ? _b : (result.files = []);
|
|
56
|
+
if (typeof info === 'string') {
|
|
57
|
+
result.files.push({
|
|
58
|
+
...file,
|
|
59
|
+
contents: info,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
result.files.push({
|
|
64
|
+
...file,
|
|
65
|
+
contents: info.contents,
|
|
66
|
+
invalidation_key: (_c = info.invalidationKey) === null || _c === void 0 ? void 0 : _c.toString(),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (needs.table_schemas) {
|
|
72
|
+
const tableSchemasByConnection = {};
|
|
73
|
+
for (const tableSchema of needs.table_schemas) {
|
|
74
|
+
(_d = tableSchemasByConnection[_h = tableSchema.connection_name]) !== null && _d !== void 0 ? _d : (tableSchemasByConnection[_h] = []);
|
|
75
|
+
tableSchemasByConnection[tableSchema.connection_name].push(tableSchema);
|
|
76
|
+
}
|
|
77
|
+
for (const connectionName in tableSchemasByConnection) {
|
|
78
|
+
const connection = await fetchers.connections.lookupConnection(connectionName);
|
|
79
|
+
const tableNames = tableSchemasByConnection[connectionName].map(t => t.name);
|
|
80
|
+
const schemas = await Promise.all(tableNames.map(async (tableName) => ({
|
|
81
|
+
name: tableName,
|
|
82
|
+
schema: await connection.fetchSchemaForTable(tableName),
|
|
83
|
+
})));
|
|
84
|
+
(_e = result.table_schemas) !== null && _e !== void 0 ? _e : (result.table_schemas = []);
|
|
85
|
+
for (const schema of schemas) {
|
|
86
|
+
result.table_schemas.push({
|
|
87
|
+
connection_name: connectionName,
|
|
88
|
+
name: schema.name,
|
|
89
|
+
schema: schema.schema,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (needs.sql_schemas) {
|
|
95
|
+
const sqlSchemasByConnectionName = {};
|
|
96
|
+
for (const sqlSchema of needs.sql_schemas) {
|
|
97
|
+
(_f = sqlSchemasByConnectionName[_j = sqlSchema.connection_name]) !== null && _f !== void 0 ? _f : (sqlSchemasByConnectionName[_j] = []);
|
|
98
|
+
sqlSchemasByConnectionName[sqlSchema.connection_name].push(sqlSchema);
|
|
99
|
+
}
|
|
100
|
+
for (const connectionName in sqlSchemasByConnectionName) {
|
|
101
|
+
const connection = await fetchers.connections.lookupConnection(connectionName);
|
|
102
|
+
const sqlQueries = sqlSchemasByConnectionName[connectionName].map(t => t.sql);
|
|
103
|
+
const schemas = await Promise.all(sqlQueries.map(async (sql) => ({
|
|
104
|
+
sql,
|
|
105
|
+
schema: await connection.fetchSchemaForSQLQuery(sql),
|
|
106
|
+
})));
|
|
107
|
+
(_g = result.sql_schemas) !== null && _g !== void 0 ? _g : (result.sql_schemas = []);
|
|
108
|
+
for (const schema of schemas) {
|
|
109
|
+
result.sql_schemas.push({
|
|
110
|
+
connection_name: connectionName,
|
|
111
|
+
sql: schema.sql,
|
|
112
|
+
schema: schema.schema,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
async function compileModel(request, fetchers) {
|
|
120
|
+
const state = Core.newCompileModelState(request);
|
|
121
|
+
// eslint-disable-next-line no-constant-condition
|
|
122
|
+
while (true) {
|
|
123
|
+
const result = Core.statedCompileModel(state);
|
|
124
|
+
if (result.model) {
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
const needs = await fetchNeeds(result.compiler_needs, fetchers);
|
|
128
|
+
Core.updateCompileModelState(state, needs);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.compileModel = compileModel;
|
|
132
|
+
async function compileSource(request, fetchers) {
|
|
133
|
+
const state = Core.newCompileSourceState(request);
|
|
134
|
+
// eslint-disable-next-line no-constant-condition
|
|
135
|
+
while (true) {
|
|
136
|
+
const result = Core.statedCompileSource(state, request.name);
|
|
137
|
+
if (result.source) {
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
const needs = await fetchNeeds(result.compiler_needs, fetchers);
|
|
141
|
+
Core.updateCompileModelState(state, needs);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.compileSource = compileSource;
|
|
145
|
+
async function compileQuery(request, fetchers) {
|
|
146
|
+
const state = Core.newCompileQueryState(request);
|
|
147
|
+
// eslint-disable-next-line no-constant-condition
|
|
148
|
+
while (true) {
|
|
149
|
+
const result = Core.statedCompileQuery(state);
|
|
150
|
+
if (result.result) {
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
const needs = await fetchNeeds(result.compiler_needs, fetchers);
|
|
154
|
+
Core.updateCompileModelState(state, needs);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.compileQuery = compileQuery;
|
|
158
|
+
async function runQuery(request, fetchers) {
|
|
159
|
+
var _a, _b;
|
|
160
|
+
const compiled = await compileQuery(request, fetchers);
|
|
161
|
+
if (compiled.result === undefined) {
|
|
162
|
+
return compiled;
|
|
163
|
+
}
|
|
164
|
+
const defaultURL = request.model_url;
|
|
165
|
+
if (compiled.result.sql === undefined) {
|
|
166
|
+
return {
|
|
167
|
+
logs: [
|
|
168
|
+
...((_a = compiled.logs) !== null && _a !== void 0 ? _a : []),
|
|
169
|
+
{
|
|
170
|
+
url: defaultURL,
|
|
171
|
+
severity: 'error',
|
|
172
|
+
message: 'Internal error: Compiler did not generate SQL',
|
|
173
|
+
range: Core.DEFAULT_LOG_RANGE,
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
const connection = await fetchers.connections.lookupConnection(compiled.result.connection_name);
|
|
180
|
+
const data = await connection.runSQL(compiled.result.sql);
|
|
181
|
+
return {
|
|
182
|
+
...compiled,
|
|
183
|
+
result: {
|
|
184
|
+
...compiled.result,
|
|
185
|
+
data,
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
return {
|
|
191
|
+
...compiled,
|
|
192
|
+
logs: [
|
|
193
|
+
...((_b = compiled.logs) !== null && _b !== void 0 ? _b : []),
|
|
194
|
+
{
|
|
195
|
+
url: defaultURL,
|
|
196
|
+
severity: 'error',
|
|
197
|
+
message: `Error running SQL: ${error.message}`,
|
|
198
|
+
range: Core.DEFAULT_LOG_RANGE,
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
exports.runQuery = runQuery;
|
|
205
|
+
//# sourceMappingURL=asynchronous.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const asynchronous_1 = require("./asynchronous");
|
|
10
|
+
describe('api', () => {
|
|
11
|
+
describe('compile model', () => {
|
|
12
|
+
test('compile model with table dependency', async () => {
|
|
13
|
+
const connection = {
|
|
14
|
+
dialectName: 'duckdb',
|
|
15
|
+
fetchSchemaForTable: async (_name) => {
|
|
16
|
+
return {
|
|
17
|
+
fields: [
|
|
18
|
+
{
|
|
19
|
+
kind: 'dimension',
|
|
20
|
+
name: 'carrier',
|
|
21
|
+
type: { kind: 'string_type' },
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
fetchSchemaForSQLQuery: async (_sql) => {
|
|
27
|
+
throw new Error('not implemented');
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
const urls = {
|
|
31
|
+
readURL: async (_url) => {
|
|
32
|
+
return "source: flights is connection.table('flights')";
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
const connections = {
|
|
36
|
+
lookupConnection: async (_name) => {
|
|
37
|
+
return connection;
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
const fetchers = {
|
|
41
|
+
urls,
|
|
42
|
+
connections,
|
|
43
|
+
};
|
|
44
|
+
const result = await (0, asynchronous_1.compileModel)({
|
|
45
|
+
model_url: 'file://test.malloy',
|
|
46
|
+
}, fetchers);
|
|
47
|
+
const expected = {
|
|
48
|
+
model: {
|
|
49
|
+
entries: [
|
|
50
|
+
{
|
|
51
|
+
kind: 'source',
|
|
52
|
+
name: 'flights',
|
|
53
|
+
schema: {
|
|
54
|
+
fields: [
|
|
55
|
+
{
|
|
56
|
+
kind: 'dimension',
|
|
57
|
+
name: 'carrier',
|
|
58
|
+
type: { kind: 'string_type' },
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
anonymous_queries: [],
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
expect(result).toMatchObject(expected);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
describe('compile query', () => {
|
|
71
|
+
test('compile query with table dependency', async () => {
|
|
72
|
+
const connection = {
|
|
73
|
+
dialectName: 'duckdb',
|
|
74
|
+
fetchSchemaForTable: async (_name) => {
|
|
75
|
+
return {
|
|
76
|
+
fields: [
|
|
77
|
+
{
|
|
78
|
+
kind: 'dimension',
|
|
79
|
+
name: 'carrier',
|
|
80
|
+
type: { kind: 'string_type' },
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
fetchSchemaForSQLQuery: async (_sql) => {
|
|
86
|
+
throw new Error('not implemented');
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
const urls = {
|
|
90
|
+
readURL: async (_url) => {
|
|
91
|
+
return "source: flights is connection.table('flights')";
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
const connections = {
|
|
95
|
+
lookupConnection: async (_name) => {
|
|
96
|
+
return connection;
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
const fetchers = {
|
|
100
|
+
urls,
|
|
101
|
+
connections,
|
|
102
|
+
};
|
|
103
|
+
const result = await (0, asynchronous_1.compileQuery)({
|
|
104
|
+
model_url: 'file://test.malloy',
|
|
105
|
+
query: {
|
|
106
|
+
definition: {
|
|
107
|
+
kind: 'arrow',
|
|
108
|
+
source_reference: { name: 'flights' },
|
|
109
|
+
view: {
|
|
110
|
+
kind: 'segment',
|
|
111
|
+
operations: [
|
|
112
|
+
{
|
|
113
|
+
kind: 'group_by',
|
|
114
|
+
field: {
|
|
115
|
+
expression: { kind: 'field_reference', name: 'carrier' },
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
}, fetchers);
|
|
123
|
+
const expected = {
|
|
124
|
+
result: {
|
|
125
|
+
connection_name: 'connection',
|
|
126
|
+
sql: `SELECT \n\
|
|
127
|
+
base."carrier" as "carrier"
|
|
128
|
+
FROM flights as base
|
|
129
|
+
GROUP BY 1
|
|
130
|
+
ORDER BY 1 asc NULLS LAST
|
|
131
|
+
`,
|
|
132
|
+
schema: {
|
|
133
|
+
fields: [
|
|
134
|
+
{
|
|
135
|
+
kind: 'dimension',
|
|
136
|
+
name: 'carrier',
|
|
137
|
+
type: { kind: 'string_type' },
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
expect(result).toMatchObject(expected);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
describe('run query', () => {
|
|
147
|
+
test('run query with table dependency', async () => {
|
|
148
|
+
const data = {
|
|
149
|
+
kind: 'table',
|
|
150
|
+
rows: [
|
|
151
|
+
{
|
|
152
|
+
cells: [{ kind: 'string_cell', string_value: 'WN' }],
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
cells: [{ kind: 'string_cell', string_value: 'AA' }],
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
};
|
|
159
|
+
const connection = {
|
|
160
|
+
dialectName: 'duckdb',
|
|
161
|
+
fetchSchemaForTable: async (_name) => {
|
|
162
|
+
return {
|
|
163
|
+
fields: [
|
|
164
|
+
{
|
|
165
|
+
kind: 'dimension',
|
|
166
|
+
name: 'carrier',
|
|
167
|
+
type: { kind: 'string_type' },
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
};
|
|
171
|
+
},
|
|
172
|
+
fetchSchemaForSQLQuery: async (_sql) => {
|
|
173
|
+
throw new Error('not implemented');
|
|
174
|
+
},
|
|
175
|
+
runSQL: async (_sql) => {
|
|
176
|
+
return data;
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
const urls = {
|
|
180
|
+
readURL: async (_url) => {
|
|
181
|
+
return "source: flights is connection.table('flights')";
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
const connections = {
|
|
185
|
+
lookupConnection: async (_name) => {
|
|
186
|
+
return connection;
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
const fetchers = {
|
|
190
|
+
urls,
|
|
191
|
+
connections,
|
|
192
|
+
};
|
|
193
|
+
const result = await (0, asynchronous_1.runQuery)({
|
|
194
|
+
model_url: 'file://test.malloy',
|
|
195
|
+
query: {
|
|
196
|
+
definition: {
|
|
197
|
+
kind: 'arrow',
|
|
198
|
+
source_reference: { name: 'flights' },
|
|
199
|
+
view: {
|
|
200
|
+
kind: 'segment',
|
|
201
|
+
operations: [
|
|
202
|
+
{
|
|
203
|
+
kind: 'group_by',
|
|
204
|
+
field: {
|
|
205
|
+
expression: { kind: 'field_reference', name: 'carrier' },
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
}, fetchers);
|
|
213
|
+
const expected = {
|
|
214
|
+
result: {
|
|
215
|
+
connection_name: 'connection',
|
|
216
|
+
sql: `SELECT \n\
|
|
217
|
+
base."carrier" as "carrier"
|
|
218
|
+
FROM flights as base
|
|
219
|
+
GROUP BY 1
|
|
220
|
+
ORDER BY 1 asc NULLS LAST
|
|
221
|
+
`,
|
|
222
|
+
schema: {
|
|
223
|
+
fields: [
|
|
224
|
+
{
|
|
225
|
+
kind: 'dimension',
|
|
226
|
+
name: 'carrier',
|
|
227
|
+
type: { kind: 'string_type' },
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
},
|
|
231
|
+
data,
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
expect(result).toMatchObject(expected);
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
//# sourceMappingURL=asynchronous.spec.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as Malloy from '@malloydata/malloy-interfaces';
|
|
2
|
+
export interface InfoConnection {
|
|
3
|
+
fetchSchemaForTable(name: string): Promise<Malloy.Schema>;
|
|
4
|
+
fetchSchemaForSQLQuery(sqlQuery: string): Promise<Malloy.Schema>;
|
|
5
|
+
get dialectName(): string;
|
|
6
|
+
}
|
|
7
|
+
export interface Connection extends InfoConnection {
|
|
8
|
+
runSQL(sql: string): Promise<Malloy.Data>;
|
|
9
|
+
}
|
|
10
|
+
export interface LookupConnection<T extends InfoConnection> {
|
|
11
|
+
lookupConnection(connectionName?: string): Promise<T>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//# sourceMappingURL=connection.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as Malloy from '@malloydata/malloy-interfaces';
|
|
2
|
+
import { LogMessage, MalloyTranslator } from '../lang';
|
|
3
|
+
import { ModelDef } from '../model';
|
|
4
|
+
export type CompileResponse = {
|
|
5
|
+
model: Malloy.ModelInfo;
|
|
6
|
+
modelDef: ModelDef;
|
|
7
|
+
compilerNeeds?: undefined;
|
|
8
|
+
logs?: LogMessage[];
|
|
9
|
+
} | {
|
|
10
|
+
model?: undefined;
|
|
11
|
+
modelDef?: undefined;
|
|
12
|
+
compilerNeeds: Malloy.CompilerNeeds;
|
|
13
|
+
logs?: LogMessage[];
|
|
14
|
+
} | {
|
|
15
|
+
model?: undefined;
|
|
16
|
+
modelDef?: undefined;
|
|
17
|
+
compilerNeeds?: undefined;
|
|
18
|
+
logs: LogMessage[];
|
|
19
|
+
};
|
|
20
|
+
export declare function compileQuery(request: Malloy.CompileQueryRequest, state?: CompileModelState): Malloy.CompileQueryResponse;
|
|
21
|
+
export interface CompileModelState {
|
|
22
|
+
extending?: CompileModelState;
|
|
23
|
+
translator: MalloyTranslator;
|
|
24
|
+
done: boolean;
|
|
25
|
+
hasSource: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function updateCompileModelState(state: CompileModelState, needs: Malloy.CompilerNeeds | undefined): void;
|
|
28
|
+
export declare function newCompileModelState(request: Malloy.CompileModelRequest): CompileModelState;
|
|
29
|
+
export declare function newCompileSourceState(request: Malloy.CompileSourceRequest): CompileModelState;
|
|
30
|
+
export declare function statedCompileModel(state: CompileModelState): Malloy.CompileModelResponse;
|
|
31
|
+
export declare function statedCompileSource(state: CompileModelState, name: string): Malloy.CompileSourceResponse;
|
|
32
|
+
export declare function _statedCompileModel(state: CompileModelState): CompileResponse;
|
|
33
|
+
export declare const DEFAULT_LOG_RANGE: Malloy.DocumentRange;
|
|
34
|
+
export declare function compileModel(request: Malloy.CompileModelRequest, state?: CompileModelState): Malloy.CompileModelResponse;
|
|
35
|
+
export declare function compileSource(request: Malloy.CompileSourceRequest): Malloy.CompileSourceResponse;
|
|
36
|
+
export declare function newCompileQueryState(request: Malloy.CompileQueryRequest): CompileModelState;
|
|
37
|
+
export declare function statedCompileQuery(state: CompileModelState): Malloy.CompileQueryResponse;
|