@malloy-publisher/server 0.17.1 → 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.
@@ -86,7 +86,8 @@ paths:
86
86
  Creates a DuckLake catalog in the schema `name`, with its data under
87
87
  `dataPath`. Encryption is fixed now and cannot be changed later; the
88
88
  inlining limit and file-deletion grace are recorded in the catalog and
89
- can be changed with PATCH. Each schema named is created. The schema may
89
+ can be changed with PATCH. With no `dataInliningRowLimit` the catalog
90
+ records 0, so every table is written as files. Each schema named is created. The schema may
90
91
  already exist, empty (created by whoever provisioned its owner role); the
91
92
  catalog's tables are then owned by that role. `409 CATALOG_EXISTS` when a
92
93
  catalog is already there.
@@ -4973,7 +4973,10 @@ components:
4973
4973
  another source), `destination_missing` (`storage=` names a
4974
4974
  destination the environment does not configure),
4975
4975
  `connection_cannot_hold_table` (database, on a connection whose
4976
- type creates no tables), `materialization_off` (a `#(materialize)`
4976
+ type creates no tables), `types_unrecorded` (database, bound, but
4977
+ its manifest entry records no column types, neither `schema` nor
4978
+ `nativeSchema`, so a change since the build cannot be ruled out;
4979
+ rebuild it), `materialization_off` (a `#(materialize)`
4977
4980
  source, which only the served copy reads, and the served copy is
4978
4981
  off: `PUBLISHER_MATERIALIZE`, and for `storage=`
4979
4982
  `PERSIST_STORAGE_MODE`), `served_copy` (a source the served copy
@@ -4999,6 +5002,17 @@ components:
4999
5002
  while a served copy has yet to compile. Read from the same compile
5000
5003
  of record as the `served-copy-not-served` warnings, never by
5001
5004
  running a query.
5005
+ servedCopyPending:
5006
+ type: boolean
5007
+ description: >-
5008
+ Present, and always `true`, while some model that holds this source,
5009
+ which its served copy reads (`#(materialize)` or `#@ persist`), has
5010
+ yet to compile its served copy over the tables bound now. A bind
5011
+ returns before that compile, so the verdict carries no served-copy
5012
+ judgement yet: it may read `serves` for a table the compile will
5013
+ leave unread. A host must re-read the verdict while it is present;
5014
+ it is absent once every such model's copy is current, and then
5015
+ `notServedIn` and a `served_copy` reason are final for the bind.
5002
5016
  message:
5003
5017
  type: string
5004
5018
  description: What the verdict means for this source, in a sentence.
@@ -11751,6 +11765,24 @@ components:
11751
11765
  content address): a stored upstream is stacked on in its
11752
11766
  destination, and never rendered into warehouse SQL. Optional and
11753
11767
  additive: a reference without it still serves a database upstream.
11768
+ nativeSchema:
11769
+ type: array
11770
+ description: >-
11771
+ For a database upstream (no `storageDestinationName`): the
11772
+ `nativeSchema` the upstream's build reported on its manifest
11773
+ entry, sent back as it came. Before a build reads the referenced
11774
+ table in place of its source, it reads the table's columns from
11775
+ the warehouse and compares each with this type (case and spacing
11776
+ aside). If a column was retyped or dropped since, or cannot be
11777
+ read, a strict build is refused and any other build recomputes
11778
+ the upstream from its definition. Without it nothing can be
11779
+ checked: a strict build reads the table unchecked, with a warning
11780
+ and a count (`publisher_materialization_upstream_recompute_total`,
11781
+ `reason="reference_types_unrecorded"`), and any other build
11782
+ recomputes the upstream. Ignored for a `storage=` upstream: omit
11783
+ it there. Optional and additive.
11784
+ items:
11785
+ $ref: "#/components/schemas/Column"
11754
11786
 
11755
11787
  BuildInstruction:
11756
11788
  type: object
@@ -12281,8 +12313,12 @@ components:
12281
12313
  handed by reference; for a database build, an upstream that
12282
12314
  landed in a `storage=` destination; for a `storage=` build, a
12283
12315
  source that reaches the warehouse through a non-persisted source,
