@duckcodeailabs/dql-cli 1.10.2 → 1.10.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/dist/assets/dql-notebook/assets/{index-DVimJaeG.js → index-VvEaTurJ.js} +207 -204
- package/dist/assets/dql-notebook/index.html +1 -1
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +38 -12
- package/dist/local-runtime.js.map +1 -1
- package/dist/package.json +10 -10
- package/dist/semantic-runtime.d.ts +88 -1
- package/dist/semantic-runtime.d.ts.map +1 -1
- package/dist/semantic-runtime.js +322 -25
- package/dist/semantic-runtime.js.map +1 -1
- package/package.json +10 -10
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duckcodeailabs/dql-cli",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.3",
|
|
4
4
|
"description": "Public CLI for parsing, formatting, testing, and certifying DQL blocks",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@anthropic-ai/sdk": "^0.104.2",
|
|
28
|
-
"@duckcodeailabs/dql-agent": "^1.10.
|
|
29
|
-
"@duckcodeailabs/dql-compiler": "^1.10.
|
|
30
|
-
"@duckcodeailabs/dql-connectors": "^1.10.
|
|
31
|
-
"@duckcodeailabs/dql-core": "^1.10.
|
|
32
|
-
"@duckcodeailabs/dql-governance": "^1.10.
|
|
33
|
-
"@duckcodeailabs/dql-mcp": "^1.10.
|
|
34
|
-
"@duckcodeailabs/dql-notebook": "^1.10.
|
|
35
|
-
"@duckcodeailabs/dql-project": "^1.10.
|
|
36
|
-
"@duckcodeailabs/dql-slack": "^1.10.
|
|
28
|
+
"@duckcodeailabs/dql-agent": "^1.10.3",
|
|
29
|
+
"@duckcodeailabs/dql-compiler": "^1.10.3",
|
|
30
|
+
"@duckcodeailabs/dql-connectors": "^1.10.3",
|
|
31
|
+
"@duckcodeailabs/dql-core": "^1.10.3",
|
|
32
|
+
"@duckcodeailabs/dql-governance": "^1.10.3",
|
|
33
|
+
"@duckcodeailabs/dql-mcp": "^1.10.3",
|
|
34
|
+
"@duckcodeailabs/dql-notebook": "^1.10.3",
|
|
35
|
+
"@duckcodeailabs/dql-project": "^1.10.3",
|
|
36
|
+
"@duckcodeailabs/dql-slack": "^1.10.3",
|
|
37
37
|
"isomorphic-git": "^1.27.0",
|
|
38
38
|
"js-yaml": "^4.1.0",
|
|
39
39
|
"node-cron": "^3.0.3",
|
|
@@ -55,6 +55,50 @@ export interface SemanticRuntimeQueryRequest {
|
|
|
55
55
|
savedQuery?: string;
|
|
56
56
|
engine?: 'native' | 'metricflow' | SemanticRuntimeAdapterId;
|
|
57
57
|
}
|
|
58
|
+
export type SemanticRuntimeBindingRole = 'dimension' | 'time_dimension' | 'filter' | 'order_by';
|
|
59
|
+
export interface SemanticRuntimeBinding {
|
|
60
|
+
role: SemanticRuntimeBindingRole;
|
|
61
|
+
/** Stable DQL/model-scoped identity shown to the analyst. */
|
|
62
|
+
authoringReference: string;
|
|
63
|
+
/** Exact dunder-qualified member sent to MetricFlow or dbt Cloud. */
|
|
64
|
+
runtimeReference: string;
|
|
65
|
+
/** Metric-relative entity path selected ahead of the member's own qualified name. */
|
|
66
|
+
entityPath: string[];
|
|
67
|
+
status: 'resolved' | 'ambiguous';
|
|
68
|
+
}
|
|
69
|
+
export interface SemanticRuntimePathCandidate {
|
|
70
|
+
/** Stable evidence identity used by Ask clarification and retry. */
|
|
71
|
+
id: string;
|
|
72
|
+
label: string;
|
|
73
|
+
description: string;
|
|
74
|
+
authoringReference: string;
|
|
75
|
+
runtimeReference: string;
|
|
76
|
+
entityPath: string[];
|
|
77
|
+
/** DQL-safe reference that preserves the model identity and the selected path. */
|
|
78
|
+
selectionReference: string;
|
|
79
|
+
}
|
|
80
|
+
export interface SemanticRuntimeTraceStep {
|
|
81
|
+
id: 'resolve_members' | 'bind_entity_paths' | 'compile_semantic_query' | 'execute_query';
|
|
82
|
+
label: string;
|
|
83
|
+
status: 'completed' | 'failed' | 'not_started';
|
|
84
|
+
detail: string;
|
|
85
|
+
}
|
|
86
|
+
export interface SemanticRuntimeTrace {
|
|
87
|
+
version: 1;
|
|
88
|
+
adapter: SemanticRuntimeAdapterId;
|
|
89
|
+
status: 'compiled' | 'ambiguous' | 'failed';
|
|
90
|
+
authoringRequest: SemanticRuntimeQueryRequest;
|
|
91
|
+
runtimeRequest?: SemanticRuntimeQueryRequest;
|
|
92
|
+
bindings: SemanticRuntimeBinding[];
|
|
93
|
+
warnings: string[];
|
|
94
|
+
steps: SemanticRuntimeTraceStep[];
|
|
95
|
+
failure?: {
|
|
96
|
+
code: 'SEMANTIC_PATH_AMBIGUOUS' | 'SEMANTIC_COMPILATION_FAILED';
|
|
97
|
+
phase: 'path_binding' | 'compilation';
|
|
98
|
+
message: string;
|
|
99
|
+
candidates?: SemanticRuntimePathCandidate[];
|
|
100
|
+
};
|
|
101
|
+
}
|
|
58
102
|
export interface SemanticRuntimeCompileContext {
|
|
59
103
|
projectRoot: string;
|
|
60
104
|
projectConfig: SemanticRuntimeProjectConfig;
|
|
@@ -78,6 +122,8 @@ export interface SemanticRuntimeCompileResult extends ComposeQueryResult {
|
|
|
78
122
|
* for native compilation (which speaks bare names). Diagnostic only.
|
|
79
123
|
*/
|
|
80
124
|
runtimeRequest?: SemanticRuntimeQueryRequest;
|
|
125
|
+
/** Auditable authoring → runtime bindings and compiler phases. */
|
|
126
|
+
semanticTrace: SemanticRuntimeTrace;
|
|
81
127
|
/** Non-fatal advisories (e.g. a time grain clamped up to the column's base). */
|
|
82
128
|
warnings?: string[];
|
|
83
129
|
}
|
|
@@ -90,6 +136,26 @@ export declare class SemanticRuntimeCompilationError extends Error {
|
|
|
90
136
|
readonly adapter: Exclude<SemanticRuntimeAdapterId, 'native'>;
|
|
91
137
|
constructor(adapter: Exclude<SemanticRuntimeAdapterId, 'native'>, error: unknown);
|
|
92
138
|
}
|
|
139
|
+
export declare class SemanticRuntimePathAmbiguityError extends Error {
|
|
140
|
+
readonly code = "SEMANTIC_PATH_AMBIGUOUS";
|
|
141
|
+
readonly adapter: Exclude<SemanticRuntimeAdapterId, 'native'>;
|
|
142
|
+
readonly details: {
|
|
143
|
+
authoringReference: string;
|
|
144
|
+
runtimeReference: string;
|
|
145
|
+
candidates: SemanticRuntimePathCandidate[];
|
|
146
|
+
};
|
|
147
|
+
readonly semanticTrace: SemanticRuntimeTrace;
|
|
148
|
+
constructor(input: {
|
|
149
|
+
adapter: Exclude<SemanticRuntimeAdapterId, 'native'>;
|
|
150
|
+
authoringRequest: SemanticRuntimeQueryRequest;
|
|
151
|
+
runtimeRequest: SemanticRuntimeQueryRequest;
|
|
152
|
+
bindings: SemanticRuntimeBinding[];
|
|
153
|
+
warnings: string[];
|
|
154
|
+
authoringReference: string;
|
|
155
|
+
runtimeReference: string;
|
|
156
|
+
candidates: SemanticRuntimePathCandidate[];
|
|
157
|
+
});
|
|
158
|
+
}
|
|
93
159
|
/**
|
|
94
160
|
* API-004 / AGT-001: MetricFlow requires `metric_time` whenever an input metric uses a time offset.
|
|
95
161
|
* dbt stores that requirement in the metric definition, so normalize it once at
|
|
@@ -127,7 +193,27 @@ export declare function explainMissingSemanticRuntime(projectRoot: string, dbtPr
|
|
|
127
193
|
export declare function qualifyForMetricFlow(request: SemanticRuntimeQueryRequest, semanticLayer: SemanticLayer): {
|
|
128
194
|
request: SemanticRuntimeQueryRequest;
|
|
129
195
|
warnings: string[];
|
|
196
|
+
bindings: SemanticRuntimeBinding[];
|
|
197
|
+
};
|
|
198
|
+
export declare function parseSemanticDimensionSelection(value: string): {
|
|
199
|
+
reference: string;
|
|
200
|
+
entityPath?: string[];
|
|
130
201
|
};
|
|
202
|
+
export declare function formatSemanticDimensionSelection(reference: string, entityPath: string[]): string;
|
|
203
|
+
export declare function applySemanticPathSelection(request: SemanticRuntimeQueryRequest, authoringReference: string, entityPath: string[]): SemanticRuntimeQueryRequest;
|
|
204
|
+
export declare function encodeSemanticPathEvidenceId(authoringReference: string, entityPath: string[]): string;
|
|
205
|
+
export declare function decodeSemanticPathEvidenceId(value: string | undefined): {
|
|
206
|
+
authoringReference: string;
|
|
207
|
+
entityPath: string[];
|
|
208
|
+
} | undefined;
|
|
209
|
+
export declare function semanticPathAmbiguityFromError(input: {
|
|
210
|
+
adapter: Exclude<SemanticRuntimeAdapterId, 'native'>;
|
|
211
|
+
error: unknown;
|
|
212
|
+
authoringRequest: SemanticRuntimeQueryRequest;
|
|
213
|
+
runtimeRequest: SemanticRuntimeQueryRequest;
|
|
214
|
+
bindings: SemanticRuntimeBinding[];
|
|
215
|
+
warnings: string[];
|
|
216
|
+
}): SemanticRuntimePathAmbiguityError | undefined;
|
|
131
217
|
export declare function compileSemanticRuntimeQuery(request: SemanticRuntimeQueryRequest, context: SemanticRuntimeCompileContext): Promise<SemanticRuntimeCompileResult | null>;
|
|
132
218
|
/**
|
|
133
219
|
* AGT-013/AGT-014/SEC-004: planning selects one adapter. Compilation may not
|
|
@@ -161,5 +247,6 @@ export declare function describeRuntimeCompatibility(projectRoot: string, semant
|
|
|
161
247
|
export declare function listRuntimeCompatibleDimensions(projectRoot: string, semanticLayer: SemanticLayer, metrics: string[], projectConfig?: SemanticRuntimeProjectConfig): Promise<Array<ReturnType<SemanticLayer['listDimensions']>[number]>>;
|
|
162
248
|
export declare function semanticMetricExecutionCapability(metricName: string, semanticLayer: SemanticLayer, provider: string, runtime: SemanticRuntimeStatus): SemanticMetricExecutionCapability;
|
|
163
249
|
export declare function isSemanticRuntimeError(error: unknown): boolean;
|
|
164
|
-
export declare function semanticRuntimeErrorCode(error: unknown): 'SEMANTIC_RUNTIME_REQUIRED' | 'SEMANTIC_COMPILATION_FAILED' | undefined;
|
|
250
|
+
export declare function semanticRuntimeErrorCode(error: unknown): 'SEMANTIC_RUNTIME_REQUIRED' | 'SEMANTIC_COMPILATION_FAILED' | 'SEMANTIC_PATH_AMBIGUOUS' | undefined;
|
|
251
|
+
export declare function semanticRuntimeErrorDetails(error: unknown): unknown;
|
|
165
252
|
//# sourceMappingURL=semantic-runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semantic-runtime.d.ts","sourceRoot":"","sources":["../src/semantic-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,kBAAkB,EAEvB,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAIL,KAAK,0BAA0B,EAChC,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAIL,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EAClC,MAAM,gCAAgC,CAAC;AAExC,MAAM,MAAM,wBAAwB,GAAG,QAAQ,GAAG,gBAAgB,GAAG,WAAW,CAAC;AACjF,MAAM,MAAM,6BAA6B,GAAG,OAAO,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAEvF,MAAM,WAAW,4BAA4B;IAC3C,aAAa,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5D,GAAG,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACrD;AAED,MAAM,WAAW,4BAA4B;IAC3C,EAAE,EAAE,wBAAwB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;IAC7C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC,UA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
}
|
|
24
|
+
export class SemanticRuntimePathAmbiguityError extends Error {
|
|
25
|
+
code = 'SEMANTIC_PATH_AMBIGUOUS';
|
|
26
|
+
adapter;
|
|
27
|
+
details;
|
|
28
|
+
semanticTrace;
|
|
29
|
+
constructor(input) {
|
|
30
|
+
const choices = input.candidates.map((candidate) => candidate.label).join(' or ');
|
|
31
|
+
const message = `The semantic dimension "${input.authoringReference}" is reachable through more than one governed entity path (${choices}). Choose the intended path before DQL compiles or executes the query.`;
|
|
32
|
+
super(message);
|
|
33
|
+
this.name = 'SemanticRuntimePathAmbiguityError';
|
|
34
|
+
this.adapter = input.adapter;
|
|
35
|
+
this.details = {
|
|
36
|
+
authoringReference: input.authoringReference,
|
|
37
|
+
runtimeReference: input.runtimeReference,
|
|
38
|
+
candidates: input.candidates,
|
|
39
|
+
};
|
|
40
|
+
this.semanticTrace = {
|
|
41
|
+
version: 1,
|
|
42
|
+
adapter: input.adapter,
|
|
43
|
+
status: 'ambiguous',
|
|
44
|
+
authoringRequest: input.authoringRequest,
|
|
45
|
+
runtimeRequest: input.runtimeRequest,
|
|
46
|
+
bindings: [
|
|
47
|
+
...input.bindings.filter((binding) => binding.runtimeReference !== input.runtimeReference),
|
|
48
|
+
{
|
|
49
|
+
role: inferSemanticBindingRole(input.authoringRequest, input.authoringReference),
|
|
50
|
+
authoringReference: input.authoringReference,
|
|
51
|
+
runtimeReference: input.runtimeReference,
|
|
52
|
+
entityPath: [],
|
|
53
|
+
status: 'ambiguous',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
warnings: input.warnings,
|
|
57
|
+
steps: [
|
|
58
|
+
{ id: 'resolve_members', label: 'Resolve governed semantic members', status: 'completed', detail: 'Metric and dimension identities resolved from the pinned semantic snapshot.' },
|
|
59
|
+
{ id: 'bind_entity_paths', label: 'Bind metric-relative entity paths', status: 'failed', detail: message },
|
|
60
|
+
{ id: 'compile_semantic_query', label: 'Compile with the selected semantic adapter', status: 'not_started', detail: 'Compilation is gated until one entity path is selected.' },
|
|
61
|
+
{ id: 'execute_query', label: 'Execute the compiled warehouse query', status: 'not_started', detail: 'Nothing was executed.' },
|
|
62
|
+
],
|
|
63
|
+
failure: {
|
|
64
|
+
code: 'SEMANTIC_PATH_AMBIGUOUS',
|
|
65
|
+
phase: 'path_binding',
|
|
66
|
+
message,
|
|
67
|
+
candidates: input.candidates,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
24
72
|
const cloudProbeCache = new Map();
|
|
25
73
|
const OFFSET_PARAMETER_KEYS = new Set(['offsetwindow', 'offsettograin']);
|
|
26
74
|
const METRIC_DEPENDENCY_KEYS = new Set([
|
|
@@ -328,25 +376,57 @@ export function qualifyForMetricFlow(request, semanticLayer) {
|
|
|
328
376
|
dim.source?.objectId,
|
|
329
377
|
dim.qualifiedName,
|
|
330
378
|
]) {
|
|
331
|
-
if (reference)
|
|
332
|
-
qualifiedByReference.set(reference.toLowerCase(),
|
|
379
|
+
if (reference) {
|
|
380
|
+
qualifiedByReference.set(reference.toLowerCase(), {
|
|
381
|
+
runtimeReference: dim.qualifiedName,
|
|
382
|
+
entityPath: dim.entityPath ?? [],
|
|
383
|
+
});
|
|
384
|
+
}
|
|
333
385
|
}
|
|
334
386
|
}
|
|
335
|
-
const
|
|
387
|
+
const bindings = [];
|
|
388
|
+
const qualify = (name, role) => {
|
|
336
389
|
if (!name)
|
|
337
390
|
return name;
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
391
|
+
const selection = parseSemanticDimensionSelection(name);
|
|
392
|
+
const authoringReference = selection.reference;
|
|
393
|
+
let runtimeReference;
|
|
394
|
+
let entityPath = selection.entityPath ?? [];
|
|
395
|
+
if (authoringReference === 'metric_time' || (authoringReference.includes('__') && !selection.entityPath)) {
|
|
396
|
+
runtimeReference = authoringReference;
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
const exact = semanticLayer.resolveDimension(authoringReference, request.metrics);
|
|
400
|
+
const compatibleBinding = qualifiedByReference.get(authoringReference.toLowerCase());
|
|
401
|
+
const baseRuntimeReference = compatibleBinding?.runtimeReference
|
|
402
|
+
?? exact?.qualifiedName
|
|
403
|
+
?? authoringReference;
|
|
404
|
+
if (selection.entityPath?.length) {
|
|
405
|
+
const prefix = `${selection.entityPath.join('__')}__`;
|
|
406
|
+
runtimeReference = baseRuntimeReference.startsWith(prefix)
|
|
407
|
+
? baseRuntimeReference
|
|
408
|
+
: `${prefix}${baseRuntimeReference}`;
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
runtimeReference = baseRuntimeReference;
|
|
412
|
+
entityPath = compatibleBinding?.entityPath ?? [];
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
bindings.push({
|
|
416
|
+
role,
|
|
417
|
+
authoringReference,
|
|
418
|
+
runtimeReference,
|
|
419
|
+
entityPath,
|
|
420
|
+
status: 'resolved',
|
|
421
|
+
});
|
|
422
|
+
return runtimeReference;
|
|
344
423
|
};
|
|
345
424
|
const timeDimension = request.timeDimension
|
|
346
425
|
? (() => {
|
|
347
|
-
const
|
|
426
|
+
const selection = parseSemanticDimensionSelection(request.timeDimension.name);
|
|
427
|
+
const name = qualify(request.timeDimension.name, 'time_dimension');
|
|
348
428
|
let granularity = request.timeDimension.granularity;
|
|
349
|
-
const td = semanticLayer.getTimeDimension(
|
|
429
|
+
const td = semanticLayer.getTimeDimension(selection.reference);
|
|
350
430
|
if (td?.granularities?.length && !td.granularities.includes(granularity)) {
|
|
351
431
|
const clamped = td.granularities[0];
|
|
352
432
|
warnings.push(`Time grain "${granularity}" is finer than ${request.timeDimension.name}'s base grain; using "${clamped}".`);
|
|
@@ -357,15 +437,148 @@ export function qualifyForMetricFlow(request, semanticLayer) {
|
|
|
357
437
|
: undefined;
|
|
358
438
|
return {
|
|
359
439
|
warnings,
|
|
440
|
+
bindings,
|
|
360
441
|
request: {
|
|
361
442
|
...request,
|
|
362
|
-
dimensions: request.dimensions.map((d) => qualify(d) ?? d),
|
|
363
|
-
...(request.filters ? { filters: request.filters.map((f) => f.dimension ? { ...f, dimension: qualify(f.dimension) } : f) } : {}),
|
|
364
|
-
...(request.orderBy ? { orderBy: request.orderBy.map((o) => ({ ...o, name: qualify(o.name) ?? o.name })) } : {}),
|
|
443
|
+
dimensions: request.dimensions.map((d) => qualify(d, 'dimension') ?? d),
|
|
444
|
+
...(request.filters ? { filters: request.filters.map((f) => f.dimension ? { ...f, dimension: qualify(f.dimension, 'filter') } : f) } : {}),
|
|
445
|
+
...(request.orderBy ? { orderBy: request.orderBy.map((o) => ({ ...o, name: qualify(o.name, 'order_by') ?? o.name })) } : {}),
|
|
365
446
|
...(timeDimension ? { timeDimension } : {}),
|
|
366
447
|
},
|
|
367
448
|
};
|
|
368
449
|
}
|
|
450
|
+
const SEMANTIC_PATH_SELECTION = /^(.*?)@via\(([^)]+)\)$/;
|
|
451
|
+
export function parseSemanticDimensionSelection(value) {
|
|
452
|
+
const match = value.trim().match(SEMANTIC_PATH_SELECTION);
|
|
453
|
+
if (!match)
|
|
454
|
+
return { reference: value };
|
|
455
|
+
const entityPath = match[2]
|
|
456
|
+
.split('>')
|
|
457
|
+
.map((part) => part.trim())
|
|
458
|
+
.filter((part) => /^[A-Za-z0-9_]+$/.test(part));
|
|
459
|
+
return entityPath.length > 0
|
|
460
|
+
? { reference: match[1].trim(), entityPath }
|
|
461
|
+
: { reference: match[1].trim() };
|
|
462
|
+
}
|
|
463
|
+
export function formatSemanticDimensionSelection(reference, entityPath) {
|
|
464
|
+
return entityPath.length > 0 ? `${reference}@via(${entityPath.join('>')})` : reference;
|
|
465
|
+
}
|
|
466
|
+
export function applySemanticPathSelection(request, authoringReference, entityPath) {
|
|
467
|
+
const bind = (value) => {
|
|
468
|
+
const parsed = parseSemanticDimensionSelection(value);
|
|
469
|
+
const selectedReference = parsed.reference.toLowerCase();
|
|
470
|
+
const requestedReference = authoringReference.toLowerCase();
|
|
471
|
+
const sameReference = selectedReference === requestedReference
|
|
472
|
+
|| ((!selectedReference.includes('.') || !requestedReference.includes('.'))
|
|
473
|
+
&& selectedReference.split('.').pop() === requestedReference.split('.').pop());
|
|
474
|
+
return sameReference ? formatSemanticDimensionSelection(parsed.reference, entityPath) : value;
|
|
475
|
+
};
|
|
476
|
+
return {
|
|
477
|
+
...request,
|
|
478
|
+
dimensions: request.dimensions.map(bind),
|
|
479
|
+
...(request.filters ? { filters: request.filters.map((filter) => filter.dimension ? { ...filter, dimension: bind(filter.dimension) } : filter) } : {}),
|
|
480
|
+
...(request.orderBy ? { orderBy: request.orderBy.map((order) => ({ ...order, name: bind(order.name) })) } : {}),
|
|
481
|
+
...(request.timeDimension ? { timeDimension: { ...request.timeDimension, name: bind(request.timeDimension.name) } } : {}),
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
export function encodeSemanticPathEvidenceId(authoringReference, entityPath) {
|
|
485
|
+
return `semantic-path:${encodeURIComponent(authoringReference)}:${encodeURIComponent(entityPath.join('>'))}`;
|
|
486
|
+
}
|
|
487
|
+
export function decodeSemanticPathEvidenceId(value) {
|
|
488
|
+
if (!value?.startsWith('semantic-path:'))
|
|
489
|
+
return undefined;
|
|
490
|
+
const [, encodedReference, encodedPath] = value.split(':');
|
|
491
|
+
if (!encodedReference || !encodedPath)
|
|
492
|
+
return undefined;
|
|
493
|
+
try {
|
|
494
|
+
const entityPath = decodeURIComponent(encodedPath).split('>').filter(Boolean);
|
|
495
|
+
return entityPath.length > 0
|
|
496
|
+
? { authoringReference: decodeURIComponent(encodedReference), entityPath }
|
|
497
|
+
: undefined;
|
|
498
|
+
}
|
|
499
|
+
catch {
|
|
500
|
+
return undefined;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
function inferSemanticBindingRole(request, authoringReference) {
|
|
504
|
+
const matches = (value) => parseSemanticDimensionSelection(value ?? '').reference.toLowerCase() === authoringReference.toLowerCase();
|
|
505
|
+
if (matches(request.timeDimension?.name))
|
|
506
|
+
return 'time_dimension';
|
|
507
|
+
if (request.filters?.some((filter) => matches(filter.dimension)))
|
|
508
|
+
return 'filter';
|
|
509
|
+
if (request.orderBy?.some((order) => matches(order.name)))
|
|
510
|
+
return 'order_by';
|
|
511
|
+
return 'dimension';
|
|
512
|
+
}
|
|
513
|
+
function semanticTraceForSuccess(input) {
|
|
514
|
+
return {
|
|
515
|
+
version: 1,
|
|
516
|
+
adapter: input.adapter,
|
|
517
|
+
status: 'compiled',
|
|
518
|
+
authoringRequest: input.authoringRequest,
|
|
519
|
+
...(input.runtimeRequest ? { runtimeRequest: input.runtimeRequest } : {}),
|
|
520
|
+
bindings: input.bindings,
|
|
521
|
+
warnings: input.warnings,
|
|
522
|
+
steps: [
|
|
523
|
+
{ id: 'resolve_members', label: 'Resolve governed semantic members', status: 'completed', detail: 'Metric and dimension identities resolved from the pinned semantic snapshot.' },
|
|
524
|
+
{ id: 'bind_entity_paths', label: 'Bind metric-relative entity paths', status: 'completed', detail: input.bindings.length > 0 ? `${input.bindings.length} runtime member binding(s) resolved.` : 'No dimension path binding was required.' },
|
|
525
|
+
{ id: 'compile_semantic_query', label: 'Compile with the selected semantic adapter', status: 'completed', detail: `Compiled through ${input.adapter}.` },
|
|
526
|
+
{ id: 'execute_query', label: 'Execute the compiled warehouse query', status: 'not_started', detail: 'Execution is owned by the authorized host after compilation.' },
|
|
527
|
+
],
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
export function semanticPathAmbiguityFromError(input) {
|
|
531
|
+
const message = input.error instanceof Error ? input.error.message : String(input.error);
|
|
532
|
+
if (!/ambiguous and can(?:not|'t) be resolved/i.test(message))
|
|
533
|
+
return undefined;
|
|
534
|
+
const parsedCandidates = [];
|
|
535
|
+
const candidatePattern = /(?:TimeDimension|Dimension)\(\s*['"]([^'"]+)['"][^)]*?entity_path=\[([^\]]*)\]/g;
|
|
536
|
+
for (const match of message.matchAll(candidatePattern)) {
|
|
537
|
+
const entityPath = Array.from(match[2].matchAll(/['"]([^'"]+)['"]/g), (item) => item[1]).filter(Boolean);
|
|
538
|
+
if (entityPath.length > 0)
|
|
539
|
+
parsedCandidates.push({ baseRuntimeReference: match[1], entityPath });
|
|
540
|
+
}
|
|
541
|
+
if (parsedCandidates.length < 2)
|
|
542
|
+
return undefined;
|
|
543
|
+
const runtimeReference = parsedCandidates[0].baseRuntimeReference;
|
|
544
|
+
const matchingBinding = input.bindings.find((binding) => binding.runtimeReference === runtimeReference);
|
|
545
|
+
const authoringReference = matchingBinding?.authoringReference
|
|
546
|
+
?? input.authoringRequest.timeDimension?.name
|
|
547
|
+
?? input.authoringRequest.dimensions[0]
|
|
548
|
+
?? runtimeReference;
|
|
549
|
+
const candidates = parsedCandidates.map((candidate) => {
|
|
550
|
+
const runtimeName = `${candidate.entityPath.join('__')}__${candidate.baseRuntimeReference}`;
|
|
551
|
+
return {
|
|
552
|
+
id: encodeSemanticPathEvidenceId(authoringReference, candidate.entityPath),
|
|
553
|
+
label: `Use ${authoringReference} via ${candidate.entityPath.join(' → ')}`,
|
|
554
|
+
description: `Bind the governed member to ${runtimeName}. No SQL will run until this path is selected.`,
|
|
555
|
+
authoringReference,
|
|
556
|
+
runtimeReference: runtimeName,
|
|
557
|
+
entityPath: candidate.entityPath,
|
|
558
|
+
selectionReference: formatSemanticDimensionSelection(authoringReference, candidate.entityPath),
|
|
559
|
+
};
|
|
560
|
+
});
|
|
561
|
+
return new SemanticRuntimePathAmbiguityError({
|
|
562
|
+
adapter: input.adapter,
|
|
563
|
+
authoringRequest: input.authoringRequest,
|
|
564
|
+
runtimeRequest: input.runtimeRequest,
|
|
565
|
+
bindings: input.bindings,
|
|
566
|
+
warnings: input.warnings,
|
|
567
|
+
authoringReference,
|
|
568
|
+
runtimeReference,
|
|
569
|
+
candidates,
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
function semanticRequestWithoutPathSelectors(request) {
|
|
573
|
+
const strip = (value) => parseSemanticDimensionSelection(value).reference;
|
|
574
|
+
return {
|
|
575
|
+
...request,
|
|
576
|
+
dimensions: request.dimensions.map(strip),
|
|
577
|
+
...(request.filters ? { filters: request.filters.map((filter) => filter.dimension ? { ...filter, dimension: strip(filter.dimension) } : filter) } : {}),
|
|
578
|
+
...(request.orderBy ? { orderBy: request.orderBy.map((order) => ({ ...order, name: strip(order.name) })) } : {}),
|
|
579
|
+
...(request.timeDimension ? { timeDimension: { ...request.timeDimension, name: strip(request.timeDimension.name) } } : {}),
|
|
580
|
+
};
|
|
581
|
+
}
|
|
369
582
|
export async function compileSemanticRuntimeQuery(request, context) {
|
|
370
583
|
const effectiveRequest = normalizeSemanticRuntimeQueryRequest(request, context.semanticLayer);
|
|
371
584
|
const status = await getSemanticRuntimeStatus(context.projectRoot, { probeConfiguredCloud: true });
|
|
@@ -375,7 +588,7 @@ export async function compileSemanticRuntimeQuery(request, context) {
|
|
|
375
588
|
const routeLockedToFullRuntime = candidates.length === 1 && candidates[0] !== 'native';
|
|
376
589
|
// Qualify dimension references to MetricFlow entity-qualified names ONCE, at
|
|
377
590
|
// this boundary, for the full-runtime engines. Native keeps the bare request.
|
|
378
|
-
const { request: runtimeRequest, warnings: qualifyWarnings } = qualifyForMetricFlow(effectiveRequest, context.semanticLayer);
|
|
591
|
+
const { request: runtimeRequest, warnings: qualifyWarnings, bindings, } = qualifyForMetricFlow(effectiveRequest, context.semanticLayer);
|
|
379
592
|
let lastRuntimeError;
|
|
380
593
|
for (const adapter of candidates) {
|
|
381
594
|
if (adapter === 'dbt-cloud') {
|
|
@@ -384,12 +597,37 @@ export async function compileSemanticRuntimeQuery(request, context) {
|
|
|
384
597
|
continue;
|
|
385
598
|
try {
|
|
386
599
|
const result = await compileDbtCloudSemanticQuery(getEffectiveDbtCloudSemanticSettings(context.projectRoot), runtimeRequest);
|
|
387
|
-
return {
|
|
600
|
+
return {
|
|
601
|
+
sql: result.sql,
|
|
602
|
+
joins: [],
|
|
603
|
+
tables: [],
|
|
604
|
+
engine: 'dbt-cloud',
|
|
605
|
+
effectiveRequest,
|
|
606
|
+
runtimeRequest,
|
|
607
|
+
semanticTrace: semanticTraceForSuccess({
|
|
608
|
+
adapter: 'dbt-cloud',
|
|
609
|
+
authoringRequest: effectiveRequest,
|
|
610
|
+
runtimeRequest,
|
|
611
|
+
bindings,
|
|
612
|
+
warnings: qualifyWarnings,
|
|
613
|
+
}),
|
|
614
|
+
warnings: qualifyWarnings,
|
|
615
|
+
};
|
|
388
616
|
}
|
|
389
617
|
catch (error) {
|
|
390
618
|
lastRuntimeError = error instanceof Error ? error : new Error(String(error));
|
|
391
619
|
if (isSemanticRuntimeError(error))
|
|
392
620
|
throw error;
|
|
621
|
+
const ambiguity = semanticPathAmbiguityFromError({
|
|
622
|
+
adapter: 'dbt-cloud',
|
|
623
|
+
error,
|
|
624
|
+
authoringRequest: effectiveRequest,
|
|
625
|
+
runtimeRequest,
|
|
626
|
+
bindings,
|
|
627
|
+
warnings: qualifyWarnings,
|
|
628
|
+
});
|
|
629
|
+
if (ambiguity)
|
|
630
|
+
throw ambiguity;
|
|
393
631
|
throw new SemanticRuntimeCompilationError('dbt-cloud', error);
|
|
394
632
|
}
|
|
395
633
|
}
|
|
@@ -412,27 +650,68 @@ export async function compileSemanticRuntimeQuery(request, context) {
|
|
|
412
650
|
limit: runtimeRequest.limit,
|
|
413
651
|
savedQuery: runtimeRequest.savedQuery,
|
|
414
652
|
});
|
|
415
|
-
return {
|
|
653
|
+
return {
|
|
654
|
+
sql: compiled.sql,
|
|
655
|
+
joins: [],
|
|
656
|
+
tables: [],
|
|
657
|
+
engine: 'metricflow-cli',
|
|
658
|
+
effectiveRequest,
|
|
659
|
+
runtimeRequest,
|
|
660
|
+
semanticTrace: semanticTraceForSuccess({
|
|
661
|
+
adapter: 'metricflow-cli',
|
|
662
|
+
authoringRequest: effectiveRequest,
|
|
663
|
+
runtimeRequest,
|
|
664
|
+
bindings,
|
|
665
|
+
warnings: qualifyWarnings,
|
|
666
|
+
}),
|
|
667
|
+
warnings: qualifyWarnings,
|
|
668
|
+
};
|
|
416
669
|
}
|
|
417
670
|
catch (error) {
|
|
418
671
|
lastRuntimeError = error instanceof Error ? error : new Error(String(error));
|
|
419
672
|
if (isSemanticRuntimeError(error))
|
|
420
673
|
throw error;
|
|
674
|
+
const ambiguity = semanticPathAmbiguityFromError({
|
|
675
|
+
adapter: 'metricflow-cli',
|
|
676
|
+
error,
|
|
677
|
+
authoringRequest: effectiveRequest,
|
|
678
|
+
runtimeRequest,
|
|
679
|
+
bindings,
|
|
680
|
+
warnings: qualifyWarnings,
|
|
681
|
+
});
|
|
682
|
+
if (ambiguity)
|
|
683
|
+
throw ambiguity;
|
|
421
684
|
throw new SemanticRuntimeCompilationError('metricflow-cli', error);
|
|
422
685
|
}
|
|
423
686
|
}
|
|
687
|
+
const nativeRequest = semanticRequestWithoutPathSelectors(effectiveRequest);
|
|
424
688
|
const composed = context.semanticLayer.composeQuery({
|
|
425
|
-
metrics:
|
|
426
|
-
dimensions:
|
|
427
|
-
filters:
|
|
428
|
-
limit:
|
|
429
|
-
timeDimension:
|
|
430
|
-
orderBy:
|
|
689
|
+
metrics: nativeRequest.metrics,
|
|
690
|
+
dimensions: nativeRequest.dimensions,
|
|
691
|
+
filters: nativeRequest.filters,
|
|
692
|
+
limit: nativeRequest.limit,
|
|
693
|
+
timeDimension: nativeRequest.timeDimension,
|
|
694
|
+
orderBy: nativeRequest.orderBy,
|
|
431
695
|
driver: context.driver,
|
|
432
696
|
tableMapping: context.tableMapping,
|
|
433
697
|
});
|
|
434
|
-
if (composed)
|
|
435
|
-
return {
|
|
698
|
+
if (composed) {
|
|
699
|
+
return {
|
|
700
|
+
...composed,
|
|
701
|
+
engine: 'native',
|
|
702
|
+
effectiveRequest,
|
|
703
|
+
semanticTrace: semanticTraceForSuccess({
|
|
704
|
+
adapter: 'native',
|
|
705
|
+
authoringRequest: effectiveRequest,
|
|
706
|
+
bindings: bindings.map((binding) => ({
|
|
707
|
+
...binding,
|
|
708
|
+
runtimeReference: parseSemanticDimensionSelection(binding.authoringReference).reference,
|
|
709
|
+
entityPath: [],
|
|
710
|
+
})),
|
|
711
|
+
warnings: [],
|
|
712
|
+
}),
|
|
713
|
+
};
|
|
714
|
+
}
|
|
436
715
|
}
|
|
437
716
|
if (fullRuntimeRequested || routeLockedToFullRuntime) {
|
|
438
717
|
throw lastRuntimeError ?? new SemanticRuntimeRequiredError(status.setup ?? 'The requested semantic runtime is unavailable.');
|
|
@@ -627,9 +906,12 @@ function selectActiveAdapter(preference, cloudReady, cliReady) {
|
|
|
627
906
|
export function isSemanticRuntimeError(error) {
|
|
628
907
|
return error instanceof SemanticRuntimeRequiredError
|
|
629
908
|
|| error instanceof SemanticRuntimeCompilationError
|
|
909
|
+
|| error instanceof SemanticRuntimePathAmbiguityError
|
|
630
910
|
|| error instanceof MetricFlowUnavailableError;
|
|
631
911
|
}
|
|
632
912
|
export function semanticRuntimeErrorCode(error) {
|
|
913
|
+
if (error instanceof SemanticRuntimePathAmbiguityError)
|
|
914
|
+
return error.code;
|
|
633
915
|
if (error instanceof SemanticRuntimeCompilationError)
|
|
634
916
|
return error.code;
|
|
635
917
|
if (error instanceof SemanticRuntimeRequiredError || error instanceof MetricFlowUnavailableError) {
|
|
@@ -637,4 +919,19 @@ export function semanticRuntimeErrorCode(error) {
|
|
|
637
919
|
}
|
|
638
920
|
return undefined;
|
|
639
921
|
}
|
|
922
|
+
export function semanticRuntimeErrorDetails(error) {
|
|
923
|
+
if (error instanceof SemanticRuntimePathAmbiguityError) {
|
|
924
|
+
return {
|
|
925
|
+
...error.details,
|
|
926
|
+
semanticTrace: error.semanticTrace,
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
if (error instanceof SemanticRuntimeCompilationError) {
|
|
930
|
+
return {
|
|
931
|
+
adapter: error.adapter,
|
|
932
|
+
phase: 'compilation',
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
return undefined;
|
|
936
|
+
}
|
|
640
937
|
//# sourceMappingURL=semantic-runtime.js.map
|