@malloy-publisher/server 0.17.0 → 0.17.2
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/admin-api-doc.yaml +2 -1
- package/dist/app/api-doc.yaml +212 -618
- package/dist/app/assets/{EnvironmentPage-D2-0ts2G.js → EnvironmentPage-DF2PahCR.js} +1 -1
- package/dist/app/assets/{HomePage-S_Bkczsx.js → HomePage-DIYlgPCz.js} +1 -1
- package/dist/app/assets/{MainPage-DEy4SyjJ.js → MainPage-C7PGAA5k.js} +1 -1
- package/dist/app/assets/ModelPage-BMoBnrW7.js +2 -0
- package/dist/app/assets/PackagePage-DD2vLSFe.js +1 -0
- package/dist/app/assets/{PackageSplatRoute-ChFCJOWE.js → PackageSplatRoute-BYIMwnLL.js} +2 -2
- package/dist/app/assets/{RenderedResult-BcEDcw0V.es-BD6PNbt6.js → RenderedResult-CYJ2Y9Fm.es-C8nokn71.js} +7 -7
- package/dist/app/assets/{RouteError-CDSSYdLB.js → RouteError-B8dE60Vs.js} +1 -1
- package/dist/app/assets/{ThemeEditorPage-DO2JWYOR.js → ThemeEditorPage-D0wf74fh.js} +1 -1
- package/dist/app/assets/{ToggleButtonGroup-BylAiUaK.js → ToggleButtonGroup-CX0_J2zR.js} +1 -1
- package/dist/app/assets/{documentRoutes-CaOt2rpR.js → documentRoutes-DgSMAc0m.js} +1 -1
- package/dist/app/assets/{editPageMounted-79YCIKgP.js → editPageMounted-BUGVg-_g.js} +2 -2
- package/dist/app/assets/{index-BOCBPBsi.js → index-BQL8UUcK.js} +1 -1
- package/dist/app/assets/{index-CPSEdm5f.js → index-BiOT4K_d.js} +1 -1
- package/dist/app/assets/{index-keJ8KKBp.js → index-DAQjZOAL.js} +1 -1
- package/dist/app/assets/index-DRkw60sj.js +512 -0
- package/dist/app/assets/{index.es-DTreXoC5.js → index.es-DgNl8IqU.js} +20 -20
- package/dist/app/assets/usePackageLinkNavigate-bHr_AFYo.js +1 -0
- package/dist/app/assets/{usePackageRoute-G6fA1__J.js → usePackageRoute-BhB6txS6.js} +1 -1
- package/dist/app/index.html +1 -1
- package/dist/app/mcp-app/report.js +2683 -757
- package/dist/instrumentation.mjs +4 -4
- package/dist/package_load_worker.mjs +364 -62
- package/dist/server.mjs +84274 -81768
- package/package.json +2 -2
- package/dist/app/assets/ModelPage-BVHjDM-u.js +0 -2
- package/dist/app/assets/PackagePage-Cbrg7o1X.js +0 -1
- package/dist/app/assets/index-BKjEX4_C.js +0 -512
- package/dist/app/assets/usePackageLinkNavigate-BfSAqkJS.js +0 -1
|
@@ -76,6 +76,71 @@ var init_constants = __esm(() => {
|
|
|
76
76
|
|
|
77
77
|
// src/service/deprecated/malloynb.ts
|
|
78
78
|
import { MalloySQLParser } from "@malloydata/malloy-sql";
|
|
79
|
+
function listMalloynbCellFindings(notebooks, limits) {
|
|
80
|
+
const warnings = [];
|
|
81
|
+
let listed = 0;
|
|
82
|
+
let unlisted = 0;
|
|
83
|
+
const past = [];
|
|
84
|
+
const pastByReason = new Map;
|
|
85
|
+
for (const { model, refusals } of notebooks) {
|
|
86
|
+
const shown = Math.max(0, Math.min(limits.perNotebook, limits.perPackage - listed));
|
|
87
|
+
const kept = refusals.slice(0, shown);
|
|
88
|
+
const rest = refusals.slice(shown);
|
|
89
|
+
warnings.push(...kept.map((r) => r.finding));
|
|
90
|
+
listed += kept.length;
|
|
91
|
+
if (rest.length === 0)
|
|
92
|
+
continue;
|
|
93
|
+
unlisted += rest.length;
|
|
94
|
+
if (kept.length === 0) {
|
|
95
|
+
past.push({ model, cells: rest.length });
|
|
96
|
+
for (const { finding } of rest) {
|
|
97
|
+
const reason = finding.reason ?? "unknown";
|
|
98
|
+
pastByReason.set(reason, (pastByReason.get(reason) ?? 0) + 1);
|
|
99
|
+
}
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const byReason = new Map;
|
|
103
|
+
for (const { cell, finding } of rest) {
|
|
104
|
+
const reason = finding.reason ?? "unknown";
|
|
105
|
+
const cells = byReason.get(reason);
|
|
106
|
+
if (cells)
|
|
107
|
+
cells.push(cell);
|
|
108
|
+
else
|
|
109
|
+
byReason.set(reason, [cell]);
|
|
110
|
+
}
|
|
111
|
+
const groups = Array.from(byReason, ([reason, cells]) => `${cells.length === 1 ? "cell" : "cells"} ${numberList(cells)} (${reason})`).join("; ");
|
|
112
|
+
warnings.push({
|
|
113
|
+
model,
|
|
114
|
+
code: MALLOYNB_CELLS_UNLISTED,
|
|
115
|
+
severity: "warn",
|
|
116
|
+
message: `${rest.length} more ${rest.length === 1 ? "cell" : "cells"} of ` + `${model} won't run for any reader in the Console, not listed ` + `one by one: ${groups}. ${FIX_AND_RELOAD}`
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (past.length > 0) {
|
|
120
|
+
const cells = past.reduce((sum, notebook) => sum + notebook.cells, 0);
|
|
121
|
+
const named = past.slice(0, limits.notebooksNamed).map((notebook) => `${notebook.cells} in ${notebook.model}`);
|
|
122
|
+
const others = past.slice(limits.notebooksNamed);
|
|
123
|
+
if (others.length > 0) {
|
|
124
|
+
const otherCells = others.reduce((sum, n) => sum + n.cells, 0);
|
|
125
|
+
named.push(`${otherCells} in ${others.length} other ` + `${others.length === 1 ? "notebook" : "notebooks"}`);
|
|
126
|
+
}
|
|
127
|
+
const reasons = Array.from(pastByReason, ([reason, count]) => `${count} ${reason}`);
|
|
128
|
+
warnings.push({
|
|
129
|
+
code: MALLOYNB_CELLS_UNLISTED,
|
|
130
|
+
severity: "warn",
|
|
131
|
+
message: `${cells} more ${cells === 1 ? "cell" : "cells"}, in ` + `${past.length} more ` + `${past.length === 1 ? "notebook" : "notebooks"}, won't run for ` + `any reader in the Console, not listed because the package lists ` + `at most ${limits.perPackage} one by one: ${wordList(named)}. ` + `By reason: ${wordList(reasons)}. ${FIX_AND_RELOAD}`
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return { warnings, unlisted };
|
|
135
|
+
}
|
|
136
|
+
function numberList(numbers) {
|
|
137
|
+
return wordList(numbers.map(String));
|
|
138
|
+
}
|
|
139
|
+
function wordList(words) {
|
|
140
|
+
if (words.length === 1)
|
|
141
|
+
return words[0];
|
|
142
|
+
return `${words.slice(0, -1).join(", ")} and ${words[words.length - 1]}`;
|
|
143
|
+
}
|
|
79
144
|
function isMalloynbPath(modelPath) {
|
|
80
145
|
return modelPath.endsWith(NOTEBOOK_FILE_SUFFIX);
|
|
81
146
|
}
|
|
@@ -83,8 +148,15 @@ function parseMalloynb(fileContents, modelPath) {
|
|
|
83
148
|
return MalloySQLParser.parse(fileContents.replace(/\r\n/g, `
|
|
84
149
|
`), modelPath);
|
|
85
150
|
}
|
|
151
|
+
var MALLOYNB_CELL_REFUSED = "malloynb-cell-refused", MALLOYNB_CELLS_UNLISTED = "malloynb-cells-unlisted", MALLOYNB_CELL_CHECK_FAILED = "malloynb-cell-check-failed", MALLOYNB_CELLS_LISTED, FIX_AND_RELOAD;
|
|
86
152
|
var init_malloynb = __esm(() => {
|
|
87
153
|
init_constants();
|
|
154
|
+
MALLOYNB_CELLS_LISTED = {
|
|
155
|
+
perNotebook: 10,
|
|
156
|
+
perPackage: 50,
|
|
157
|
+
notebooksNamed: 10
|
|
158
|
+
};
|
|
159
|
+
FIX_AND_RELOAD = "The legacy .malloynb section of docs/reports.md gives the fix for each " + "reason, and a reload after fixing lists what remains.";
|
|
88
160
|
});
|
|
89
161
|
|
|
90
162
|
// ../../node_modules/@opentelemetry/api/build/src/platform/node/globalThis.js
|
|
@@ -2167,7 +2239,7 @@ var init_query = __esm(() => {
|
|
|
2167
2239
|
type: integer({ min: 0 }),
|
|
2168
2240
|
default: DEFAULT_MAX_QUERY_ROWS,
|
|
2169
2241
|
description: "Row cap on ad-hoc connection SQL; 0 leaves only the byte cap.",
|
|
2170
|
-
notes: "Maximum rows returned per query on every query surface (`/connections/.../sqlQuery`, model query,
|
|
2242
|
+
notes: "Maximum rows returned per query on every query surface (`/connections/.../sqlQuery`, model query, MCP `executeQuery`). Forwarded to the connector / Malloy `runnable.run` as the effective row limit; queries that exceed the cap fail with HTTP 413. Set to `0` to disable. A caller-supplied `rowLimit` smaller than the cap is preserved.",
|
|
2171
2243
|
aliases: { env: ["PUBLISHER_MAX_QUERY_ROWS"] }
|
|
2172
2244
|
}),
|
|
2173
2245
|
setting({
|
|
@@ -2175,7 +2247,7 @@ var init_query = __esm(() => {
|
|
|
2175
2247
|
type: integer({ min: 0 }),
|
|
2176
2248
|
default: DEFAULT_MAX_RESPONSE_BYTES,
|
|
2177
2249
|
description: "Byte cap on ad-hoc connection SQL responses; 0 leaves only the row cap.",
|
|
2178
|
-
notes: "Maximum JSON-serialized response size, for ad-hoc SQL
|
|
2250
|
+
notes: "Maximum JSON-serialized response size, for ad-hoc SQL and model queries. Streaming-capable connections (Postgres, DuckDB) enforce mid-stream and abort the driver immediately; non-streaming connections enforce post-buffer. Exceeding the cap fails with HTTP 413. Set to `0` to disable. See the note below the table.",
|
|
2179
2251
|
defaultText: "`50000000` (50 MB)",
|
|
2180
2252
|
aliases: { env: ["PUBLISHER_MAX_RESPONSE_BYTES"] }
|
|
2181
2253
|
}),
|
|
@@ -2632,7 +2704,7 @@ var init_server = __esm(() => {
|
|
|
2632
2704
|
type: oneOf(["explorer", "viewer"]),
|
|
2633
2705
|
default: "explorer",
|
|
2634
2706
|
description: "The page the Console shows for a model, reported on /status as modelPage: explorer, or viewer, which builds no query and takes the Explorer out of the legacy notebook too.",
|
|
2635
|
-
notes: "`explorer` or `viewer`: the page the Console shows for a model, reported on `/status` as `modelPage`. `explorer` is the [Explorer](explorer.md), which
|
|
2707
|
+
notes: "`explorer` or `viewer`: the page the Console shows for a model, reported on `/status` as `modelPage`. `explorer` is the [Explorer](explorer.md), which builds queries; the server's restricted mode and `#(authorize)` bound what those queries can read. `viewer` shows the model viewer, which builds no query, and also takes the Explorer's \"Data sources\" dialog out of the legacy notebook; there a given's option list also quotes every name. The Console keeps both pages, and shows the viewer if `/status` cannot be read. Any other value fails startup.",
|
|
2636
2708
|
noFlag: true,
|
|
2637
2709
|
aliases: { env: ["PUBLISHER_MODEL_PAGE"] }
|
|
2638
2710
|
}),
|
|
@@ -13386,18 +13458,16 @@ ${body}`;
|
|
|
13386
13458
|
if (modelDef && runCount !== modelDef.queryList.length) {
|
|
13387
13459
|
return refuse({
|
|
13388
13460
|
line: 1,
|
|
13389
|
-
message: `Line 1: the notebook reader
|
|
13461
|
+
message: `Line 1: the notebook reader and the Malloy compiler disagree on the number of run: statements. The reader found ${runCount} and the compiler ${modelDef.queryList.length}. Fix: none in the file; report it.`
|
|
13390
13462
|
});
|
|
13391
13463
|
}
|
|
13392
13464
|
const cells = [];
|
|
13393
13465
|
const annotations = [];
|
|
13394
13466
|
let lineRun;
|
|
13395
|
-
let runsSeen = 0;
|
|
13396
13467
|
items.forEach((item, index) => {
|
|
13397
13468
|
const belowTag = index > artifactAt;
|
|
13398
13469
|
if (item.kind === "statement") {
|
|
13399
13470
|
lineRun = undefined;
|
|
13400
|
-
const queryIndex = item.run ? runsSeen++ : undefined;
|
|
13401
13471
|
const pushed = item.run && belowTag ? {
|
|
13402
13472
|
kind: "query",
|
|
13403
13473
|
type: "code",
|
|
@@ -13411,8 +13481,7 @@ ${body}`;
|
|
|
13411
13481
|
caption: item.caption
|
|
13412
13482
|
},
|
|
13413
13483
|
startLine: item.startLine,
|
|
13414
|
-
endLine: item.endLine
|
|
13415
|
-
queryIndex
|
|
13484
|
+
endLine: item.endLine
|
|
13416
13485
|
} : {
|
|
13417
13486
|
kind: "definition",
|
|
13418
13487
|
type: "code",
|
|
@@ -14043,7 +14112,7 @@ function internalErrorToHttpError(error, { log = true, onLogged } = {}) {
|
|
|
14043
14112
|
json: { code: status, message, problems: row.problems(error) }
|
|
14044
14113
|
};
|
|
14045
14114
|
}
|
|
14046
|
-
const answer = httpError(status, message,
|
|
14115
|
+
const answer = httpError(status, message, errorReason(error));
|
|
14047
14116
|
const refusalReason = row.refusalReason?.(error);
|
|
14048
14117
|
if (refusalReason !== undefined)
|
|
14049
14118
|
answer.json.refusalReason = refusalReason;
|
|
@@ -14095,6 +14164,9 @@ function errorKind(error) {
|
|
|
14095
14164
|
function errorMapping(error) {
|
|
14096
14165
|
return ERROR_TABLE[errorKind(error)];
|
|
14097
14166
|
}
|
|
14167
|
+
function errorReason(error) {
|
|
14168
|
+
return resolve(errorMapping(error).reason, error);
|
|
14169
|
+
}
|
|
14098
14170
|
var GENERIC_INTERNAL_MESSAGE = "Internal server error.", GENERIC_UPSTREAM_MESSAGE = "Upstream connection error.", GENERIC_UNREACHABLE_MESSAGE = "The database connection is down: the database could not be reached, so the query did not run.", GENERIC_AUTH_MESSAGE = "The database rejected the connection's credentials. Check the connection's user, password, key or token.", MAX_LOGGED_DETAIL_CHARS = 2000, PACKAGE_VERSION_ERROR_STATUS, PackageVersionError, FILESYSTEM_ACCESS_DESCRIPTIONS, POSTGRES_STATEMENT_SQLSTATES, POSTGRES_UNDEFINED_TABLE = "42P01", POSTGRES_RELATION_MISSING, BuildPlanUnavailableError, BuildPlanRefreshingError, NotImplementedError, BadRequestError, BuildInstructionsInvalidError, TableOwnershipError, InvalidArgumentError, CompileRefusedError, InvalidModelPathError, InvalidQueryRequestError, RenderTagRefusedError, UnparseableTextError, EnvironmentNotFoundError, PackageNotFoundError, ModelNotFoundError, DashboardNotFoundError, SkillNotFoundError, AgentNotFoundError, ConflictError, ConnectionNotFoundError, TableNotFoundError, ConnectionError, ConnectionFailedError, ResultTruncatedError, UnconfiguredConnectionError, ConnectionPoolExhaustedError, ResultShapeError, DestinationNotFoundError, StorageDestinationNotFoundError, StorageCatalogNotFoundError, ConnectionAuthError, StorageAccessDeniedError, UnsupportedCatalogFormatError, ModelCompilationError, VersionFilesMissingError, PackageManifestError, MaterializationEligibilityError, ChainedUpstreamMissingError, ChainedShapeNotCarriedError, WarehouseRecomputeRefusedError, PublisherConfigError, ServerConfigurationError, FrozenConfigError, AccessDeniedError, QueryCompileError, NotQueryableError, OffSurfaceError, MaterializationNotFoundError, MaterializationConflictError, MaterializedTableDropRefusedError, WriteConflictError, InstalledFromLocationError, WriteRolledBackError, WriteRollbackFailedError, ConnectionSaveError, WriteVerifyError, InvalidStateTransitionError, ServiceUnavailableError, PackageAdmissionRefusedError, DryRunCapacityError, PayloadTooLargeError, ResponseUnserializableError, QueryTimeoutError, ERROR_CLASSES, UNHANDLED_LOG, UNHANDLED, NOT_TRANSIENT_CHANGE_QUERY = "This is not transient. The same query will fail the same way, so change the query rather than retrying it.", BACK_PRESSURE_SUGGESTIONS, BACK_PRESSURE, TOO_LARGE, BAD_REQUEST, NOT_FOUND, CONNECTION, ERROR_TABLE;
|
|
14099
14171
|
var init_errors2 = __esm(() => {
|
|
14100
14172
|
init_constants();
|
|
@@ -15513,6 +15585,9 @@ function probeFilterList(view) {
|
|
|
15513
15585
|
const ref = view.structRef;
|
|
15514
15586
|
return ref?.filterList;
|
|
15515
15587
|
}
|
|
15588
|
+
function requiresUniqueKey(requirement) {
|
|
15589
|
+
return requirement !== undefined && requirement !== false;
|
|
15590
|
+
}
|
|
15516
15591
|
function joinGrainAggregatePaths(view) {
|
|
15517
15592
|
const out = [];
|
|
15518
15593
|
let unreadable = false;
|
|
@@ -15527,9 +15602,9 @@ function joinGrainAggregatePaths(view) {
|
|
|
15527
15602
|
const usage = node.expandedFieldUsage;
|
|
15528
15603
|
if (Array.isArray(usage)) {
|
|
15529
15604
|
for (const u of usage) {
|
|
15530
|
-
if (!u || u.uniqueKeyRequirement
|
|
15605
|
+
if (!u || !requiresUniqueKey(u.uniqueKeyRequirement))
|
|
15531
15606
|
continue;
|
|
15532
|
-
if (!Array.isArray(u.path) || u.path.some((p) => typeof p !== "string")) {
|
|
15607
|
+
if (u.uniqueKeyRequirement !== true || !Array.isArray(u.path) || u.path.some((p) => typeof p !== "string")) {
|
|
15533
15608
|
unreadable = true;
|
|
15534
15609
|
continue;
|
|
15535
15610
|
}
|
|
@@ -15819,9 +15894,9 @@ function aggregateOutsideJoin(view, sourceDef, join) {
|
|
|
15819
15894
|
if (!Array.isArray(usage))
|
|
15820
15895
|
return;
|
|
15821
15896
|
for (const u of usage) {
|
|
15822
|
-
if (!u || u.uniqueKeyRequirement
|
|
15897
|
+
if (!u || !requiresUniqueKey(u.uniqueKeyRequirement))
|
|
15823
15898
|
continue;
|
|
15824
|
-
if (!Array.isArray(u.path)) {
|
|
15899
|
+
if (u.uniqueKeyRequirement !== true || !Array.isArray(u.path)) {
|
|
15825
15900
|
unreadable = true;
|
|
15826
15901
|
continue;
|
|
15827
15902
|
}
|
|
@@ -25601,17 +25676,6 @@ var init_model_load_checks = __esm(() => {
|
|
|
25601
25676
|
|
|
25602
25677
|
// src/service/model_notebook_cell.ts
|
|
25603
25678
|
import { MalloySQLStatementType } from "@malloydata/malloy-sql";
|
|
25604
|
-
function declaredGivensPerCell(cells) {
|
|
25605
|
-
return cells.map((cell) => {
|
|
25606
|
-
if (!cell.modelDef)
|
|
25607
|
-
return;
|
|
25608
|
-
const registry = cell.modelDef.givens ?? {};
|
|
25609
|
-
return {
|
|
25610
|
-
ids: new Set(Object.keys(registry)),
|
|
25611
|
-
names: new Set(Object.values(registry).map((g) => g.name))
|
|
25612
|
-
};
|
|
25613
|
-
});
|
|
25614
|
-
}
|
|
25615
25679
|
async function tileQueryInfo(materializer, text) {
|
|
25616
25680
|
try {
|
|
25617
25681
|
const def = (await materializer.extendModel(text).getModel())._modelDef;
|
|
@@ -25669,7 +25733,6 @@ async function compileNotebookCells(runtime, importBaseURL, statements) {
|
|
|
25669
25733
|
cells.push({
|
|
25670
25734
|
type: "code",
|
|
25671
25735
|
text: statement.text,
|
|
25672
|
-
materializer,
|
|
25673
25736
|
modelDef,
|
|
25674
25737
|
newSources,
|
|
25675
25738
|
query,
|
|
@@ -28587,6 +28650,49 @@ function queryTimezoneOf(structDef) {
|
|
|
28587
28650
|
}
|
|
28588
28651
|
return typeof tz === "string" && tz !== "" ? tz : undefined;
|
|
28589
28652
|
}
|
|
28653
|
+
function sameZone(a, b) {
|
|
28654
|
+
const utc = (z) => z === "UTC" ? undefined : z;
|
|
28655
|
+
return utc(a) === utc(b);
|
|
28656
|
+
}
|
|
28657
|
+
function queryStageZone(def) {
|
|
28658
|
+
const query = def?.query;
|
|
28659
|
+
const stages = Array.isArray(query?.pipeline) ? query.pipeline : [];
|
|
28660
|
+
if (stages.length === 0)
|
|
28661
|
+
return;
|
|
28662
|
+
const zoneOf = (x) => {
|
|
28663
|
+
const z = x?.queryTimezone;
|
|
28664
|
+
return typeof z === "string" && z !== "" ? z : undefined;
|
|
28665
|
+
};
|
|
28666
|
+
const base = query?.structRef;
|
|
28667
|
+
if (base === null || typeof base !== "object" || base.query !== undefined || base.type === "query_source") {
|
|
28668
|
+
return;
|
|
28669
|
+
}
|
|
28670
|
+
const own = stages.map(zoneOf);
|
|
28671
|
+
const zones = own.filter((z) => z !== undefined);
|
|
28672
|
+
if (own.some((z) => z === undefined))
|
|
28673
|
+
zones.push(zoneOf(base));
|
|
28674
|
+
const [first, ...rest] = zones;
|
|
28675
|
+
return rest.every((z) => sameZone(z, first)) ? { zone: first } : undefined;
|
|
28676
|
+
}
|
|
28677
|
+
function stageZonedTruncations(def) {
|
|
28678
|
+
const d = def;
|
|
28679
|
+
if (d?.query === undefined)
|
|
28680
|
+
return new Set;
|
|
28681
|
+
if (queryTimezoneOf(d) === undefined && !anyTimezone(d.query)) {
|
|
28682
|
+
return new Set;
|
|
28683
|
+
}
|
|
28684
|
+
const stage = queryStageZone(d);
|
|
28685
|
+
if (stage !== undefined && sameZone(stage.zone, undefined)) {
|
|
28686
|
+
return new Set;
|
|
28687
|
+
}
|
|
28688
|
+
return new Set((d.fields ?? []).filter((f) => typeof f.timeframe === "string" && f.e === undefined && (f.type === "timestamp" || f.type === "timestamptz")).map((f) => String(f.as ?? f.name)));
|
|
28689
|
+
}
|
|
28690
|
+
function anyTimezone(node, depth = 0) {
|
|
28691
|
+
if (!node || typeof node !== "object" || depth > MAX_WALK_DEPTH) {
|
|
28692
|
+
return depth > MAX_WALK_DEPTH;
|
|
28693
|
+
}
|
|
28694
|
+
return Object.entries(node).some(([k, v]) => k === "queryTimezone" ? typeof v === "string" && v !== "" : anyTimezone(v, depth + 1));
|
|
28695
|
+
}
|
|
28590
28696
|
function readsAGiven(node, seen = new WeakSet, depth = 0) {
|
|
28591
28697
|
if (depth > MAX_WALK_DEPTH) {
|
|
28592
28698
|
throw new Error("given walk exceeded max depth");
|
|
@@ -28673,6 +28779,7 @@ var init_dialect = __esm(() => {
|
|
|
28673
28779
|
castsToIntegerType: false,
|
|
28674
28780
|
onlyBigIntegerType: undefined,
|
|
28675
28781
|
foldsTableNameCase: false,
|
|
28782
|
+
decodedTablePath: false,
|
|
28676
28783
|
utcSessions: false,
|
|
28677
28784
|
leafBudget: 50,
|
|
28678
28785
|
passthroughNumericAsDouble: false,
|
|
@@ -28694,6 +28801,7 @@ var init_dialect = __esm(() => {
|
|
|
28694
28801
|
driverKeepsBigIntegers: true,
|
|
28695
28802
|
castsToIntegerType: true,
|
|
28696
28803
|
foldsTableNameCase: true,
|
|
28804
|
+
decodedTablePath: true,
|
|
28697
28805
|
utcSessions: true,
|
|
28698
28806
|
leafBudget: 120,
|
|
28699
28807
|
stringCollation: "instance",
|
|
@@ -28707,6 +28815,7 @@ var init_dialect = __esm(() => {
|
|
|
28707
28815
|
incrementalTargetDml: true,
|
|
28708
28816
|
merge: true,
|
|
28709
28817
|
mergeGatedByServerVersion: true,
|
|
28818
|
+
decodedTablePath: true,
|
|
28710
28819
|
transactionalSwap: true,
|
|
28711
28820
|
dependencyGuard: true,
|
|
28712
28821
|
relationProbe: true,
|
|
@@ -28734,6 +28843,7 @@ var init_dialect = __esm(() => {
|
|
|
28734
28843
|
}),
|
|
28735
28844
|
standardsql: Object.freeze({
|
|
28736
28845
|
...NONE,
|
|
28846
|
+
decodedTablePath: true,
|
|
28737
28847
|
incrementalSourceRange: true,
|
|
28738
28848
|
incrementalTargetDml: true,
|
|
28739
28849
|
merge: true,
|
|
@@ -28743,7 +28853,7 @@ var init_dialect = __esm(() => {
|
|
|
28743
28853
|
castsToIntegerType: true,
|
|
28744
28854
|
onlyBigIntegerType: "INT64",
|
|
28745
28855
|
leafBudget: 120,
|
|
28746
|
-
stringCollation: "
|
|
28856
|
+
stringCollation: "dataset",
|
|
28747
28857
|
ungroupableTypes: {
|
|
28748
28858
|
malloy: ["json", "array", "record"],
|
|
28749
28859
|
native: ["geography"]
|
|
@@ -28751,6 +28861,7 @@ var init_dialect = __esm(() => {
|
|
|
28751
28861
|
}),
|
|
28752
28862
|
snowflake: Object.freeze({
|
|
28753
28863
|
...NONE,
|
|
28864
|
+
decodedTablePath: true,
|
|
28754
28865
|
catalogHidesTables: true,
|
|
28755
28866
|
incrementalSourceRange: true,
|
|
28756
28867
|
incrementalTargetDml: true,
|
|
@@ -29966,6 +30077,39 @@ function skipAnnotation(text, i, blank) {
|
|
|
29966
30077
|
}
|
|
29967
30078
|
return at;
|
|
29968
30079
|
}
|
|
30080
|
+
function annotationsBefore(text, from, to) {
|
|
30081
|
+
let found = [];
|
|
30082
|
+
const keep = () => {
|
|
30083
|
+
return;
|
|
30084
|
+
};
|
|
30085
|
+
let i = from;
|
|
30086
|
+
while (i < to) {
|
|
30087
|
+
const code = text.charCodeAt(i);
|
|
30088
|
+
if (isSpaceCode(code, text, i)) {
|
|
30089
|
+
i += unitsAt(text, i);
|
|
30090
|
+
continue;
|
|
30091
|
+
}
|
|
30092
|
+
let end = -1;
|
|
30093
|
+
if (code === 35) {
|
|
30094
|
+
end = skipAnnotation(text, i, keep);
|
|
30095
|
+
if (end >= 0) {
|
|
30096
|
+
found.push({ from: i, to: end, model: text.startsWith("##", i) });
|
|
30097
|
+
}
|
|
30098
|
+
} else if (text.startsWith("--", i) || text.startsWith("//", i)) {
|
|
30099
|
+
end = toEndOfLine(text, i);
|
|
30100
|
+
} else if (text.startsWith("/*", i)) {
|
|
30101
|
+
const close = text.indexOf("*/", i + 2);
|
|
30102
|
+
end = close === -1 ? text.length : close + 2;
|
|
30103
|
+
}
|
|
30104
|
+
if (end < 0) {
|
|
30105
|
+
found = [];
|
|
30106
|
+
i += unitsAt(text, i);
|
|
30107
|
+
continue;
|
|
30108
|
+
}
|
|
30109
|
+
i = end;
|
|
30110
|
+
}
|
|
30111
|
+
return found;
|
|
30112
|
+
}
|
|
29969
30113
|
function closesBlock(text, at, column, closer) {
|
|
29970
30114
|
for (let c = 0;c < column; c++) {
|
|
29971
30115
|
const code = text.charCodeAt(at + c);
|
|
@@ -33123,6 +33267,14 @@ function sourceReads(source) {
|
|
|
33123
33267
|
return;
|
|
33124
33268
|
}
|
|
33125
33269
|
}
|
|
33270
|
+
function queryTableReads(entry, pipeline) {
|
|
33271
|
+
return sourceReads({
|
|
33272
|
+
_sourceDef: {
|
|
33273
|
+
type: "query_source",
|
|
33274
|
+
query: { structRef: entry, pipeline }
|
|
33275
|
+
}
|
|
33276
|
+
});
|
|
33277
|
+
}
|
|
33126
33278
|
var MAX_DEPTH = 200, Unknown;
|
|
33127
33279
|
var init_source_reads = __esm(() => {
|
|
33128
33280
|
Unknown = class Unknown extends Error {
|
|
@@ -35845,6 +35997,15 @@ function storedColumnsOfOutput(fields, options) {
|
|
|
35845
35997
|
}
|
|
35846
35998
|
return out;
|
|
35847
35999
|
}
|
|
36000
|
+
function spelledNativeType(nativeType, dialect) {
|
|
36001
|
+
if (isArrayType(nativeType))
|
|
36002
|
+
return;
|
|
36003
|
+
const [spelled] = storedColumnsOfOutput([{ name: "c", ...getDialect2(dialect).sqlTypeToMalloyType(nativeType) }], { nested: false, bigint: true, timestamptz: true });
|
|
36004
|
+
return spelled?.type;
|
|
36005
|
+
}
|
|
36006
|
+
function isArrayType(type) {
|
|
36007
|
+
return /\[\s*\d*\s*\]\s*$/.test(type) || /^\s*ARRAY\b/i.test(type);
|
|
36008
|
+
}
|
|
35848
36009
|
function storedTypeOfField(field, nested, depth, bigint = false, timestamptz = false) {
|
|
35849
36010
|
if (depth > 16 || field === null || typeof field !== "object") {
|
|
35850
36011
|
return;
|
|
@@ -36367,6 +36528,50 @@ function extractRunTargetSourceNames(query) {
|
|
|
36367
36528
|
}
|
|
36368
36529
|
return [];
|
|
36369
36530
|
}
|
|
36531
|
+
function lastRunStatementText(text) {
|
|
36532
|
+
const tokens = tokenize2(stripMalloyCommentsAndLiterals(text));
|
|
36533
|
+
const colonStatement = (k, words) => words.some((word) => isWord(tokens, k, word)) && textIs(tokens, k + 1, ":");
|
|
36534
|
+
let depth = 0;
|
|
36535
|
+
let open = -1;
|
|
36536
|
+
let last = -1;
|
|
36537
|
+
let found;
|
|
36538
|
+
for (let k = 0;k < tokens.count; k++) {
|
|
36539
|
+
const opens = depth === 0 && (textIs(tokens, k, ";") || isWord(tokens, k, "import") || isWord(tokens, k, "export") || colonStatement(k, COLON_STATEMENTS));
|
|
36540
|
+
if (opens) {
|
|
36541
|
+
if (open >= 0)
|
|
36542
|
+
found = [open, last];
|
|
36543
|
+
open = colonStatement(k, ["run"]) ? k : -1;
|
|
36544
|
+
last = k + 1;
|
|
36545
|
+
if (open >= 0)
|
|
36546
|
+
k++;
|
|
36547
|
+
continue;
|
|
36548
|
+
}
|
|
36549
|
+
last = k;
|
|
36550
|
+
if (tokens.kind[k] !== PUNCT)
|
|
36551
|
+
continue;
|
|
36552
|
+
const code = tokens.source.charCodeAt(tokens.start[k]);
|
|
36553
|
+
if (code === 40 || code === 91 || code === 123)
|
|
36554
|
+
depth++;
|
|
36555
|
+
else if (code === 41 || code === 93 || code === 125)
|
|
36556
|
+
depth = Math.max(0, depth - 1);
|
|
36557
|
+
}
|
|
36558
|
+
if (open >= 0)
|
|
36559
|
+
found = [open, last];
|
|
36560
|
+
if (!found)
|
|
36561
|
+
return;
|
|
36562
|
+
const [run, end] = found;
|
|
36563
|
+
let from = tokens.start[run];
|
|
36564
|
+
const before = annotationsBefore(text, run > 0 ? rawEnd(tokens, run - 1) : 0, from);
|
|
36565
|
+
for (const tag of before.reverse()) {
|
|
36566
|
+
if (tag.model)
|
|
36567
|
+
break;
|
|
36568
|
+
from = tag.from;
|
|
36569
|
+
}
|
|
36570
|
+
return text.slice(from, rawEnd(tokens, end));
|
|
36571
|
+
}
|
|
36572
|
+
function rawEnd(tokens, k) {
|
|
36573
|
+
return tokens.end[k] + (tokens.kind[k] === QUOTED ? 1 : 0);
|
|
36574
|
+
}
|
|
36370
36575
|
function namesOutside(tokens, headFrom, headTo) {
|
|
36371
36576
|
const names = new Set;
|
|
36372
36577
|
for (let k = 0;k < tokens.count; k++) {
|
|
@@ -36781,10 +36986,11 @@ function locateProblemsInCallerText(problems, callerText, prefixLines) {
|
|
|
36781
36986
|
};
|
|
36782
36987
|
});
|
|
36783
36988
|
}
|
|
36784
|
-
var UNREADABLE_BASE = "`", PUNCT = 0, NAME = 1, QUOTED = 2;
|
|
36989
|
+
var UNREADABLE_BASE = "`", COLON_STATEMENTS, PUNCT = 0, NAME = 1, QUOTED = 2;
|
|
36785
36990
|
var init_query_text = __esm(() => {
|
|
36786
36991
|
init_malloy_lexer_core();
|
|
36787
36992
|
init_malloy_lexer_core();
|
|
36993
|
+
COLON_STATEMENTS = ["run", "source", "query", "given", "sql", "type"];
|
|
36788
36994
|
});
|
|
36789
36995
|
|
|
36790
36996
|
// src/service/materialization/plan/materialize_read_time.ts
|
|
@@ -37924,6 +38130,7 @@ function rollupFactsOf(map, node, def, byName, sourceName) {
|
|
|
37924
38130
|
timeFields,
|
|
37925
38131
|
zone,
|
|
37926
38132
|
joinedInZone: joinersInZone.length > 0,
|
|
38133
|
+
stageZoned: stageZonedTruncations(def),
|
|
37927
38134
|
readInZone,
|
|
37928
38135
|
scope,
|
|
37929
38136
|
joinsRead,
|
|
@@ -37969,6 +38176,10 @@ function declarationRefusal(decl, facts, ctx) {
|
|
|
37969
38176
|
const noJoin = decl.storage === undefined || !facts.joinedInZone ? "no source in the same zone joins it" : `no source in the same zone that joins it is stored in \`${decl.storage}\`, the only place a join reads a rollup there from`;
|
|
37970
38177
|
return unservable("time_zone", decl, `the source sets its own time zone (\`timezone: '${zone}'\`), and a query on it is never read from a rollup, whose stored times would be read in another zone, nor through a join (${noJoin}), so its table would cost a build no query reads`);
|
|
37971
38178
|
}
|
|
38179
|
+
const stageZoned = decl.storage === undefined ? undefined : decl.grain.find((g) => facts.stageZoned.has(g));
|
|
38180
|
+
if (stageZoned !== undefined) {
|
|
38181
|
+
return unservable("time_zone", decl, `its grain dimension \`${stageZoned}\` is a truncation its source's query computed in a zone of its own, which a \`storage=\` rollup would truncate again in the reading query's zone`);
|
|
38182
|
+
}
|
|
37972
38183
|
const hiddenGrain = decl.grain.find((g) => {
|
|
37973
38184
|
const f = byName.get(g);
|
|
37974
38185
|
return isHidden(f) && f?.accessModifier !== "internal" && !(f?.accessModifier === "private" && privateLifts(f, facts));
|
|
@@ -38423,8 +38634,8 @@ function unreadableSourceConnectionMessage(source, type) {
|
|
|
38423
38634
|
const what = type === undefined ? `is not one of the environment's connections (the package's own ` + `DuckDB sandbox is not)` : type === "ducklake" ? `is a DuckLake catalog other than the destination's` : `is a '${type}' connection`;
|
|
38424
38635
|
return `Source '${source.name}' cannot be materialized into a storage ` + `destination: its connection '${source.connectionName}' ${what}, ` + `which cannot be passed through to a 'storage=' build (it reads ` + `${PASSTHROUGH_SOURCE_TYPES.join(", ")} sources, and a DuckLake ` + `source into its own catalog only). ` + `The source is not built and is answered live. Drop 'storage=' to ` + `build it in its own connection, or put the source on a warehouse ` + `connection.`;
|
|
38425
38636
|
}
|
|
38426
|
-
function catalogAuthorSqlMessage(source, { managed = false } = {}) {
|
|
38427
|
-
return `Source '${source.name}' cannot be materialized: its
|
|
38637
|
+
function catalogAuthorSqlMessage(source, cause, { managed = false } = {}) {
|
|
38638
|
+
return `Source '${source.name}' cannot be materialized: ${cause}, and its ` + `connection '${source.connectionName}' is a ` + `${managed ? "managed database" : "DuckLake catalog"}, whose tables are ` + `built inside the catalog by SQL Malloy generates alone: no SQL an ` + `author wrote (an .sql() source or a sql_* expression, its own or a ` + `joined source's) and no file or URL read as a table. The source is ` + `not built and is answered live. Express it in Malloy over the ` + `catalog's tables to build it.`;
|
|
38428
38639
|
}
|
|
38429
38640
|
var PASSTHROUGH_SOURCE_TYPES;
|
|
38430
38641
|
var init_source_connection_type = __esm(() => {
|
|
@@ -38451,41 +38662,121 @@ function isSameCatalog(source, destination) {
|
|
|
38451
38662
|
return !!pa.host && pa.host === pb.host && (pa.port ?? 5432) === (pb.port ?? 5432) && !!pa.databaseName && pa.databaseName === pb.databaseName && (a.catalog.metadataSchema ?? "") === (b.catalog.metadataSchema ?? "") && (pathA === "" || pathB === "" || pathA === pathB);
|
|
38452
38663
|
}
|
|
38453
38664
|
function carriesAuthorSql(def) {
|
|
38665
|
+
return authorSqlCause(def) !== undefined;
|
|
38666
|
+
}
|
|
38667
|
+
function authorSqlCause(def) {
|
|
38454
38668
|
const seen = new Set;
|
|
38455
|
-
const walk = (node, depth) => {
|
|
38669
|
+
const walk = (node, depth, frames) => {
|
|
38456
38670
|
if (depth > MAX_DEPTH2)
|
|
38457
|
-
return
|
|
38671
|
+
return { found: UNREADABLE3, frames };
|
|
38458
38672
|
if (node === null || typeof node !== "object")
|
|
38459
|
-
return
|
|
38673
|
+
return;
|
|
38460
38674
|
if (seen.has(node))
|
|
38461
|
-
return
|
|
38675
|
+
return;
|
|
38462
38676
|
seen.add(node);
|
|
38463
38677
|
if (Array.isArray(node)) {
|
|
38464
|
-
|
|
38678
|
+
for (const child of node) {
|
|
38679
|
+
const hit = walk(child, depth + 1, frames);
|
|
38680
|
+
if (hit)
|
|
38681
|
+
return hit;
|
|
38682
|
+
}
|
|
38683
|
+
return;
|
|
38465
38684
|
}
|
|
38466
38685
|
const record = node;
|
|
38467
|
-
if (
|
|
38468
|
-
|
|
38686
|
+
if (typeof record.join === "string") {
|
|
38687
|
+
frames = [
|
|
38688
|
+
...frames,
|
|
38689
|
+
{
|
|
38690
|
+
kind: "join",
|
|
38691
|
+
as: String(record.as ?? record.name ?? ""),
|
|
38692
|
+
source: sourceNameOf(record)
|
|
38693
|
+
}
|
|
38694
|
+
];
|
|
38469
38695
|
}
|
|
38470
|
-
if (record.
|
|
38471
|
-
return
|
|
38696
|
+
if (record.type === "sql_select") {
|
|
38697
|
+
return { found: { kind: "sql_source" }, frames };
|
|
38698
|
+
}
|
|
38699
|
+
if (record.node === "genericSQLExpr") {
|
|
38700
|
+
return { found: { kind: "sql_expression" }, frames };
|
|
38472
38701
|
}
|
|
38473
38702
|
if (record.type === "table" && typeof record.tablePath === "string" && !CATALOG_TABLE_PATH.test(record.tablePath)) {
|
|
38474
|
-
return
|
|
38703
|
+
return {
|
|
38704
|
+
found: { kind: "file_table", path: record.tablePath },
|
|
38705
|
+
frames
|
|
38706
|
+
};
|
|
38707
|
+
}
|
|
38708
|
+
for (const [key, child] of Object.entries(record)) {
|
|
38709
|
+
if (record.node === "function_call" && key === "overload")
|
|
38710
|
+
continue;
|
|
38711
|
+
const hit = key === "fields" && Array.isArray(child) ? walkFields(child, depth + 1, frames) : walk(child, depth + 1, key === "structRef" && child !== null && typeof child === "object" ? [
|
|
38712
|
+
...frames,
|
|
38713
|
+
{
|
|
38714
|
+
kind: "reads",
|
|
38715
|
+
source: sourceNameOf(child)
|
|
38716
|
+
}
|
|
38717
|
+
] : frames);
|
|
38718
|
+
if (hit)
|
|
38719
|
+
return hit;
|
|
38720
|
+
}
|
|
38721
|
+
return;
|
|
38722
|
+
};
|
|
38723
|
+
const walkFields = (fields, depth, frames) => {
|
|
38724
|
+
if (depth > MAX_DEPTH2)
|
|
38725
|
+
return { found: UNREADABLE3, frames };
|
|
38726
|
+
if (seen.has(fields))
|
|
38727
|
+
return;
|
|
38728
|
+
seen.add(fields);
|
|
38729
|
+
for (const field of fields) {
|
|
38730
|
+
const f = field;
|
|
38731
|
+
const named = f !== null && typeof f === "object" && typeof f.name === "string" && typeof f.join !== "string";
|
|
38732
|
+
const hit = walk(field, depth + 1, named ? [...frames, { kind: "field", name: String(f.name) }] : frames);
|
|
38733
|
+
if (hit)
|
|
38734
|
+
return hit;
|
|
38475
38735
|
}
|
|
38476
|
-
return
|
|
38736
|
+
return;
|
|
38477
38737
|
};
|
|
38478
38738
|
try {
|
|
38479
38739
|
if (def === null || typeof def !== "object")
|
|
38480
|
-
return
|
|
38481
|
-
|
|
38740
|
+
return describe3([], UNREADABLE3);
|
|
38741
|
+
const hit = walk(def, 0, []);
|
|
38742
|
+
return hit ? describe3(hit.frames, hit.found) : undefined;
|
|
38482
38743
|
} catch {
|
|
38483
|
-
return
|
|
38744
|
+
return describe3([], UNREADABLE3);
|
|
38745
|
+
}
|
|
38746
|
+
}
|
|
38747
|
+
function sourceNameOf(record) {
|
|
38748
|
+
const id = typeof record.sourceID === "string" ? record.sourceID : "";
|
|
38749
|
+
const name = typeof record.name === "string" ? record.name : "";
|
|
38750
|
+
return id.split("@")[0] || (name.startsWith("sql://") ? "" : name);
|
|
38751
|
+
}
|
|
38752
|
+
function describe3(frames, found) {
|
|
38753
|
+
if (found.kind === "unreadable") {
|
|
38754
|
+
return "its definition could not be read to check for SQL its author wrote";
|
|
38755
|
+
}
|
|
38756
|
+
frames = frames.filter((frame, i) => frame.kind !== "reads" || i === frames.length - 1 && found.kind !== "sql_expression");
|
|
38757
|
+
const parts = [];
|
|
38758
|
+
let lead = true;
|
|
38759
|
+
for (const frame of frames) {
|
|
38760
|
+
const possessive = lead ? "its" : "whose";
|
|
38761
|
+
const subject = lead ? "it" : "which";
|
|
38762
|
+
lead = false;
|
|
38763
|
+
if (frame.kind === "join") {
|
|
38764
|
+
parts.push(`${possessive} join '${frame.as}'` + (frame.source ? ` reads source '${frame.source}'` : ""));
|
|
38765
|
+
} else if (frame.kind === "reads") {
|
|
38766
|
+
parts.push(frame.source ? `${subject} reads source '${frame.source}'` : `${subject} reads a source`);
|
|
38767
|
+
} else {
|
|
38768
|
+
parts.push(`${possessive} field '${frame.name}'`);
|
|
38769
|
+
}
|
|
38484
38770
|
}
|
|
38771
|
+
const last = frames[frames.length - 1];
|
|
38772
|
+
const subject = frames.length === 0 ? "it" : ", which";
|
|
38773
|
+
const what = found.kind === "sql_source" ? `${subject} is an .sql() source` : found.kind === "file_table" ? `${subject} reads '${found.path.replace(/^'|'$/g, "")}' as a table` : last?.kind === "field" ? " uses a sql_* expression" : `${subject} uses a sql_* expression`;
|
|
38774
|
+
return (parts.join(", ") + what).replace(/^ /, "");
|
|
38485
38775
|
}
|
|
38486
|
-
var CATALOG_TABLE_PATH, MAX_DEPTH2 = 200;
|
|
38776
|
+
var CATALOG_TABLE_PATH, MAX_DEPTH2 = 200, UNREADABLE3;
|
|
38487
38777
|
var init_same_catalog_build = __esm(() => {
|
|
38488
38778
|
CATALOG_TABLE_PATH = /^[A-Za-z_][A-Za-z0-9_$]*(\.[A-Za-z_][A-Za-z0-9_$]*)*$/;
|
|
38779
|
+
UNREADABLE3 = { kind: "unreadable" };
|
|
38489
38780
|
});
|
|
38490
38781
|
|
|
38491
38782
|
// src/service/materialization/plan/materialization_eligibility.ts
|
|
@@ -38532,21 +38823,23 @@ function assertStorageBuildReadsConnection(persistSource, connectionTypes) {
|
|
|
38532
38823
|
message: unreadableSourceConnectionMessage(persistSource, type)
|
|
38533
38824
|
});
|
|
38534
38825
|
}
|
|
38535
|
-
|
|
38826
|
+
const cause = type === "ducklake" ? authorSqlCause(sourceDefOf(persistSource)) : undefined;
|
|
38827
|
+
if (cause !== undefined) {
|
|
38536
38828
|
throw new MaterializationEligibilityError({
|
|
38537
38829
|
reason: "storage_source_unsupported",
|
|
38538
|
-
message: catalogAuthorSqlMessage(persistSource)
|
|
38830
|
+
message: catalogAuthorSqlMessage(persistSource, cause)
|
|
38539
38831
|
});
|
|
38540
38832
|
}
|
|
38541
38833
|
}
|
|
38542
38834
|
function assertManagedBuildRunsMalloySql(source, plan) {
|
|
38543
38835
|
if (!plan?.managedConnections?.includes(source.connectionName))
|
|
38544
38836
|
return;
|
|
38545
|
-
|
|
38837
|
+
const cause = authorSqlCause(sourceDefOf(source));
|
|
38838
|
+
if (cause === undefined)
|
|
38546
38839
|
return;
|
|
38547
38840
|
throw new MaterializationEligibilityError({
|
|
38548
38841
|
reason: "storage_source_unsupported",
|
|
38549
|
-
message: catalogAuthorSqlMessage(source, { managed: true })
|
|
38842
|
+
message: catalogAuthorSqlMessage(source, cause, { managed: true })
|
|
38550
38843
|
});
|
|
38551
38844
|
}
|
|
38552
38845
|
function assertMergeKeyScopeResolvable(persistSource, terms, annotationFields, what) {
|
|
@@ -41523,7 +41816,10 @@ function recordChainedStorageBuild(outcome) {
|
|
|
41523
41816
|
function recordStaleUpstreamEntry(tier) {
|
|
41524
41817
|
staleUpstreamEntryCounter().add(1, { tier });
|
|
41525
41818
|
}
|
|
41526
|
-
|
|
41819
|
+
function recordUpstreamRecompute(reason, build, outcome) {
|
|
41820
|
+
upstreamRecomputeCounter().add(1, { reason, build, outcome });
|
|
41821
|
+
}
|
|
41822
|
+
var BUILD_DURATION_BUCKETS_MS, BUILD_READ_BYTES_BUCKETS, runCounter, runDuration, buildCounter, buildDuration, buildReadBytes, annotationFindingsCounter, incrementalStepCounter, buildPlanComputeDuration, buildPlanComputeFailedCounter, autoLoadCounter, connectionDigestSkipCounter, servedCopyBindCounter, manifestBindDegradedCounter, duplicateTargetSkipCounter, sharedAddressInstructionCounter, tableCollisionCounter, dropTablesCounter, scheduledFireCounter, queryRouteCounter, queryRouteDuration, keyCheckCounter, storageTableRetainedCounter, attributionSkippedCounter, eligibilityRefusedCounter, serveShapeTypeFallbackCounter, storedColumnTypeMismatchCounter, chainedStorageBuildCounter, upstreamRecomputeCounter, staleUpstreamEntryCounter;
|
|
41527
41823
|
var init_materialization_metrics = __esm(() => {
|
|
41528
41824
|
init_vocabulary();
|
|
41529
41825
|
init_telemetry();
|
|
@@ -41566,6 +41862,7 @@ var init_materialization_metrics = __esm(() => {
|
|
|
41566
41862
|
serveShapeTypeFallbackCounter = lazyCounter("publisher_storage_serve_shape_type_fallback_total", "Captured DuckDB column types mapped to json in a stored table's declared " + "type (type fidelity loss). " + "Label: kind ('array'|'unrecognized').");
|
|
41567
41863
|
storedColumnTypeMismatchCounter = lazyCounter("publisher_storage_column_type_mismatch_total", "Stored columns whose DuckDB type does not serve as the type Malloy " + "declares for them. Labels: stage ('build' = " + "found after a storage build; 'serve' = found when a model's bindings " + "are set, then cast on read or left out of the served copy so queries " + "reading it are answered live), declared (the Malloy type).");
|
|
41568
41864
|
chainedStorageBuildCounter = lazyCounter("publisher_storage_chained_build_total", "Chained storage= source builds (a source reading a storage-materialized " + "upstream). Label: outcome ('parent_reuse'|'inline_fallback'|" + "'strict_shape_fallback'|'strict_refused'|'infra_failure'). The " + "parent_reuse share is the headline signal for how far the " + "stack-on-the-parent path gets us vs recompute-from-raw.");
|
|
41865
|
+
upstreamRecomputeCounter = lazyCounter("publisher_materialization_upstream_recompute_total", "Builds that could not check a stored upstream's database table against " + "the column types its build recorded. Labels: reason ('moved', a " + "column retyped or dropped since its build; 'unreadable', its columns " + "could not be read; 'types_unrecorded', its build recorded no column " + "types; 'reference_types_unrecorded', a host's reference carried no " + "nativeSchema; 'persisted_result', a persisted view or query, which " + "builds from its source's definition by design), build ('chained' for a build over the upstream, " + "'rollup' for a database rollup over its stored base), and outcome " + "('recomputed' from its definition, or 'read_unchecked': a strict " + "host-instructed build read the referenced table as before).");
|
|
41569
41866
|
staleUpstreamEntryCounter = lazyCounter("publisher_materialization_stale_upstream_entry_total", "Builds that could not use an upstream's manifest entry because it is at a " + "different tier than the upstream is declared on now (a source moved to " + "or from storage= keeps its content address). The build " + "recomputes that upstream from raw instead, which reads the warehouse. " + "Label: tier ('database'|'storage'), the tier of the build that " + "recomputed.");
|
|
41570
41867
|
});
|
|
41571
41868
|
|
|
@@ -41979,12 +42276,12 @@ function statementsOf(text, tokens) {
|
|
|
41979
42276
|
}
|
|
41980
42277
|
return out;
|
|
41981
42278
|
}
|
|
41982
|
-
function definitionCutAt(text, offset) {
|
|
42279
|
+
function definitionCutAt(text, offset, topLevel = false) {
|
|
41983
42280
|
const tokens = lexAll(text);
|
|
41984
42281
|
if (!tokens)
|
|
41985
42282
|
return;
|
|
41986
42283
|
const statements = statementsOf(text, tokens);
|
|
41987
|
-
const holding = statements.filter((s) => DEFINITION_KEYWORDS.has(s.keyword.text) && s.keyword.start <= offset && offset < s.end && (s.keyword.depth === 0 || s.keyword.text !== "source" && s.keyword.text !== "query"));
|
|
42284
|
+
const holding = statements.filter((s) => DEFINITION_KEYWORDS.has(s.keyword.text) && s.keyword.start <= offset && offset < s.end && (s.keyword.depth === 0 ? !topLevel || s.keyword.text === "source" || s.keyword.text === "query" : !topLevel && s.keyword.text !== "source" && s.keyword.text !== "query"));
|
|
41988
42285
|
if (holding.length === 0)
|
|
41989
42286
|
return;
|
|
41990
42287
|
const stmt = holding.reduce((a, b) => b.keyword.depth > a.keyword.depth || b.keyword.depth === a.keyword.depth && b.keyword.start > a.keyword.start ? b : a);
|
|
@@ -42031,19 +42328,24 @@ function definitionCutAt(text, offset) {
|
|
|
42031
42328
|
name,
|
|
42032
42329
|
...declaration && declaration !== name ? { declaration } : {}
|
|
42033
42330
|
};
|
|
42034
|
-
|
|
42035
|
-
|
|
42036
|
-
|
|
42037
|
-
|
|
42038
|
-
|
|
42039
|
-
|
|
42040
|
-
|
|
42041
|
-
};
|
|
42042
|
-
}
|
|
42331
|
+
const head = statementHead(tokens, tokens.indexOf(stmt.keyword));
|
|
42332
|
+
const before = tokens.filter((t) => t.end <= head.start);
|
|
42333
|
+
const whole = {
|
|
42334
|
+
start: annotationsStart(text, before[before.length - 1]?.end ?? 0, head.start),
|
|
42335
|
+
end: stmtLast.end
|
|
42336
|
+
};
|
|
42337
|
+
if (defs.length === 1)
|
|
42338
|
+
return { ...whole, left };
|
|
42339
|
+
const statement = { ...whole, definitions: defs.length };
|
|
42043
42340
|
if (index === 0) {
|
|
42044
|
-
return { start: stmt.colon.end, end: def.fullEnd, left };
|
|
42341
|
+
return { start: stmt.colon.end, end: def.fullEnd, left, statement };
|
|
42045
42342
|
}
|
|
42046
|
-
return {
|
|
42343
|
+
return {
|
|
42344
|
+
start: defs[index - 1].lastEnd,
|
|
42345
|
+
end: def.lastEnd,
|
|
42346
|
+
left,
|
|
42347
|
+
statement
|
|
42348
|
+
};
|
|
42047
42349
|
}
|
|
42048
42350
|
function annotationsStart(text, floor, keyword) {
|
|
42049
42351
|
const lineStart = text.lastIndexOf(`
|