12284
- or whose shape does not compile in the destination.
12285
- `upstreamRecomputeReason` says which. Such a table reflects the
12316
+ or whose shape does not compile in the destination; on the
12317
+ database tier, an upstream whose table holds other columns than
12318
+ its build recorded (retyped or dropped since), could not be read,
12319
+ or whose build recorded no column types; and always, for a
12320
+ persisted view or named query, which builds from its source's
12321
+ definition. `upstreamRecomputeReason` says which. Such a table reflects the
12286
12322
  warehouse at THIS build's time rather than the upstream's
12287
12323
  snapshot, so the two can disagree when their refresh cadences
12288
12324
  differ.
@@ -12292,8 +12328,10 @@ components:
12292
12328
  way to build and no choice to report.
12293
12329
 
12294
12330
  A database rollup reports what its build actually read: `reused`
12295
- only when it built from its base's materialized table, and absent
12296
- when it built from the warehouse, even over a persisted base. Before
12331
+ only when it built from its base's materialized table, `recomputed`
12332
+ when it could not because that table holds other columns than its
12333
+ build recorded, could not be read, or recorded no column types,
12334
+ and absent when it built from the warehouse for any other reason. Before
12297
12335
  0.15.0 every rollup over a persisted base reported `reused`. A
12298
12336
  `storage=` rollup reports `reused` only when it stacked on a stored
12299
12337
  table.
@@ -167061,7 +167061,7 @@ var init_telemetry = __esm(() => {
167061
167061
  });
167062
167062
 
167063
167063
  // package.json
167064
- var version = "0.17.1";
167064
+ var version = "0.17.2";
167065
167065
  var init_package = () => {};
167066
167066
 
167067
167067
  // src/version.ts
@@ -14112,7 +14112,7 @@ function internalErrorToHttpError(error, { log = true, onLogged } = {}) {
14112
14112
  json: { code: status, message, problems: row.problems(error) }
14113
14113
  };
14114
14114
  }
14115
- const answer = httpError(status, message, resolve(row.reason, error));
14115
+ const answer = httpError(status, message, errorReason(error));
14116
14116
  const refusalReason = row.refusalReason?.(error);
14117
14117
  if (refusalReason !== undefined)
14118
14118
  answer.json.refusalReason = refusalReason;
