@malloy-publisher/server 0.15.0 → 0.16.0
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/app/api-doc.yaml +256 -15
- package/dist/app/assets/{EnvironmentPage-CKUvEX7r.js → EnvironmentPage-Y9IWPC9J.js} +1 -1
- package/dist/app/assets/{HomePage-COpZmm3Z.js → HomePage-BOUo0MEl.js} +1 -1
- package/dist/app/assets/{MainPage-nIyVOgy5.js → MainPage-BkM5UDRU.js} +1 -1
- package/dist/app/assets/{ModelPage-BelGfTpw.js → ModelPage-PgDTkS5C.js} +2 -2
- package/dist/app/assets/{PackagePage-CbnVG2uD.js → PackagePage-Dn7FrQ5r.js} +1 -1
- package/dist/app/assets/{PackageSplatRoute-37oqxKyq.js → PackageSplatRoute-BLC29ek-.js} +2 -2
- package/dist/app/assets/{RenderedResult-Ct3z543g.es-QeWq894a.js → RenderedResult-vyM2wQbC.es-ha8dF24T.js} +3 -3
- package/dist/app/assets/{RouteError-CjmVxFgv.js → RouteError-BolMqTuz.js} +1 -1
- package/dist/app/assets/{ThemeEditorPage-BjPyhpFF.js → ThemeEditorPage-CPv1eHkI.js} +1 -1
- package/dist/app/assets/{ToggleButtonGroup-bM-WVZrV.js → ToggleButtonGroup-DZtImN0S.js} +1 -1
- package/dist/app/assets/{documentRoutes-BAPDdua3.js → documentRoutes-DI5cX3ty.js} +1 -1
- package/dist/app/assets/{editPageMounted-B4HEQbbz.js → editPageMounted-C--4kcld.js} +2 -2
- package/dist/app/assets/{index-DbRUcXfe.js → index-CbsrzNSp.js} +1 -1
- package/dist/app/assets/{index-C-aFb4Gn.js → index-D9wSfMZN.js} +1 -1
- package/dist/app/assets/{index-DUgED99B.js → index-DLToSg1f.js} +62 -62
- package/dist/app/assets/{index-Bx-5B05C.js → index-DyYEltlF.js} +1 -1
- package/dist/app/assets/{index.es-DO67FMt6.js → index.es-D8SVyfmS.js} +1 -1
- package/dist/app/assets/usePackageLinkNavigate-DxHGKrmZ.js +1 -0
- package/dist/app/assets/{usePackageRoute-Cso_p7RX.js → usePackageRoute-A_YQMrax.js} +1 -1
- package/dist/app/index.html +1 -1
- package/dist/app/mcp-app/report.js +145 -145
- package/dist/instrumentation.mjs +9 -1
- package/dist/package_load_worker.mjs +161 -13
- package/dist/server.mjs +1415 -228
- package/package.json +1 -1
- package/dist/app/assets/usePackageLinkNavigate-BgdbNERJ.js +0 -1
package/dist/instrumentation.mjs
CHANGED
|
@@ -446,6 +446,14 @@ var init_admin = __esm(() => {
|
|
|
446
446
|
notes: "Host binding for the admin API. Deliberately not moved by `PUBLISHER_HOST`: putting the main API on every interface does not expose the admin operations. Widen it only inside the network the orchestrator calls from, never behind a public ingress.",
|
|
447
447
|
aliases: { env: ["PUBLISHER_ADMIN_HOST"], flags: ["--admin_host"] }
|
|
448
448
|
}),
|
|
449
|
+
setting({
|
|
450
|
+
key: "admin.requestTimeoutMs",
|
|
451
|
+
type: integer({ min: 1 }),
|
|
452
|
+
default: 600000,
|
|
453
|
+
description: "Ms the admin API keeps a request, its headers and an idle keep-alive open.",
|
|
454
|
+
defaultText: "`600000` (10 min)",
|
|
455
|
+
notes: "How long the admin listener lets a request run before closing its connection. A table copy or a file load answers only when the table is written, so a large table needs longer than the main API's ten minutes; raise this for the caller's largest copy, and keep the caller's own timeout above it. Applies to the admin listener alone: the main API and MCP listeners keep ten minutes."
|
|
456
|
+
}),
|
|
449
457
|
setting({
|
|
450
458
|
key: "admin.catalogDatabase",
|
|
451
459
|
type: string(),
|
|
@@ -167053,7 +167061,7 @@ var init_telemetry = __esm(() => {
|
|
|
167053
167061
|
});
|
|
167054
167062
|
|
|
167055
167063
|
// package.json
|
|
167056
|
-
var version = "0.
|
|
167064
|
+
var version = "0.16.0";
|
|
167057
167065
|
var init_package = () => {};
|
|
167058
167066
|
|
|
167059
167067
|
// src/version.ts
|
|
@@ -1968,6 +1968,14 @@ var init_admin = __esm(() => {
|
|
|
1968
1968
|
notes: "Host binding for the admin API. Deliberately not moved by `PUBLISHER_HOST`: putting the main API on every interface does not expose the admin operations. Widen it only inside the network the orchestrator calls from, never behind a public ingress.",
|
|
1969
1969
|
aliases: { env: ["PUBLISHER_ADMIN_HOST"], flags: ["--admin_host"] }
|
|
1970
1970
|
}),
|
|
1971
|
+
setting({
|
|
1972
|
+
key: "admin.requestTimeoutMs",
|
|
1973
|
+
type: integer({ min: 1 }),
|
|
1974
|
+
default: 600000,
|
|
1975
|
+
description: "Ms the admin API keeps a request, its headers and an idle keep-alive open.",
|
|
1976
|
+
defaultText: "`600000` (10 min)",
|
|
1977
|
+
notes: "How long the admin listener lets a request run before closing its connection. A table copy or a file load answers only when the table is written, so a large table needs longer than the main API's ten minutes; raise this for the caller's largest copy, and keep the caller's own timeout above it. Applies to the admin listener alone: the main API and MCP listeners keep ten minutes."
|
|
1978
|
+
}),
|
|
1971
1979
|
setting({
|
|
1972
1980
|
key: "admin.catalogDatabase",
|
|
1973
1981
|
type: string(),
|
|
@@ -12521,6 +12529,15 @@ function freshnessWindowSeconds(window2) {
|
|
|
12521
12529
|
return;
|
|
12522
12530
|
return count * WINDOW_UNITS[match[2]];
|
|
12523
12531
|
}
|
|
12532
|
+
function durationSeconds(text) {
|
|
12533
|
+
const match = /^\s*(\d+)\s*([a-z]+)\s*$/.exec(text);
|
|
12534
|
+
if (!match || !Object.hasOwn(DURATION_UNITS, match[2]))
|
|
12535
|
+
return;
|
|
12536
|
+
const count = Number(match[1]);
|
|
12537
|
+
if (!Number.isSafeInteger(count) || count <= 0)
|
|
12538
|
+
return;
|
|
12539
|
+
return count * DURATION_UNITS[match[2]];
|
|
12540
|
+
}
|
|
12524
12541
|
function declaredFreshnessFacts(declarations) {
|
|
12525
12542
|
let window2;
|
|
12526
12543
|
const fallbacks = new Set;
|
|
@@ -12548,7 +12565,7 @@ function declaredFreshnessFacts(declarations) {
|
|
|
12548
12565
|
...fallback !== undefined ? { freshnessFallback: fallback } : {}
|
|
12549
12566
|
};
|
|
12550
12567
|
}
|
|
12551
|
-
var FRESHNESS_FALLBACKS, WINDOW_UNITS;
|
|
12568
|
+
var FRESHNESS_FALLBACKS, WINDOW_UNITS, DURATION_UNITS, DURATION_UNIT_TEXT = "seconds, minutes, hours, days or weeks (s, m, h, d or w)";
|
|
12552
12569
|
var init_freshness = __esm(() => {
|
|
12553
12570
|
FRESHNESS_FALLBACKS = ["live", "stale_ok", "fail"];
|
|
12554
12571
|
WINDOW_UNITS = {
|
|
@@ -12558,6 +12575,19 @@ var init_freshness = __esm(() => {
|
|
|
12558
12575
|
d: 86400,
|
|
12559
12576
|
w: 604800
|
|
12560
12577
|
};
|
|
12578
|
+
DURATION_UNITS = {
|
|
12579
|
+
...WINDOW_UNITS,
|
|
12580
|
+
second: 1,
|
|
12581
|
+
seconds: 1,
|
|
12582
|
+
minute: 60,
|
|
12583
|
+
minutes: 60,
|
|
12584
|
+
hour: 3600,
|
|
12585
|
+
hours: 3600,
|
|
12586
|
+
day: 86400,
|
|
12587
|
+
days: 86400,
|
|
12588
|
+
week: 604800,
|
|
12589
|
+
weeks: 604800
|
|
12590
|
+
};
|
|
12561
12591
|
});
|
|
12562
12592
|
|
|
12563
12593
|
// src/service/annotation_reader.ts
|
|
@@ -12895,6 +12925,7 @@ var init_annotation_reader = __esm(() => {
|
|
|
12895
12925
|
"refresh",
|
|
12896
12926
|
"watermark",
|
|
12897
12927
|
"merge_key",
|
|
12928
|
+
"lookback",
|
|
12898
12929
|
"freshness",
|
|
12899
12930
|
"queryMetadata"
|
|
12900
12931
|
]);
|
|
@@ -12910,6 +12941,7 @@ var init_annotation_reader = __esm(() => {
|
|
|
12910
12941
|
"refresh",
|
|
12911
12942
|
"watermark",
|
|
12912
12943
|
"merge_key",
|
|
12944
|
+
"lookback",
|
|
12913
12945
|
"freshness",
|
|
12914
12946
|
"queryMetadata",
|
|
12915
12947
|
"inline"
|
|
@@ -14062,7 +14094,7 @@ function errorKind(error) {
|
|
|
14062
14094
|
function errorMapping(error) {
|
|
14063
14095
|
return ERROR_TABLE[errorKind(error)];
|
|
14064
14096
|
}
|
|
14065
|
-
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, UnconfiguredConnectionError, ConnectionPoolExhaustedError, DestinationNotFoundError, StorageDestinationNotFoundError, StorageCatalogNotFoundError, ConnectionAuthError, StorageAccessDeniedError, UnsupportedCatalogFormatError, ModelCompilationError, VersionFilesMissingError, PackageManifestError, MaterializationEligibilityError, ChainedUpstreamMissingError, ChainedShapeNotCarriedError, WarehouseRecomputeRefusedError, PublisherConfigError, ServerConfigurationError, FrozenConfigError, AccessDeniedError, QueryCompileError, NotQueryableError, OffSurfaceError, MaterializationNotFoundError, MaterializationConflictError, 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;
|
|
14097
|
+
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, UnconfiguredConnectionError, ConnectionPoolExhaustedError, 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;
|
|
14066
14098
|
var init_errors2 = __esm(() => {
|
|
14067
14099
|
init_constants();
|
|
14068
14100
|
init_logger();
|
|
@@ -14548,6 +14580,16 @@ var init_errors2 = __esm(() => {
|
|
|
14548
14580
|
super(message);
|
|
14549
14581
|
}
|
|
14550
14582
|
};
|
|
14583
|
+
MaterializedTableDropRefusedError = class MaterializedTableDropRefusedError extends Error {
|
|
14584
|
+
reason;
|
|
14585
|
+
get kind() {
|
|
14586
|
+
return "materialized_table_drop_refused";
|
|
14587
|
+
}
|
|
14588
|
+
constructor(reason, message) {
|
|
14589
|
+
super(message);
|
|
14590
|
+
this.reason = reason;
|
|
14591
|
+
}
|
|
14592
|
+
};
|
|
14551
14593
|
WriteConflictError = class WriteConflictError extends Error {
|
|
14552
14594
|
reason;
|
|
14553
14595
|
get kind() {
|
|
@@ -14707,6 +14749,7 @@ var init_errors2 = __esm(() => {
|
|
|
14707
14749
|
off_surface: OffSurfaceError,
|
|
14708
14750
|
materialization_not_found: MaterializationNotFoundError,
|
|
14709
14751
|
materialization_conflict: MaterializationConflictError,
|
|
14752
|
+
materialized_table_drop_refused: MaterializedTableDropRefusedError,
|
|
14710
14753
|
write_conflict: WriteConflictError,
|
|
14711
14754
|
installed_from_location: InstalledFromLocationError,
|
|
14712
14755
|
write_rolled_back: WriteRolledBackError,
|
|
@@ -14984,6 +15027,11 @@ var init_errors2 = __esm(() => {
|
|
|
14984
15027
|
reason: "MATERIALIZATION_CONFLICT",
|
|
14985
15028
|
mcp: { advice: "internal" }
|
|
14986
15029
|
},
|
|
15030
|
+
materialized_table_drop_refused: {
|
|
15031
|
+
status: 409,
|
|
15032
|
+
reason: (error) => error.reason,
|
|
15033
|
+
mcp: { advice: "internal" }
|
|
15034
|
+
},
|
|
14987
15035
|
invalid_state_transition: { status: 409, mcp: { advice: "internal" } },
|
|
14988
15036
|
write_conflict: {
|
|
14989
15037
|
status: 409,
|
|
@@ -28200,9 +28248,9 @@ var init_materialization_metrics = __esm(() => {
|
|
|
28200
28248
|
duplicateTargetSkipCounter = lazyCounter("publisher_materialization_duplicate_target_skipped_total", "Sources skipped because the physical table they name was already built in " + "this run. Ordinary for a package that extends a persisted source; a " + "rising count against a package with no extension means the plan is " + "enumerating one table under more names than expected.");
|
|
28201
28249
|
sharedAddressInstructionCounter = lazyCounter("publisher_materialization_shared_address_instructions_total", "Content addresses that arrived with more than one instruction naming a " + "DIFFERENT physical table. The host minted a table per source where " + "several sources share one artifact. With a sourceID on each instruction " + "every table is built and only one is recorded, so the rest are orphaned; " + "without one the last instruction wins and the earlier names are never " + "built. Wasteful, not wrong — the table's CONTENT is the same either way.");
|
|
28202
28250
|
tableCollisionCounter = lazyCounter("publisher_materialization_table_collision_total", "Two definitions with DIFFERENT content addresses materializing into ONE " + "physical table. Each build overwrites the other's rows while both " + "addresses resolve to the table at serve time, so a query is answered " + "from another source's data. A wrong answer, not wasted work — page on " + "this one. Counted, then refused before any write, unless " + "PERSIST_COLLISION_ENFORCE=false opts out, in which case the build " + "continues.");
|
|
28203
|
-
dropTablesCounter = lazyCounter("publisher_materialization_drop_tables_total", "Physical tables dropped. Labels: outcome ('success'|'failure'), tier " + "('database'|'storage'), occasion ('delete' when a caller deleted a " + "storage destination's table, since a run's delete is record-only; " + "'reclaim' when Publisher dropped it on its own: " + "a failed run's tables, a table a readable name replaced, an archived " + "or deleted version's tables).");
|
|
28251
|
+
dropTablesCounter = lazyCounter("publisher_materialization_drop_tables_total", "Physical tables dropped. Labels: outcome ('success'|'failure'), tier " + "('database'|'storage'), occasion ('delete' when a caller deleted a " + "storage destination's table, since a run's delete is record-only; " + "'reclaim' when Publisher dropped it on its own: " + "a failed run's tables, a table a readable name replaced, an archived " + "or deleted version's tables; 'caller' when a caller dropped a " + "package's materialized database table through " + "DELETE .../materializedTables/{tableName}).");
|
|
28204
28252
|
scheduledFireCounter = lazyCounter("publisher_materialization_scheduled_fires_total", "Standalone-scheduler attempts to fire a package's materialization.schedule. " + "Label: outcome ('fired'|'conflict'|'error').");
|
|
28205
|
-
queryRouteCounter = lazyCounter("publisher_query_route_total", "The router's decision on each leg it considered for a query, counted once " + "the query is answered. Labels: leg ('view'|'query'|'rollup'|'materialized'|'live'; " + "'query' is a persisted named query), " + "outcome ('used'|'skipped'|'fallback': a chosen leg whose run failed and " + "was answered live), reason ('NONE' when used, else the path report's " + "SkipReason; '
|
|
28253
|
+
queryRouteCounter = lazyCounter("publisher_query_route_total", "The router's decision on each leg it considered for a query, counted once " + "the query is answered. Labels: leg ('view'|'query'|'rollup'|'materialized'|'live'; " + "'query' is a persisted named query), " + "outcome ('used'|'skipped'|'fallback': a chosen leg whose run failed and " + "was answered live), reason ('NONE' when used, else the path report's " + "SkipReason; 'READ_FAILED' with 'fallback'). A leg that does not apply to " + "the query is not counted; 'live' is counted 'used' when it answered a " + "query the router counted a leg for.");
|
|
28206
28254
|
queryRouteDuration = lazyHistogram("publisher_query_route_duration_ms", "Wall-clock time the router spent choosing how to answer a query, for a " + "query with at least one serving leg that applied: the row-level veto " + "and each leg's compile, up to the leg chosen. Not the query's run. " + "Label: leg ('view'|'query'|'rollup'|'materialized'|'live'), the one that " + "answered.");
|
|
28207
28255
|
keyCheckCounter = lazyCounter("publisher_materialization_key_check_total", "Key checks a run made over the rows it read or wrote. Labels: kind " + "('inline_join'|'rollup'|'parent'|'pair_leaf'|'stored'), outcome " + "('unique'|'not_unique'|'not_run'|'reused'). An inline_join that is " + "not_unique fails its build; every other not_unique or not_run leaves " + "the key unknown or repeated, so queries that need it unique are " + "answered live.");
|
|
28208
28256
|
storageTableRetainedCounter = lazyCounter("publisher_storage_tables_retained_total", "Tables a FAILED run left in a storage= destination and deliberately did not " + "reclaim, because the source is refreshed incrementally and the name may be " + "the one it serves from. Not all of these are orphans — " + "a rebuild at a fresh generational name is, a seed on the live serving name " + "is not, and the manifest entry cannot separate them — so read this as an " + "upper bound on what is accumulating rather than a leak count. It is the " + "only accounting there is until reclaiming a destination exists, which is " + "why it is a counter and not just a log line: the question is a rate, not " + "whether it ever happened. Unlabelled: the destination is on the warn " + "log that accompanies each count.");
|
|
@@ -28656,6 +28704,7 @@ var init_dialect = __esm(() => {
|
|
|
28656
28704
|
needsQualifiedTable: false,
|
|
28657
28705
|
nestedColumns: false,
|
|
28658
28706
|
driverKeepsBigIntegers: false,
|
|
28707
|
+
liveRoundsBigIntegersMeasured: false,
|
|
28659
28708
|
castsToIntegerType: false,
|
|
28660
28709
|
onlyBigIntegerType: undefined,
|
|
28661
28710
|
foldsTableNameCase: false,
|
|
@@ -28694,7 +28743,8 @@ var init_dialect = __esm(() => {
|
|
|
28694
28743
|
dependencyGuard: true,
|
|
28695
28744
|
relationProbe: true,
|
|
28696
28745
|
tableOwnership: true,
|
|
28697
|
-
castsToIntegerType: true
|
|
28746
|
+
castsToIntegerType: true,
|
|
28747
|
+
liveRoundsBigIntegersMeasured: true
|
|
28698
28748
|
}),
|
|
28699
28749
|
standardsql: Object.freeze({
|
|
28700
28750
|
...NONE,
|
|
@@ -28777,6 +28827,9 @@ function aggregateBacked(names) {
|
|
|
28777
28827
|
return names.filter((n) => n !== undefined && n.kind === "aggregate");
|
|
28778
28828
|
}
|
|
28779
28829
|
function malformedMessage(where, key, problem, detail) {
|
|
28830
|
+
if (key === "lookback" && (problem === "array" || problem === "empty")) {
|
|
28831
|
+
return `${where} declares lookback=${problem === "array" ? "[…] as a tag ARRAY" : '"" (empty)'}. ` + `Write ONE quoted duration, such as lookback="2 days", or remove the ` + `key (use -lookback to strip one inherited from a parent source).`;
|
|
28832
|
+
}
|
|
28780
28833
|
switch (problem) {
|
|
28781
28834
|
case "array":
|
|
28782
28835
|
return `${where} declares ${key}=[…] as a tag ARRAY. Write ONE quoted ` + `string instead: ${key}="order_date"` + (key === "merge_key" ? `, and separate a compound key with commas inside that one ` + `string — merge_key="order_id, region".` : `.`) + ` An array value is dropped from the annotation's scalar fields, so ` + `the key would otherwise read as undeclared.`;
|
|
@@ -28812,10 +28865,11 @@ function judgeSource(source) {
|
|
|
28812
28865
|
for (const m of d.malformed) {
|
|
28813
28866
|
out.push(malformedMessage(where, m.key, m.problem, m.detail));
|
|
28814
28867
|
}
|
|
28815
|
-
if (!d.incremental && (d.declaredWatermark || d.declaredMergeKey)) {
|
|
28868
|
+
if (!d.incremental && (d.declaredWatermark || d.declaredMergeKey || d.declaredLookback)) {
|
|
28816
28869
|
const keys = [
|
|
28817
28870
|
d.declaredWatermark ? "watermark=" : undefined,
|
|
28818
|
-
d.declaredMergeKey ? "merge_key=" : undefined
|
|
28871
|
+
d.declaredMergeKey ? "merge_key=" : undefined,
|
|
28872
|
+
d.declaredLookback ? "lookback=" : undefined
|
|
28819
28873
|
].filter((k) => k !== undefined);
|
|
28820
28874
|
out.push(`${where} declares ${keys.join(" and ")} but is not ${MODE}` + (d.refresh ? ` (it declares refresh=${JSON.stringify(d.refresh)})` : "") + `. These keys describe how an INCREMENTAL refresh advances the ` + `table and are ignored by a full rebuild. Either add ${MODE}, or ` + `remove the key — and if the key is inherited from a parent source, ` + `strip it with a negation (e.g. -watermark), since removing the ` + `parent's key is not an option from the child.`);
|
|
28821
28875
|
}
|
|
@@ -28847,11 +28901,31 @@ function judgeSource(source) {
|
|
|
28847
28901
|
if (d.watermarkInMergeKeys && d.watermark !== undefined) {
|
|
28848
28902
|
out.push(`${where} declares merge_key= including the watermark dimension ` + `"${d.watermark.name}". Row identity must be independent of the ` + `watermark: a row restated with a LATER watermark value would not ` + `match its predecessor, so it would be inserted alongside the old ` + `row rather than replacing it — the failure merge_key= exists to ` + `prevent. List only the identity dimensions.`);
|
|
28849
28903
|
}
|
|
28904
|
+
out.push(...lookbackRejections(d, where));
|
|
28850
28905
|
if (d.calculateFields.length > 0) {
|
|
28851
28906
|
unbuildable.push(`it declares ${MODE} but computes ` + `${quoteList([...new Set(d.calculateFields)])} with calculate:. A ` + `window function is not supported on an incremental source yet: a ` + `delta recomputes only rows inside its range, so a frame that reaches ` + `outside that range assigns already-materialized rows values that ` + `later data changes, below the range start where no delta ever ` + `rewrites them. Frames strictly BACKWARD along the watermark ordering ` + `are stable and will become legal; every other frame will not. Use ` + `refresh="full", or move the window computation into the query that ` + `reads this source (plain non-additive aggregates like ` + `count_distinct are fine: a delta recomputes whole output rows from ` + `full input and never merges partial aggregates)`);
|
|
28852
28907
|
}
|
|
28853
28908
|
return { invalid: out, unbuildable };
|
|
28854
28909
|
}
|
|
28910
|
+
function lookbackRejections(d, where) {
|
|
28911
|
+
if (d.lookback === undefined)
|
|
28912
|
+
return [];
|
|
28913
|
+
const out = [];
|
|
28914
|
+
if (d.lookback.seconds !== undefined && d.lookback.seconds > MAX_LOOKBACK_SECONDS) {
|
|
28915
|
+
out.push(`${where} declares lookback=${JSON.stringify(d.lookback.text)}, ` + `longer than the most it takes, 365 days. Every refresh re-reads ` + `its whole lookback; to recompute that much history, rebuild the ` + `table (reseed) instead.`);
|
|
28916
|
+
}
|
|
28917
|
+
if (d.lookback.seconds === undefined) {
|
|
28918
|
+
out.push(`${where} declares lookback=${JSON.stringify(d.lookback.text)}, ` + `which is not a duration. Write a positive whole number and one ` + `unit of ${DURATION_UNIT_TEXT}, such as lookback="2 days" or ` + `lookback="36h".`);
|
|
28919
|
+
}
|
|
28920
|
+
if (!d.declaredMergeKey) {
|
|
28921
|
+
out.push(`${where} declares lookback= without merge_key=. lookback= re-reads ` + `rows the table already holds, below the newest stored ` + `watermark, and merge_key= is what matches each one to its stored ` + `copy instead of applying it again. Declare merge_key= with the ` + `row's identity dimensions, or remove lookback=.`);
|
|
28922
|
+
}
|
|
28923
|
+
const watermark = d.watermark;
|
|
28924
|
+
if (watermark !== undefined && watermark.kind !== "unresolved" && watermark.malloyType !== "date" && watermark.malloyType !== "timestamp") {
|
|
28925
|
+
out.push(`${where} declares lookback= with watermark="${watermark.name}", of ` + `type ${watermark.malloyType}. lookback= is a span of time, so it ` + `needs a date or timestamp watermark; a ${watermark.malloyType} ` + `watermark's delta already starts at the newest value the source ` + `held at the last refresh. Remove lookback=.`);
|
|
28926
|
+
}
|
|
28927
|
+
return out;
|
|
28928
|
+
}
|
|
28855
28929
|
function recordedLineage(d) {
|
|
28856
28930
|
const watermark = d.watermark;
|
|
28857
28931
|
return [
|
|
@@ -28910,9 +28984,11 @@ function incrementalPolicyAdvisories(sources) {
|
|
|
28910
28984
|
}
|
|
28911
28985
|
return warnings;
|
|
28912
28986
|
}
|
|
28913
|
-
var MODE = `refresh="incremental"`, INCREMENTAL_NO_MERGE_KEY_CODE = "persist-incremental-no-merge-key", INCREMENTAL_SHARED_ADDRESS_CODE = "persist-incremental-shared-address";
|
|
28987
|
+
var MODE = `refresh="incremental"`, MAX_LOOKBACK_SECONDS, INCREMENTAL_NO_MERGE_KEY_CODE = "persist-incremental-no-merge-key", INCREMENTAL_SHARED_ADDRESS_CODE = "persist-incremental-shared-address";
|
|
28914
28988
|
var init_incremental_policy = __esm(() => {
|
|
28915
28989
|
init_dialect();
|
|
28990
|
+
init_freshness();
|
|
28991
|
+
MAX_LOOKBACK_SECONDS = 365 * 86400;
|
|
28916
28992
|
});
|
|
28917
28993
|
|
|
28918
28994
|
// src/service/materialization/domain/table_plans.ts
|
|
@@ -31118,7 +31194,7 @@ var init_persisted_query = __esm(() => {
|
|
|
31118
31194
|
init_declaration();
|
|
31119
31195
|
init_persist_annotation_validation();
|
|
31120
31196
|
PERSIST_LINE = /^\s*#@\s*persist\b/;
|
|
31121
|
-
INCREMENTAL_KEYS = ["watermark", "merge_key"];
|
|
31197
|
+
INCREMENTAL_KEYS = ["watermark", "merge_key", "lookback"];
|
|
31122
31198
|
});
|
|
31123
31199
|
|
|
31124
31200
|
// src/service/materialization/plan/persisted_view.ts
|
|
@@ -34945,6 +35021,62 @@ var init_composite_row_filter = __esm(() => {
|
|
|
34945
35021
|
init_authorize_routes();
|
|
34946
35022
|
});
|
|
34947
35023
|
|
|
35024
|
+
// src/service/materialization/domain/live_big_integers.ts
|
|
35025
|
+
function liveRoundsBigIntegersAsPostgres(dialect) {
|
|
35026
|
+
return capabilitiesOf(dialect).liveRoundsBigIntegersMeasured;
|
|
35027
|
+
}
|
|
35028
|
+
function roundedAsLive(value) {
|
|
35029
|
+
const exact = typeof value === "bigint" || typeof value === "string" && /^-?\d+$/.test(value);
|
|
35030
|
+
if (!exact)
|
|
35031
|
+
return value;
|
|
35032
|
+
const nearest = Number(value);
|
|
35033
|
+
if (/e/i.test(String(nearest)))
|
|
35034
|
+
return nearest;
|
|
35035
|
+
return typeof value === "bigint" ? BigInt(String(nearest)) : String(nearest);
|
|
35036
|
+
}
|
|
35037
|
+
function roundValue(value, field) {
|
|
35038
|
+
if (value === null || value === undefined)
|
|
35039
|
+
return value;
|
|
35040
|
+
if (field.type === "number") {
|
|
35041
|
+
return field.numberType === "bigint" ? roundedAsLive(value) : value;
|
|
35042
|
+
}
|
|
35043
|
+
if (field.type === "array" && Array.isArray(value)) {
|
|
35044
|
+
if (field.fields) {
|
|
35045
|
+
for (const item of value)
|
|
35046
|
+
roundRecord(item, field);
|
|
35047
|
+
} else if (field.elementTypeDef) {
|
|
35048
|
+
const element = field.elementTypeDef;
|
|
35049
|
+
return value.map((item) => roundValue(item, element));
|
|
35050
|
+
}
|
|
35051
|
+
return value;
|
|
35052
|
+
}
|
|
35053
|
+
if (field.type === "record" && field.fields && typeof value === "object") {
|
|
35054
|
+
roundRecord(value, field);
|
|
35055
|
+
}
|
|
35056
|
+
return value;
|
|
35057
|
+
}
|
|
35058
|
+
function holdsBigInteger(field) {
|
|
35059
|
+
return field.numberType === "bigint" || (field.fields ?? []).some(holdsBigInteger) || field.elementTypeDef !== undefined && holdsBigInteger(field.elementTypeDef);
|
|
35060
|
+
}
|
|
35061
|
+
function roundRecord(row, struct) {
|
|
35062
|
+
for (const field of struct.fields ?? []) {
|
|
35063
|
+
const name = field.as ?? field.name;
|
|
35064
|
+
if (name in row)
|
|
35065
|
+
row[name] = roundValue(row[name], field);
|
|
35066
|
+
}
|
|
35067
|
+
}
|
|
35068
|
+
function roundBigIntegersAsLive(result) {
|
|
35069
|
+
const { structs, result: rows } = result._queryResult;
|
|
35070
|
+
const struct = structs[structs.length - 1];
|
|
35071
|
+
if (!struct || !holdsBigInteger(struct))
|
|
35072
|
+
return;
|
|
35073
|
+
for (const row of rows)
|
|
35074
|
+
roundRecord(row, struct);
|
|
35075
|
+
}
|
|
35076
|
+
var init_live_big_integers = __esm(() => {
|
|
35077
|
+
init_dialect();
|
|
35078
|
+
});
|
|
35079
|
+
|
|
34948
35080
|
// src/service/quoting.ts
|
|
34949
35081
|
function bareTableName(tableName) {
|
|
34950
35082
|
const lastDot = tableName.lastIndexOf(".");
|
|
@@ -35379,9 +35511,13 @@ function liveKeepsBigIntegers(dialect) {
|
|
|
35379
35511
|
return true;
|
|
35380
35512
|
}
|
|
35381
35513
|
}
|
|
35514
|
+
function storageReadsBigIntegers(dialect) {
|
|
35515
|
+
return liveKeepsBigIntegers(dialect) || liveRoundsBigIntegersAsPostgres(dialect);
|
|
35516
|
+
}
|
|
35382
35517
|
function bigIntegerReads(schema, fields, options) {
|
|
35383
|
-
if (!options.database && !
|
|
35518
|
+
if (!options.database && !storageReadsBigIntegers(options.dialect)) {
|
|
35384
35519
|
return [];
|
|
35520
|
+
}
|
|
35385
35521
|
const byName = new Map;
|
|
35386
35522
|
const declared = [];
|
|
35387
35523
|
const fieldOf = (f) => f ?? {};
|
|
@@ -35430,7 +35566,7 @@ function bigIntegerReads(schema, fields, options) {
|
|
|
35430
35566
|
return out;
|
|
35431
35567
|
}
|
|
35432
35568
|
function bigIntegerReadOf(field, column, options) {
|
|
35433
|
-
if (!options.database && !
|
|
35569
|
+
if (!options.database && !storageReadsBigIntegers(options.dialect)) {
|
|
35434
35570
|
return;
|
|
35435
35571
|
}
|
|
35436
35572
|
if (!isBigIntegerField(field))
|
|
@@ -35697,6 +35833,7 @@ function canonicalStoredSchema(schema, names) {
|
|
|
35697
35833
|
var STORED_COLUMN_TYPE_MISMATCH_CODE = "storage-column-type-mismatch", BUILD_CAST_TARGETS, CHECKED_TYPES, EXACT_INTEGER_STORAGE_TYPE = "DECIMAL(38,0)", INTEGER_TYPES, TIMESTAMPTZ_TYPES, NAIVE_TIMESTAMP_TYPES, HUGEINT_EXACT;
|
|
35698
35834
|
var init_stored_column_types = __esm(() => {
|
|
35699
35835
|
init_dialect();
|
|
35836
|
+
init_live_big_integers();
|
|
35700
35837
|
init_malloy_text();
|
|
35701
35838
|
init_quoting();
|
|
35702
35839
|
BUILD_CAST_TARGETS = {
|
|
@@ -38762,7 +38899,8 @@ var init_build_file_generator = __esm(() => {
|
|
|
38762
38899
|
"storage",
|
|
38763
38900
|
"refresh",
|
|
38764
38901
|
"watermark",
|
|
38765
|
-
"merge_key"
|
|
38902
|
+
"merge_key",
|
|
38903
|
+
"lookback"
|
|
38766
38904
|
];
|
|
38767
38905
|
});
|
|
38768
38906
|
|
|
@@ -39930,7 +40068,7 @@ var init_materialize_plan = __esm(() => {
|
|
|
39930
40068
|
"number",
|
|
39931
40069
|
"string"
|
|
39932
40070
|
]);
|
|
39933
|
-
INCREMENTAL_KEYS2 = ["refresh", "watermark", "merge_key"];
|
|
40071
|
+
INCREMENTAL_KEYS2 = ["refresh", "watermark", "merge_key", "lookback"];
|
|
39934
40072
|
});
|
|
39935
40073
|
|
|
39936
40074
|
// src/service/materialization/plan/eligibility_collect.ts
|
|
@@ -40794,6 +40932,13 @@ function resolveIncrementalDeclaration(source, annotationFields) {
|
|
|
40794
40932
|
mergeKeys.push(resolveName(name, columns, aggregates));
|
|
40795
40933
|
}
|
|
40796
40934
|
}
|
|
40935
|
+
const rawLookback = readKey(tag, "lookback");
|
|
40936
|
+
if (rawLookback.malformed)
|
|
40937
|
+
malformed.push(rawLookback.malformed);
|
|
40938
|
+
const lookback = rawLookback.text === undefined ? undefined : {
|
|
40939
|
+
text: rawLookback.text,
|
|
40940
|
+
...durationSeconds(rawLookback.text) !== undefined ? { seconds: durationSeconds(rawLookback.text) } : {}
|
|
40941
|
+
};
|
|
40797
40942
|
const watermarkInMergeKeys = watermark !== undefined && mergeKeys.some((k) => k.name === watermark.name);
|
|
40798
40943
|
const strategy = incremental && watermark !== undefined && watermark.kind === "dimension" ? mergeKeys.length > 0 ? "merge" : "range_replace" : undefined;
|
|
40799
40944
|
const unknownKeys = [];
|
|
@@ -40811,6 +40956,8 @@ function resolveIncrementalDeclaration(source, annotationFields) {
|
|
|
40811
40956
|
invalidRefresh,
|
|
40812
40957
|
declaredWatermark: rawWatermark.declared,
|
|
40813
40958
|
declaredMergeKey: rawMergeKey.declared,
|
|
40959
|
+
declaredLookback: rawLookback.declared,
|
|
40960
|
+
...lookback ? { lookback } : {},
|
|
40814
40961
|
watermark,
|
|
40815
40962
|
watermarkOrderable,
|
|
40816
40963
|
mergeKeys,
|
|
@@ -40828,6 +40975,7 @@ var REFRESH_MODES, ORDERABLE_TYPES;
|
|
|
40828
40975
|
var init_incremental_declaration = __esm(() => {
|
|
40829
40976
|
init_annotation_reader();
|
|
40830
40977
|
init_declaration();
|
|
40978
|
+
init_freshness();
|
|
40831
40979
|
init_persist_source_fields();
|
|
40832
40980
|
init_persist_dynamic_terms();
|
|
40833
40981
|
REFRESH_MODES = ["full", "incremental"];
|