@duckcodeailabs/dql-cli 1.6.16 → 1.6.17
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/commands/notebook.d.ts +2 -0
- package/dist/commands/notebook.d.ts.map +1 -1
- package/dist/commands/notebook.js +6 -1
- package/dist/commands/notebook.js.map +1 -1
- package/dist/local-runtime.d.ts +1 -1
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +85 -56
- package/dist/local-runtime.js.map +1 -1
- package/dist/package.json +10 -10
- package/package.json +11 -11
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { CLIFlags } from '../args.js';
|
|
2
|
+
import type { ProjectConfig } from '../local-runtime.js';
|
|
3
|
+
export declare function resolveNotebookConnection(config: ProjectConfig, projectRoot: string): import("@duckcodeailabs/dql-connectors").ConnectionConfig | null;
|
|
2
4
|
export declare function runNotebook(targetArg: string | null, flags: CLIFlags): Promise<void>;
|
|
3
5
|
//# sourceMappingURL=notebook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notebook.d.ts","sourceRoot":"","sources":["../../src/commands/notebook.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"notebook.d.ts","sourceRoot":"","sources":["../../src/commands/notebook.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAezD,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oEAInF;AAED,wBAAsB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAsC1F"}
|
|
@@ -9,6 +9,11 @@ const COMMAND_DIR = dirname(fileURLToPath(import.meta.url));
|
|
|
9
9
|
const REACT_APP_DIR = resolve(COMMAND_DIR, '../assets/dql-notebook');
|
|
10
10
|
const LEGACY_APP_DIR = resolve(COMMAND_DIR, '../assets/notebook-browser');
|
|
11
11
|
const NOTEBOOK_APP_DIR = existsSync(join(REACT_APP_DIR, 'index.html')) ? REACT_APP_DIR : LEGACY_APP_DIR;
|
|
12
|
+
export function resolveNotebookConnection(config, projectRoot) {
|
|
13
|
+
return config.defaultConnection
|
|
14
|
+
? normalizeProjectConnection(config.defaultConnection, projectRoot)
|
|
15
|
+
: null;
|
|
16
|
+
}
|
|
12
17
|
export async function runNotebook(targetArg, flags) {
|
|
13
18
|
const baseDir = resolve(targetArg ?? '.');
|
|
14
19
|
const projectRoot = findProjectRoot(baseDir);
|
|
@@ -17,7 +22,7 @@ export async function runNotebook(targetArg, flags) {
|
|
|
17
22
|
}
|
|
18
23
|
const config = loadProjectConfig(projectRoot);
|
|
19
24
|
const executor = new QueryExecutor();
|
|
20
|
-
const connection =
|
|
25
|
+
const connection = resolveNotebookConnection(config, projectRoot);
|
|
21
26
|
const host = flags.host ?? process.env.DQL_HOST ?? '127.0.0.1';
|
|
22
27
|
const port = await startLocalServer({
|
|
23
28
|
rootDir: NOTEBOOK_APP_DIR,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notebook.js","sourceRoot":"","sources":["../../src/commands/notebook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"notebook.js","sourceRoot":"","sources":["../../src/commands/notebook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MA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
|
package/dist/local-runtime.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export interface LocalServerOptions {
|
|
|
46
46
|
rootDir: string;
|
|
47
47
|
projectRoot?: string;
|
|
48
48
|
executor: QueryExecutor;
|
|
49
|
-
connection
|
|
49
|
+
connection?: ConnectionConfig | null;
|
|
50
50
|
preferredPort: number;
|
|
51
51
|
/**
|
|
52
52
|
* Host the HTTP server binds to. Defaults to `127.0.0.1` (loopback only)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-runtime.d.ts","sourceRoot":"","sources":["../src/local-runtime.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAU9G,OAAO,EAmBL,KAAK,aAAa,EAClB,KAAK,2BAA2B,EAejC,MAAM,0BAA0B,CAAC;AAIlC,OAAO,KAAK,EAA4B,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EAcL,KAAK,gBAAgB,EAItB,MAAM,2BAA2B,CAAC;AAgDnC,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,gBAAgB,CAAC;IACrC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,2BAA2B,CAAC;IAC5C,GAAG,CAAC,EAAE;QACJ,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAA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AAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,gBAAgB,EAAE,CAoC7F;AA4ID,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EAAE,EACrB,UAAU,EAAE,gBAAgB,GAC3B,MAAM,CAcR;AA6ED,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBvE"}
|
package/dist/local-runtime.js
CHANGED
|
@@ -25,8 +25,14 @@ const NOTEBOOK_EXECUTE_PREVIEW_ROW_LIMIT = 500;
|
|
|
25
25
|
export async function startLocalServer(opts) {
|
|
26
26
|
const { rootDir, executor, connection: rawConnection, preferredPort, projectRoot = process.cwd() } = opts;
|
|
27
27
|
const bindHost = opts.host ?? process.env.DQL_HOST ?? '127.0.0.1';
|
|
28
|
-
let connection = normalizeProjectConnection(rawConnection, projectRoot);
|
|
28
|
+
let connection = rawConnection ? normalizeProjectConnection(rawConnection, projectRoot) : null;
|
|
29
29
|
let projectConfig = loadProjectConfig(projectRoot);
|
|
30
|
+
const requireActiveConnection = (candidate = connection) => {
|
|
31
|
+
if (!candidate) {
|
|
32
|
+
throw new Error('No database connection is configured yet. Open Connections, add a warehouse or local DuckDB/file connection, then retry.');
|
|
33
|
+
}
|
|
34
|
+
return candidate;
|
|
35
|
+
};
|
|
30
36
|
// Load semantic layer via provider system (dql native, dbt, cubejs, etc.)
|
|
31
37
|
let semanticLayer;
|
|
32
38
|
let semanticLayerErrors = [];
|
|
@@ -37,8 +43,9 @@ export async function startLocalServer(opts) {
|
|
|
37
43
|
const semanticConfig = projectConfig.semanticLayer;
|
|
38
44
|
let semanticLastSyncTime = null;
|
|
39
45
|
{
|
|
40
|
-
const
|
|
41
|
-
|
|
46
|
+
const semanticConnection = connection;
|
|
47
|
+
const executeQuery = semanticConfig?.provider === 'snowflake' && semanticConnection
|
|
48
|
+
? async (sql) => { const r = await executor.executeQuery(sql, [], {}, semanticConnection); return { rows: r.rows }; }
|
|
42
49
|
: undefined;
|
|
43
50
|
const result = await resolveSemanticLayerAsync(semanticConfig, projectRoot, executeQuery);
|
|
44
51
|
semanticLayer = result.layer;
|
|
@@ -58,7 +65,7 @@ export async function startLocalServer(opts) {
|
|
|
58
65
|
await refreshLocalMetadataCatalog(projectRoot);
|
|
59
66
|
// Auto-register data/ CSV and Parquet files as DuckDB views so semantic layer
|
|
60
67
|
// queries like `FROM orders` resolve without requiring read_csv_auto() in SQL.
|
|
61
|
-
if (connection.driver === 'file' || connection.driver === 'duckdb') {
|
|
68
|
+
if (connection && (connection.driver === 'file' || connection.driver === 'duckdb')) {
|
|
62
69
|
const dataDir = projectConfig.dataDir
|
|
63
70
|
? resolve(projectRoot, projectConfig.dataDir)
|
|
64
71
|
: join(projectRoot, 'data');
|
|
@@ -81,11 +88,12 @@ export async function startLocalServer(opts) {
|
|
|
81
88
|
}
|
|
82
89
|
}
|
|
83
90
|
const executeLocalSqlForStoredResult = async (sql) => {
|
|
91
|
+
const activeConnection = requireActiveConnection();
|
|
84
92
|
const semantic = prepareSemanticSql(sql, semanticLayer);
|
|
85
93
|
if (semantic.unresolvedRefs.length > 0) {
|
|
86
94
|
throw new Error(`Unknown semantic reference${semantic.unresolvedRefs.length > 1 ? 's' : ''}: ${semantic.unresolvedRefs.join(', ')}`);
|
|
87
95
|
}
|
|
88
|
-
const prepared = prepareLocalExecution(semantic.sql,
|
|
96
|
+
const prepared = prepareLocalExecution(semantic.sql, activeConnection, projectRoot, projectConfig);
|
|
89
97
|
const result = await executor.executeQuery(prepared.sql, [], runtimeVariables({}), prepared.connection);
|
|
90
98
|
return normalizeQueryResult(result, semantic.semanticRefs);
|
|
91
99
|
};
|
|
@@ -127,13 +135,14 @@ export async function startLocalServer(opts) {
|
|
|
127
135
|
config: (sourceCell.chartConfig ?? sourceCell.config),
|
|
128
136
|
};
|
|
129
137
|
const resolved = resolveNotebookBlockReferenceCell(cell, projectRoot);
|
|
130
|
-
const
|
|
131
|
-
const
|
|
138
|
+
const activeConnection = requireActiveConnection();
|
|
139
|
+
const tableMapping = await resolveSemanticTableMapping(executor, activeConnection, semanticLayer);
|
|
140
|
+
const plan = buildExecutionPlan(resolved.cell, { semanticLayer, driver: activeConnection.driver, tableMapping });
|
|
132
141
|
if (!plan) {
|
|
133
142
|
snapshotCells.push({ cellId, status: 'idle', executionCount: 0, executedAt });
|
|
134
143
|
continue;
|
|
135
144
|
}
|
|
136
|
-
const prepared = prepareLocalExecution(plan.sql,
|
|
145
|
+
const prepared = prepareLocalExecution(plan.sql, activeConnection, projectRoot, projectConfig);
|
|
137
146
|
assertAppAccess({ app, domain: resolved.domain ?? app.domain, level: 'execute' });
|
|
138
147
|
const rawResult = await executor.executeQuery(prepared.sql, plan.sqlParams, runtimeVariables(plan.variables), prepared.connection);
|
|
139
148
|
const result = normalizeQueryResult(rawResult);
|
|
@@ -189,22 +198,23 @@ export async function startLocalServer(opts) {
|
|
|
189
198
|
}
|
|
190
199
|
const absBlockPath = join(projectRoot, block.filePath);
|
|
191
200
|
const source = readFileSync(absBlockPath, 'utf-8');
|
|
192
|
-
const
|
|
201
|
+
const activeConnection = requireActiveConnection();
|
|
202
|
+
const tableMapping = await resolveSemanticTableMapping(executor, activeConnection, semanticLayer);
|
|
193
203
|
const semanticCompose = semanticLayer
|
|
194
204
|
? composeSemanticBlockSql(source, semanticLayer, {
|
|
195
|
-
driver:
|
|
205
|
+
driver: activeConnection.driver,
|
|
196
206
|
tableMapping,
|
|
197
207
|
projectRoot,
|
|
198
208
|
projectConfig,
|
|
199
209
|
detectedProvider: semanticDetectedProvider,
|
|
200
210
|
})
|
|
201
211
|
: null;
|
|
202
|
-
const plan = buildExecutionPlan({ id: `agent-${block.name}`, type: 'dql', source, title: block.name }, { semanticLayer, driver:
|
|
212
|
+
const plan = buildExecutionPlan({ id: `agent-${block.name}`, type: 'dql', source, title: block.name }, { semanticLayer, driver: activeConnection.driver, tableMapping });
|
|
203
213
|
if (!plan && !semanticCompose?.sql) {
|
|
204
214
|
const semanticError = semanticCompose?.diagnostics.find((diagnostic) => diagnostic.severity === 'error')?.message;
|
|
205
215
|
throw new Error(semanticError ?? `Block "${block.name}" produced no executable SQL.`);
|
|
206
216
|
}
|
|
207
|
-
const prepared = prepareLocalExecution(semanticCompose?.sql ?? plan.sql,
|
|
217
|
+
const prepared = prepareLocalExecution(semanticCompose?.sql ?? plan.sql, activeConnection, projectRoot, projectConfig);
|
|
208
218
|
const app = loadRuntimeApp(projectRoot, activePersonaAppId());
|
|
209
219
|
assertAppAccess({ app, domain: block.domain ?? app?.domain, level: 'execute' });
|
|
210
220
|
const rawResult = await executor.executeQuery(prepared.sql, plan?.sqlParams ?? [], runtimeVariables(plan?.variables ?? {}), prepared.connection);
|
|
@@ -221,12 +231,13 @@ export async function startLocalServer(opts) {
|
|
|
221
231
|
};
|
|
222
232
|
};
|
|
223
233
|
const executeGeneratedSqlForAgent = async (sql) => {
|
|
234
|
+
const activeConnection = requireActiveConnection();
|
|
224
235
|
const boundedSql = buildAgentPreviewSql(sql);
|
|
225
236
|
const semantic = prepareSemanticSql(boundedSql, semanticLayer);
|
|
226
237
|
if (semantic.unresolvedRefs.length > 0) {
|
|
227
238
|
throw new Error(`Unknown semantic reference${semantic.unresolvedRefs.length > 1 ? 's' : ''}: ${semantic.unresolvedRefs.join(', ')}`);
|
|
228
239
|
}
|
|
229
|
-
const prepared = prepareLocalExecution(semantic.sql,
|
|
240
|
+
const prepared = prepareLocalExecution(semantic.sql, activeConnection, projectRoot, projectConfig);
|
|
230
241
|
const app = loadRuntimeApp(projectRoot, activePersonaAppId());
|
|
231
242
|
assertAppAccess({ app, domain: app?.domain, level: 'execute' });
|
|
232
243
|
const rawResult = await executor.executeQuery(prepared.sql, [], runtimeVariables({}), prepared.connection);
|
|
@@ -242,10 +253,14 @@ export async function startLocalServer(opts) {
|
|
|
242
253
|
const getSchemaContextForAgent = async (question) => {
|
|
243
254
|
const catalogContext = await buildAgentSchemaContextFromCatalog(projectRoot, question).catch(() => []);
|
|
244
255
|
if (catalogContext.length > 0) {
|
|
256
|
+
if (!connection)
|
|
257
|
+
return catalogContext;
|
|
245
258
|
const enriched = await enrichAgentSchemaContextWithValueMatches(question, catalogContext, executor, connection);
|
|
246
259
|
recordAgentRuntimeSchemaSnapshot(projectRoot, enriched, 'catalog enriched runtime schema');
|
|
247
260
|
return enriched;
|
|
248
261
|
}
|
|
262
|
+
if (!connection)
|
|
263
|
+
return [];
|
|
249
264
|
try {
|
|
250
265
|
const result = await executor.executeQuery(`SELECT table_schema, table_name, column_name, data_type
|
|
251
266
|
FROM information_schema.columns
|
|
@@ -339,8 +354,9 @@ export async function startLocalServer(opts) {
|
|
|
339
354
|
}
|
|
340
355
|
// Hot-reload semantic layer on change and notify frontend
|
|
341
356
|
if (dir === 'semantic-layer') {
|
|
342
|
-
const
|
|
343
|
-
|
|
357
|
+
const semanticConnection = connection;
|
|
358
|
+
const executeQuery = semanticConfig?.provider === 'snowflake' && semanticConnection
|
|
359
|
+
? async (sql) => { const r = await executor.executeQuery(sql, [], {}, semanticConnection); return { rows: r.rows }; }
|
|
344
360
|
: undefined;
|
|
345
361
|
resolveSemanticLayerAsync(semanticConfig, projectRoot, executeQuery).then((refreshed) => {
|
|
346
362
|
if (refreshed.layer) {
|
|
@@ -384,13 +400,14 @@ export async function startLocalServer(opts) {
|
|
|
384
400
|
}
|
|
385
401
|
return { candidate: validated, errors };
|
|
386
402
|
};
|
|
387
|
-
const runBlockStudioPreviewSource = async (source, targetConnection
|
|
403
|
+
const runBlockStudioPreviewSource = async (source, targetConnection) => {
|
|
404
|
+
const activeConnection = requireActiveConnection(targetConnection);
|
|
388
405
|
let tableMapping;
|
|
389
406
|
if (semanticLayer) {
|
|
390
407
|
try {
|
|
391
408
|
const tablesResult = await executor.executeQuery(`SELECT table_schema, table_name
|
|
392
409
|
FROM information_schema.tables
|
|
393
|
-
WHERE table_schema NOT IN ('information_schema', 'pg_catalog')`, [], {},
|
|
410
|
+
WHERE table_schema NOT IN ('information_schema', 'pg_catalog')`, [], {}, activeConnection);
|
|
394
411
|
tableMapping = buildSemanticTableMapping(semanticLayer, tablesResult.rows);
|
|
395
412
|
}
|
|
396
413
|
catch {
|
|
@@ -399,7 +416,7 @@ export async function startLocalServer(opts) {
|
|
|
399
416
|
}
|
|
400
417
|
const semanticCompose = semanticLayer
|
|
401
418
|
? composeSemanticBlockSql(source, semanticLayer, {
|
|
402
|
-
driver:
|
|
419
|
+
driver: activeConnection.driver,
|
|
403
420
|
tableMapping,
|
|
404
421
|
projectRoot,
|
|
405
422
|
projectConfig,
|
|
@@ -414,8 +431,8 @@ export async function startLocalServer(opts) {
|
|
|
414
431
|
?? 'No executable SQL found in block source.';
|
|
415
432
|
throw new Error(message);
|
|
416
433
|
}
|
|
417
|
-
const plan = buildExecutionPlan({ id: 'block-studio', type: 'dql', source, title: 'Block Studio' }, { semanticLayer, driver:
|
|
418
|
-
const prepared = prepareLocalExecution(semanticCompose?.sql ?? plan?.sql ?? executableSql,
|
|
434
|
+
const plan = buildExecutionPlan({ id: 'block-studio', type: 'dql', source, title: 'Block Studio' }, { semanticLayer, driver: activeConnection.driver, tableMapping });
|
|
435
|
+
const prepared = prepareLocalExecution(semanticCompose?.sql ?? plan?.sql ?? executableSql, activeConnection, projectRoot, projectConfig);
|
|
419
436
|
const result = await executor.executeQuery(prepared.sql, plan?.sqlParams ?? [], runtimeVariables(plan?.variables ?? {}), prepared.connection);
|
|
420
437
|
return {
|
|
421
438
|
sql: prepared.sql,
|
|
@@ -423,10 +440,11 @@ export async function startLocalServer(opts) {
|
|
|
423
440
|
chartConfig: plan?.chartConfig ?? validation.chartConfig ?? null,
|
|
424
441
|
};
|
|
425
442
|
};
|
|
426
|
-
const runBlockStudioTestSummary = async (source, targetConnection
|
|
443
|
+
const runBlockStudioTestSummary = async (source, targetConnection) => {
|
|
444
|
+
const activeConnection = requireActiveConnection(targetConnection);
|
|
427
445
|
const start = Date.now();
|
|
428
|
-
const tableMapping = await resolveSemanticTableMapping(executor,
|
|
429
|
-
const plan = buildExecutionPlan({ id: 'block-studio-tests', type: 'dql', source, title: 'Block Studio' }, { semanticLayer, driver:
|
|
446
|
+
const tableMapping = await resolveSemanticTableMapping(executor, activeConnection, semanticLayer);
|
|
447
|
+
const plan = buildExecutionPlan({ id: 'block-studio-tests', type: 'dql', source, title: 'Block Studio' }, { semanticLayer, driver: activeConnection.driver, tableMapping });
|
|
430
448
|
const tests = plan?.tests ?? [];
|
|
431
449
|
if (!plan || !plan.sql) {
|
|
432
450
|
return {
|
|
@@ -445,7 +463,7 @@ export async function startLocalServer(opts) {
|
|
|
445
463
|
if (tests.length === 0) {
|
|
446
464
|
return { passed: 0, failed: 0, skipped: 0, duration: Date.now() - start, assertions: [], runAt: new Date() };
|
|
447
465
|
}
|
|
448
|
-
const prepared = prepareLocalExecution(plan.sql,
|
|
466
|
+
const prepared = prepareLocalExecution(plan.sql, activeConnection, projectRoot, projectConfig);
|
|
449
467
|
const rawResult = await executor.executeQuery(prepared.sql, plan.sqlParams ?? [], runtimeVariables(plan.variables ?? {}), prepared.connection);
|
|
450
468
|
const rows = Array.isArray(rawResult?.rows) ? rawResult.rows : [];
|
|
451
469
|
const columns = Array.isArray(rawResult?.columns)
|
|
@@ -1166,7 +1184,9 @@ export async function startLocalServer(opts) {
|
|
|
1166
1184
|
if (req.method === 'GET' && path === '/api/schema') {
|
|
1167
1185
|
try {
|
|
1168
1186
|
const dataFiles = scanDataFiles(projectRoot);
|
|
1169
|
-
const { tables, columnsByPath } =
|
|
1187
|
+
const { tables, columnsByPath } = connection
|
|
1188
|
+
? await introspectSchema(executor, connection)
|
|
1189
|
+
: { tables: [], columnsByPath: new Map() };
|
|
1170
1190
|
const dbTables = tables.map((t) => ({
|
|
1171
1191
|
name: t.path,
|
|
1172
1192
|
path: t.path,
|
|
@@ -1186,8 +1206,8 @@ export async function startLocalServer(opts) {
|
|
|
1186
1206
|
const message = error instanceof Error ? error.message : String(error);
|
|
1187
1207
|
console.warn(`[dql] /api/schema introspection failed: ${message}`);
|
|
1188
1208
|
const fallback = scanDataFiles(projectRoot).map((f) => ({ ...f, source: 'file' }));
|
|
1189
|
-
res.writeHead(
|
|
1190
|
-
res.end(serializeJSON(
|
|
1209
|
+
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
1210
|
+
res.end(serializeJSON(fallback));
|
|
1191
1211
|
}
|
|
1192
1212
|
return;
|
|
1193
1213
|
}
|
|
@@ -2258,7 +2278,7 @@ export async function startLocalServer(opts) {
|
|
|
2258
2278
|
};
|
|
2259
2279
|
const executeQuery = provider === 'snowflake'
|
|
2260
2280
|
? async (sql) => {
|
|
2261
|
-
const result = await executor.executeQuery(sql, [], {},
|
|
2281
|
+
const result = await executor.executeQuery(sql, [], {}, requireActiveConnection());
|
|
2262
2282
|
return { rows: result.rows };
|
|
2263
2283
|
}
|
|
2264
2284
|
: undefined;
|
|
@@ -2297,7 +2317,7 @@ export async function startLocalServer(opts) {
|
|
|
2297
2317
|
try {
|
|
2298
2318
|
const executeQuery = semanticImportManifest?.provider === 'snowflake'
|
|
2299
2319
|
? async (sql) => {
|
|
2300
|
-
const result = await executor.executeQuery(sql, [], {},
|
|
2320
|
+
const result = await executor.executeQuery(sql, [], {}, requireActiveConnection());
|
|
2301
2321
|
return { rows: result.rows };
|
|
2302
2322
|
}
|
|
2303
2323
|
: undefined;
|
|
@@ -2354,7 +2374,7 @@ export async function startLocalServer(opts) {
|
|
|
2354
2374
|
};
|
|
2355
2375
|
const executeQuery = provider === 'snowflake'
|
|
2356
2376
|
? async (sql) => {
|
|
2357
|
-
const result = await executor.executeQuery(sql, [], {},
|
|
2377
|
+
const result = await executor.executeQuery(sql, [], {}, requireActiveConnection());
|
|
2358
2378
|
return { rows: result.rows };
|
|
2359
2379
|
}
|
|
2360
2380
|
: undefined;
|
|
@@ -2386,7 +2406,7 @@ export async function startLocalServer(opts) {
|
|
|
2386
2406
|
try {
|
|
2387
2407
|
const executeQuery = semanticImportManifest?.provider === 'snowflake'
|
|
2388
2408
|
? async (sql) => {
|
|
2389
|
-
const result = await executor.executeQuery(sql, [], {},
|
|
2409
|
+
const result = await executor.executeQuery(sql, [], {}, requireActiveConnection());
|
|
2390
2410
|
return { rows: result.rows };
|
|
2391
2411
|
}
|
|
2392
2412
|
: undefined;
|
|
@@ -2620,8 +2640,11 @@ export async function startLocalServer(opts) {
|
|
|
2620
2640
|
}
|
|
2621
2641
|
// Try connector.listColumns() first
|
|
2622
2642
|
let columns = [];
|
|
2643
|
+
const activeConnection = connection;
|
|
2623
2644
|
try {
|
|
2624
|
-
|
|
2645
|
+
if (!activeConnection)
|
|
2646
|
+
throw new Error('No active connection');
|
|
2647
|
+
const connector = await executor.getConnector(activeConnection);
|
|
2625
2648
|
if (typeof connector.listColumns === 'function') {
|
|
2626
2649
|
const rawCols = await connector.listColumns(schemaName, tablePath);
|
|
2627
2650
|
columns = rawCols.map((c) => ({ name: c.name, type: c.dataType }));
|
|
@@ -2639,7 +2662,9 @@ export async function startLocalServer(opts) {
|
|
|
2639
2662
|
const sql = isFile
|
|
2640
2663
|
? `DESCRIBE SELECT * FROM read_csv_auto('${safePath}') LIMIT 0`
|
|
2641
2664
|
: `DESCRIBE ${qualifiedIdentifier}`;
|
|
2642
|
-
|
|
2665
|
+
if (!activeConnection)
|
|
2666
|
+
throw new Error('No active connection');
|
|
2667
|
+
const result = await executor.executeQuery(sql, [], {}, activeConnection);
|
|
2643
2668
|
columns = result.rows.map((row) => ({
|
|
2644
2669
|
name: String(row['column_name'] ?? row['Field'] ?? ''),
|
|
2645
2670
|
type: String(row['column_type'] ?? row['Type'] ?? ''),
|
|
@@ -2726,7 +2751,7 @@ export async function startLocalServer(opts) {
|
|
|
2726
2751
|
}));
|
|
2727
2752
|
return;
|
|
2728
2753
|
}
|
|
2729
|
-
const prepared = prepareLocalExecution(semantic.sql, isConnectionConfig(body.connection) ? body.connection : connection, projectRoot, projectConfig);
|
|
2754
|
+
const prepared = prepareLocalExecution(semantic.sql, requireActiveConnection(isConnectionConfig(body.connection) ? body.connection : connection), projectRoot, projectConfig);
|
|
2730
2755
|
const app = loadRuntimeApp(projectRoot, typeof body.appId === 'string' ? body.appId : activePersonaAppId());
|
|
2731
2756
|
const domain = typeof body.domain === 'string' ? body.domain : app?.domain;
|
|
2732
2757
|
assertAppAccess({ app, domain, level: 'execute' });
|
|
@@ -2770,7 +2795,7 @@ export async function startLocalServer(opts) {
|
|
|
2770
2795
|
const body = await readJSON(req);
|
|
2771
2796
|
const { metrics = [], dimensions = [], filters = [], limit, timeDimension, orderBy, savedQuery, engine } = body;
|
|
2772
2797
|
// Resolve which connection to use — request can override default
|
|
2773
|
-
const targetConnection = isConnectionConfig(body.connection) ? body.connection : connection;
|
|
2798
|
+
const targetConnection = requireActiveConnection(isConnectionConfig(body.connection) ? body.connection : connection);
|
|
2774
2799
|
const driver = targetConnection.driver;
|
|
2775
2800
|
// Build table mapping: resolve semantic model names to actual DB table names
|
|
2776
2801
|
let tableMapping;
|
|
@@ -2862,7 +2887,7 @@ export async function startLocalServer(opts) {
|
|
|
2862
2887
|
}
|
|
2863
2888
|
const body = await readJSON(req);
|
|
2864
2889
|
const { metrics = [], dimensions = [], filters = [], limit, timeDimension, orderBy, savedQuery, engine } = body;
|
|
2865
|
-
const targetConnection = isConnectionConfig(body.connection) ? body.connection : connection;
|
|
2890
|
+
const targetConnection = requireActiveConnection(isConnectionConfig(body.connection) ? body.connection : connection);
|
|
2866
2891
|
const driver = targetConnection.driver;
|
|
2867
2892
|
let tableMapping;
|
|
2868
2893
|
try {
|
|
@@ -2947,7 +2972,7 @@ export async function startLocalServer(opts) {
|
|
|
2947
2972
|
res.end(serializeJSON({ error: 'name and at least one metric are required.' }));
|
|
2948
2973
|
return;
|
|
2949
2974
|
}
|
|
2950
|
-
const targetConnection = isConnectionConfig(body.connection) ? body.connection : connection;
|
|
2975
|
+
const targetConnection = requireActiveConnection(isConnectionConfig(body.connection) ? body.connection : connection);
|
|
2951
2976
|
const composed = composeRuntimeSemanticQuery({
|
|
2952
2977
|
metrics,
|
|
2953
2978
|
dimensions,
|
|
@@ -3005,7 +3030,7 @@ export async function startLocalServer(opts) {
|
|
|
3005
3030
|
let target = connection;
|
|
3006
3031
|
try {
|
|
3007
3032
|
const body = await readJSON(req);
|
|
3008
|
-
target = normalizeProjectConnection(isConnectionConfig(body.connection) ? body.connection : connection, projectRoot);
|
|
3033
|
+
target = normalizeProjectConnection(requireActiveConnection(isConnectionConfig(body.connection) ? body.connection : connection), projectRoot);
|
|
3009
3034
|
const connector = await executor.getConnector(target);
|
|
3010
3035
|
const result = await validateConnectionForTest(connector, target);
|
|
3011
3036
|
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
@@ -3015,7 +3040,7 @@ export async function startLocalServer(opts) {
|
|
|
3015
3040
|
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
3016
3041
|
res.end(serializeJSON({
|
|
3017
3042
|
ok: false,
|
|
3018
|
-
message: formatConnectionTestError(target, error),
|
|
3043
|
+
message: target ? formatConnectionTestError(target, error) : error instanceof Error ? error.message : String(error),
|
|
3019
3044
|
}));
|
|
3020
3045
|
}
|
|
3021
3046
|
return;
|
|
@@ -3266,7 +3291,7 @@ export async function startLocalServer(opts) {
|
|
|
3266
3291
|
}
|
|
3267
3292
|
const resolved = resolveNotebookBlockReferenceCell(cell, projectRoot);
|
|
3268
3293
|
const executableCell = resolved.cell;
|
|
3269
|
-
const cellConnection = isConnectionConfig(body.connection) ? body.connection : connection;
|
|
3294
|
+
const cellConnection = requireActiveConnection(isConnectionConfig(body.connection) ? body.connection : connection);
|
|
3270
3295
|
const tableMapping = needsSemanticTableMapping(executableCell)
|
|
3271
3296
|
? await resolveSemanticTableMapping(executor, cellConnection, semanticLayer)
|
|
3272
3297
|
: undefined;
|
|
@@ -3276,7 +3301,7 @@ export async function startLocalServer(opts) {
|
|
|
3276
3301
|
res.end(serializeJSON({ cellType: cell.type, result: null }));
|
|
3277
3302
|
return;
|
|
3278
3303
|
}
|
|
3279
|
-
const prepared = prepareLocalExecution(plan.sql,
|
|
3304
|
+
const prepared = prepareLocalExecution(plan.sql, cellConnection, projectRoot, projectConfig);
|
|
3280
3305
|
const app = loadRuntimeApp(projectRoot, typeof body.appId === 'string' ? body.appId : activePersonaAppId());
|
|
3281
3306
|
assertAppAccess({ app, domain: resolved.domain ?? app?.domain, level: 'execute' });
|
|
3282
3307
|
const rawResult = await executor.executeQuery(prepared.sql, plan.sqlParams, runtimeVariables(plan.variables), prepared.connection);
|
|
@@ -4363,7 +4388,9 @@ async function introspectSchema(executor, connection) {
|
|
|
4363
4388
|
function buildDatabaseSchemaTree(projectRoot, executor, connection) {
|
|
4364
4389
|
return (async () => {
|
|
4365
4390
|
const dataFiles = scanDataFiles(projectRoot);
|
|
4366
|
-
const { tables: dbTables, columnsByPath: dbColumnsByPath } =
|
|
4391
|
+
const { tables: dbTables, columnsByPath: dbColumnsByPath } = connection
|
|
4392
|
+
? await introspectSchema(executor, connection)
|
|
4393
|
+
: { tables: [], columnsByPath: new Map() };
|
|
4367
4394
|
const schemaMap = new Map();
|
|
4368
4395
|
for (const table of dbTables) {
|
|
4369
4396
|
const schemaName = table.schema || 'default';
|
|
@@ -4399,20 +4426,22 @@ function buildDatabaseSchemaTree(projectRoot, executor, connection) {
|
|
|
4399
4426
|
const fileChildren = [];
|
|
4400
4427
|
for (const file of dataFiles) {
|
|
4401
4428
|
let columns = [];
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4429
|
+
if (connection) {
|
|
4430
|
+
try {
|
|
4431
|
+
const ext = file.name.split('.').pop()?.toLowerCase();
|
|
4432
|
+
const readFn = ext === 'parquet' ? 'read_parquet' : ext === 'json' ? 'read_json_auto' : 'read_csv_auto';
|
|
4433
|
+
const descResult = await executor.executeQuery(`DESCRIBE SELECT * FROM ${readFn}('${file.path.replace(/'/g, "''")}') LIMIT 0`, [], {}, connection);
|
|
4434
|
+
columns = descResult.rows.map((row) => ({
|
|
4435
|
+
id: `db-column:${file.path}:${String(row['column_name'] ?? '')}`,
|
|
4436
|
+
label: String(row['column_name'] ?? ''),
|
|
4437
|
+
kind: 'column',
|
|
4438
|
+
path: file.path,
|
|
4439
|
+
type: String(row['column_type'] ?? ''),
|
|
4440
|
+
}));
|
|
4441
|
+
}
|
|
4442
|
+
catch {
|
|
4443
|
+
// file column discovery failed — empty children is fine
|
|
4444
|
+
}
|
|
4416
4445
|
}
|
|
4417
4446
|
fileChildren.push({
|
|
4418
4447
|
id: `db-table:${file.path}`,
|