@@ -14164,6 +14164,9 @@ function errorKind(error) {
14164
14164
  function errorMapping(error) {
14165
14165
  return ERROR_TABLE[errorKind(error)];
14166
14166
  }
14167
+ function errorReason(error) {
14168
+ return resolve(errorMapping(error).reason, error);
14169
+ }
14167
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;
14168
14171
  var init_errors2 = __esm(() => {
14169
14172
  init_constants();
@@ -28647,6 +28650,49 @@ function queryTimezoneOf(structDef) {
28647
28650
  }
28648
28651
  return typeof tz === "string" && tz !== "" ? tz : undefined;
28649
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
+ }
28650
28696
  function readsAGiven(node, seen = new WeakSet, depth = 0) {
28651
28697
  if (depth > MAX_WALK_DEPTH) {
28652
28698
  throw new Error("given walk exceeded max depth");
@@ -28733,6 +28779,7 @@ var init_dialect = __esm(() => {
28733
28779
  castsToIntegerType: false,
28734
28780
  onlyBigIntegerType: undefined,
28735
28781
  foldsTableNameCase: false,
28782
+ decodedTablePath: false,
28736
28783
  utcSessions: false,
28737
28784
  leafBudget: 50,
28738
28785
  passthroughNumericAsDouble: false,
@@ -28754,6 +28801,7 @@ var init_dialect = __esm(() => {
28754
28801
  driverKeepsBigIntegers: true,
28755
28802
  castsToIntegerType: true,
28756
28803
  foldsTableNameCase: true,
28804
+ decodedTablePath: true,
28757
28805
  utcSessions: true,
28758
28806
  leafBudget: 120,
28759
28807
  stringCollation: "instance",
@@ -28767,6 +28815,7 @@ var init_dialect = __esm(() => {
28767
28815
  incrementalTargetDml: true,
28768
28816
  merge: true,
28769
28817
  mergeGatedByServerVersion: true,
28818
+ decodedTablePath: true,
28770
28819
  transactionalSwap: true,
28771
28820
  dependencyGuard: true,
28772
28821
  relationProbe: true,
@@ -28794,6 +28843,7 @@ var init_dialect = __esm(() => {
28794
28843
  }),
28795
28844
  standardsql: Object.freeze({
28796
28845
  ...NONE,
28846
+ decodedTablePath: true,
28797
28847
  incrementalSourceRange: true,
28798
28848
  incrementalTargetDml: true,
28799
28849
  merge: true,
@@ -28811,6 +28861,7 @@ var init_dialect = __esm(() => {
28811
28861
  }),
28812
28862
  snowflake: Object.freeze({
28813
28863
  ...NONE,
28864
+ decodedTablePath: true,
28814
28865
  catalogHidesTables: true,
28815
28866
  incrementalSourceRange: true,
28816
28867
  incrementalTargetDml: true,
@@ -38079,6 +38130,7 @@ function rollupFactsOf(map, node, def, byName, sourceName) {
38079
38130
  timeFields,
38080
38131
  zone,
38081
38132
  joinedInZone: joinersInZone.length > 0,
38133
+ stageZoned: stageZonedTruncations(def),
38082
38134
  readInZone,
38083
38135
  scope,
38084
38136
  joinsRead,
@@ -38124,6 +38176,10 @@ function declarationRefusal(decl, facts, ctx) {
38124
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`;
38125
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`);
38126
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
+ }
38127
38183
  const hiddenGrain = decl.grain.find((g) => {
38128
38184
  const f = byName.get(g);
38129
38185
  return isHidden(f) && f?.accessModifier !== "internal" && !(f?.accessModifier === "private" && privateLifts(f, facts));
@@ -38578,8 +38634,8 @@ function unreadableSourceConnectionMessage(source, type) {
38578
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`;
38579
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.`;
38580
38636
  }
38581
- function catalogAuthorSqlMessage(source, { managed = false } = {}) {
38582
- return `Source '${source.name}' cannot be materialized: its connection ` + `'${source.connectionName}' is a ${managed ? "managed database" : "DuckLake catalog"}, whose tables are ` + `built inside the catalog by SQL Malloy generates, and the source ` + `carries SQL its author wrote (an .sql() source or a sql_* ` + `expression, its own or a joined source's) or reads a file or URL as a ` + `table. The source is not built and is answered live. Express it in ` + `Malloy over the catalog's tables to build it.`;
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.`;
38583
38639
  }
38584
38640
  var PASSTHROUGH_SOURCE_TYPES;
38585
38641
  var init_source_connection_type = __esm(() => {
@@ -38606,41 +38662,121 @@ function isSameCatalog(source, destination) {
38606
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);
38607
38663
  }
38608
38664
  function carriesAuthorSql(def) {
38665
+ return authorSqlCause(def) !== undefined;
38666
+ }
38667
+ function authorSqlCause(def) {
38609
38668
  const seen = new Set;
38610
- const walk = (node, depth) => {
38669
+ const walk = (node, depth, frames) => {
38611
38670
  if (depth > MAX_DEPTH2)
38612
- return true;
38671
+ return { found: UNREADABLE3, frames };
38613
38672
  if (node === null || typeof node !== "object")
38614
- return false;
38673
+ return;
38615
38674
  if (seen.has(node))
38616
- return false;
38675
+ return;
38617
38676
  seen.add(node);
38618
38677
  if (Array.isArray(node)) {
38619
- return node.some((child) => walk(child, depth + 1));
38678
+ for (const child of node) {
38679
+ const hit = walk(child, depth + 1, frames);
38680
+ if (hit)
38681
+ return hit;
38682
+ }
38683
+ return;
38620
38684
  }
38621
38685
  const record = node;
38622
- if (record.type === "sql_select" || record.node === "genericSQLExpr") {
38623
- return true;
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
+ ];
38695
+ }
38696
+ if (record.type === "sql_select") {
38697
+ return { found: { kind: "sql_source" }, frames };
38624
38698
  }
38625
- if (record.node === "function_call") {
38626
- return Object.entries(record).some(([key, child]) => key !== "overload" && walk(child, depth + 1));
38699
+ if (record.node === "genericSQLExpr") {
38700
+ return { found: { kind: "sql_expression" }, frames };
38627
38701
  }
38628
38702
  if (record.type === "table" && typeof record.tablePath === "string" && !CATALOG_TABLE_PATH.test(record.tablePath)) {
38629
- return true;
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;
38630
38735
  }
38631
- return Object.values(record).some((child) => walk(child, depth + 1));
38736
+ return;
38632
38737
  };
38633
38738
  try {
38634
38739
  if (def === null || typeof def !== "object")
38635
- return true;
38636
- return walk(def, 0);
38740
+ return describe3([], UNREADABLE3);
38741
+ const hit = walk(def, 0, []);
38742
+ return hit ? describe3(hit.frames, hit.found) : undefined;
38637
38743
  } catch {
38638
- return true;
38744
+ return describe3([], UNREADABLE3);
38639
38745
  }
38640
38746
  }
38641
- var CATALOG_TABLE_PATH, MAX_DEPTH2 = 200;
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
+ }
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(/^ /, "");
38775
+ }
38776
+ var CATALOG_TABLE_PATH, MAX_DEPTH2 = 200, UNREADABLE3;
38642
38777
  var init_same_catalog_build = __esm(() => {
38643
38778
  CATALOG_TABLE_PATH = /^[A-Za-z_][A-Za-z0-9_$]*(\.[A-Za-z_][A-Za-z0-9_$]*)*$/;
38779
+ UNREADABLE3 = { kind: "unreadable" };
38644
38780
  });
38645
38781
 
38646
38782
  // src/service/materialization/plan/materialization_eligibility.ts
@@ -38687,21 +38823,23 @@ function assertStorageBuildReadsConnection(persistSource, connectionTypes) {
38687
38823
  message: unreadableSourceConnectionMessage(persistSource, type)
38688
38824
  });
38689
38825
  }
38690
- if (type === "ducklake" && carriesAuthorSql(sourceDefOf(persistSource))) {
38826
+ const cause = type === "ducklake" ? authorSqlCause(sourceDefOf(persistSource)) : undefined;
38827
+ if (cause !== undefined) {
38691
38828
  throw new MaterializationEligibilityError({
38692
38829
  reason: "storage_source_unsupported",
38693
- message: catalogAuthorSqlMessage(persistSource)
38830
+ message: catalogAuthorSqlMessage(persistSource, cause)
38694
38831
  });
38695
38832
  }
38696
38833
  }
38697
38834
  function assertManagedBuildRunsMalloySql(source, plan) {
38698
38835
  if (!plan?.managedConnections?.includes(source.connectionName))
38699
38836
  return;
38700
- if (!carriesAuthorSql(sourceDefOf(source)))
38837
+ const cause = authorSqlCause(sourceDefOf(source));
38838
+ if (cause === undefined)
38701
38839
  return;
38702
38840
  throw new MaterializationEligibilityError({
38703
38841
  reason: "storage_source_unsupported",
38704
- message: catalogAuthorSqlMessage(source, { managed: true })
38842
+ message: catalogAuthorSqlMessage(source, cause, { managed: true })
38705
38843
  });
38706
38844
  }
38707
38845
  function assertMergeKeyScopeResolvable(persistSource, terms, annotationFields, what) {
@@ -41678,7 +41816,10 @@ function recordChainedStorageBuild(outcome) {
41678
41816
  function recordStaleUpstreamEntry(tier) {
41679
41817
  staleUpstreamEntryCounter().add(1, { tier });
41680
41818
  }
41681
- 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, staleUpstreamEntryCounter;
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;
41682
41823
  var init_materialization_metrics = __esm(() => {
41683
41824
  init_vocabulary();
41684
41825
  init_telemetry();
@@ -41721,6 +41862,7 @@ var init_materialization_metrics = __esm(() => {
41721
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').");
41722
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).");
41723
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).");
41724
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.");
41725
41867
  });
41726
41868