@malloy-publisher/server 0.18.4 → 0.18.5
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 +28 -1
- package/dist/app/assets/{EnvironmentPage-BxNqq3cN.js → EnvironmentPage-C3gdsp81.js} +1 -1
- package/dist/app/assets/{HomePage-B4iN5rso.js → HomePage-DqgKtxBQ.js} +1 -1
- package/dist/app/assets/{MainPage-DGiMH0eU.js → MainPage-BnTI-1vD.js} +1 -1
- package/dist/app/assets/{ModelPage-BJmyMnQo.js → ModelPage-eLIQM9Js.js} +2 -2
- package/dist/app/assets/{PackagePage-D2Pay_Xy.js → PackagePage-CejLNGDv.js} +1 -1
- package/dist/app/assets/{PackageSplatRoute-CQ7PxhkD.js → PackageSplatRoute-CXdCJTYw.js} +2 -2
- package/dist/app/assets/{RenderedResult-BEJ_GMaW.es-DS2oXAjc.js → RenderedResult-cJiP774J.es-CZC2lkLE.js} +1 -1
- package/dist/app/assets/{RouteError-BysHaT0t.js → RouteError-_sExFuNk.js} +1 -1
- package/dist/app/assets/{ThemeEditorPage-BFyTBbqA.js → ThemeEditorPage-CaJX95t_.js} +1 -1
- package/dist/app/assets/{ToggleButtonGroup-eURRljZv.js → ToggleButtonGroup-DogvpiUV.js} +1 -1
- package/dist/app/assets/{documentRoutes-DgTzGqfC.js → documentRoutes-G_kvP2a6.js} +1 -1
- package/dist/app/assets/{editPageMounted-CWBeAIbE.js → editPageMounted-CM_VLUwp.js} +2 -2
- package/dist/app/assets/{index-N8X9kVzc.js → index-CYndXhSx.js} +1 -1
- package/dist/app/assets/{index-D4DhR2vg.js → index-D9nJPs77.js} +1 -1
- package/dist/app/assets/{index-We9Zzxmt.js → index-O_b7OJ2r.js} +1 -1
- package/dist/app/assets/{index-CCLHq9po.js → index-b7pou7Vk.js} +5 -5
- package/dist/app/assets/{index.es-D_O2KdNW.js → index.es-DQ-xbkiQ.js} +1 -1
- package/dist/app/assets/usePackageLinkNavigate-Lw9XmylW.js +1 -0
- package/dist/app/assets/{usePackageRoute-DEUbQLf3.js → usePackageRoute-yIGqS2C8.js} +1 -1
- package/dist/app/index.html +1 -1
- package/dist/instrumentation.mjs +1 -1
- package/dist/package_load_worker.mjs +954 -287
- package/dist/server.mjs +1331 -182
- package/package.json +1 -1
- package/dist/app/assets/usePackageLinkNavigate-CllycPZP.js +0 -1
package/dist/server.mjs
CHANGED
|
@@ -14181,7 +14181,7 @@ function errorMapping(error) {
|
|
|
14181
14181
|
function errorReason(error) {
|
|
14182
14182
|
return resolve(errorMapping(error).reason, error);
|
|
14183
14183
|
}
|
|
14184
|
-
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, ContractCaptureFailedError, SchemaIncompatibleError, PublisherConfigError, ServerConfigurationError, FrozenConfigError, AccessDeniedError, QueryCompileError, NotQueryableError, OffSurfaceError, MaterializationNotFoundError, MaterializationConflictError, MaterializedTableDropRefusedError, WriteConflictError, InstalledFromLocationError, WriteRolledBackError, ManifestBindFailedError, 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;
|
|
14184
|
+
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, ContainerNotFoundError, StorageDestinationNotFoundError, StorageCatalogNotFoundError, ConnectionAuthError, StorageAccessDeniedError, UnsupportedCatalogFormatError, ModelCompilationError, VersionFilesMissingError, PackageManifestError, MaterializationEligibilityError, ChainedUpstreamMissingError, ChainedShapeNotCarriedError, ContractCaptureFailedError, SchemaIncompatibleError, PublisherConfigError, ServerConfigurationError, FrozenConfigError, AccessDeniedError, QueryCompileError, NotQueryableError, OffSurfaceError, MaterializationNotFoundError, MaterializationConflictError, MaterializedTableDropRefusedError, WriteConflictError, InstalledFromLocationError, WriteRolledBackError, ManifestBindFailedError, 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;
|
|
14185
14185
|
var init_errors2 = __esm(() => {
|
|
14186
14186
|
init_constants();
|
|
14187
14187
|
init_logger();
|
|
@@ -14466,6 +14466,15 @@ var init_errors2 = __esm(() => {
|
|
|
14466
14466
|
super(message);
|
|
14467
14467
|
}
|
|
14468
14468
|
};
|
|
14469
|
+
ContainerNotFoundError = class ContainerNotFoundError extends Error {
|
|
14470
|
+
get kind() {
|
|
14471
|
+
return "container_not_found";
|
|
14472
|
+
}
|
|
14473
|
+
constructor(message) {
|
|
14474
|
+
super(message);
|
|
14475
|
+
this.name = "ContainerNotFoundError";
|
|
14476
|
+
}
|
|
14477
|
+
};
|
|
14469
14478
|
StorageDestinationNotFoundError = class StorageDestinationNotFoundError extends Error {
|
|
14470
14479
|
get kind() {
|
|
14471
14480
|
return "storage_destination_not_found";
|
|
@@ -14865,6 +14874,7 @@ var init_errors2 = __esm(() => {
|
|
|
14865
14874
|
result_truncated: ResultTruncatedError,
|
|
14866
14875
|
result_shape: ResultShapeError,
|
|
14867
14876
|
destination_not_found: DestinationNotFoundError,
|
|
14877
|
+
container_not_found: ContainerNotFoundError,
|
|
14868
14878
|
storage_destination_not_found: StorageDestinationNotFoundError,
|
|
14869
14879
|
storage_catalog_not_found: StorageCatalogNotFoundError,
|
|
14870
14880
|
connection_auth: ConnectionAuthError,
|
|
@@ -15070,6 +15080,7 @@ var init_errors2 = __esm(() => {
|
|
|
15070
15080
|
},
|
|
15071
15081
|
storage_catalog_not_found: { status: 404, mcp: { advice: "internal" } },
|
|
15072
15082
|
destination_not_found: { status: 422, mcp: { advice: "internal" } },
|
|
15083
|
+
container_not_found: { status: 422, mcp: { advice: "internal" } },
|
|
15073
15084
|
connection_auth: {
|
|
15074
15085
|
status: 424,
|
|
15075
15086
|
message: GENERIC_AUTH_MESSAGE,
|
|
@@ -24031,11 +24042,16 @@ function recordConnectionType(connection, type, options = {}) {
|
|
|
24031
24042
|
const recordedType = overrideOf(connection) ?? type;
|
|
24032
24043
|
if (recordedType)
|
|
24033
24044
|
recorded.set(connection, recordedType);
|
|
24045
|
+
if (options.config)
|
|
24046
|
+
configs.set(connection, options.config);
|
|
24034
24047
|
if (options.managed === true || managedOverrideOf(connection)) {
|
|
24035
24048
|
managed.set(connection, options.schemas ?? MAIN_ONLY);
|
|
24036
24049
|
}
|
|
24037
24050
|
return connection;
|
|
24038
24051
|
}
|
|
24052
|
+
function connectionConfigOf(connection) {
|
|
24053
|
+
return connection ? configs.get(connection) : undefined;
|
|
24054
|
+
}
|
|
24039
24055
|
function isManagedConnection(connection) {
|
|
24040
24056
|
return !!connection && managed.has(connection);
|
|
24041
24057
|
}
|
|
@@ -24057,10 +24073,11 @@ function resolveConnectionTypes(connections) {
|
|
|
24057
24073
|
}
|
|
24058
24074
|
return types;
|
|
24059
24075
|
}
|
|
24060
|
-
var recorded, managed, MAIN_ONLY, overrides, managedOverrides;
|
|
24076
|
+
var recorded, managed, configs, MAIN_ONLY, overrides, managedOverrides;
|
|
24061
24077
|
var init_connection_type = __esm(() => {
|
|
24062
24078
|
recorded = new WeakMap;
|
|
24063
24079
|
managed = new WeakMap;
|
|
24080
|
+
configs = new WeakMap;
|
|
24064
24081
|
MAIN_ONLY = managedSchemas();
|
|
24065
24082
|
overrides = [];
|
|
24066
24083
|
managedOverrides = [];
|
|
@@ -133085,7 +133102,8 @@ function buildEnvironmentMalloyConfig(connections = [], environmentPath = "", is
|
|
|
133085
133102
|
}
|
|
133086
133103
|
recordConnectionType(connection, metadata?.apiConnection.type, {
|
|
133087
133104
|
managed: metadata?.apiConnection.managed === true,
|
|
133088
|
-
schemas: managedSchemas(metadata?.apiConnection.ducklakeConnection?.readableSchemas)
|
|
133105
|
+
schemas: managedSchemas(metadata?.apiConnection.ducklakeConnection?.readableSchemas),
|
|
133106
|
+
config: metadata?.apiConnection
|
|
133089
133107
|
});
|
|
133090
133108
|
return applyConnectionFingerprint(connection, metadata);
|
|
133091
133109
|
}
|
|
@@ -133991,7 +134009,8 @@ var init_dialect = __esm(() => {
|
|
|
133991
134009
|
catalogHidesTables: false,
|
|
133992
134010
|
stringCollation: undefined,
|
|
133993
134011
|
ungroupableTypes: undefined,
|
|
133994
|
-
binary64Types: undefined
|
|
134012
|
+
binary64Types: undefined,
|
|
134013
|
+
containerCatalog: undefined
|
|
133995
134014
|
});
|
|
133996
134015
|
CAPABILITIES = {
|
|
133997
134016
|
duckdb: Object.freeze({
|
|
@@ -134010,10 +134029,12 @@ var init_dialect = __esm(() => {
|
|
|
134010
134029
|
utcSessions: true,
|
|
134011
134030
|
leafBudget: 120,
|
|
134012
134031
|
stringCollation: "instance",
|
|
134013
|
-
binary64Types: ["DOUBLE", "FLOAT8"]
|
|
134032
|
+
binary64Types: ["DOUBLE", "FLOAT8"],
|
|
134033
|
+
containerCatalog: "duckdb_schemas"
|
|
134014
134034
|
}),
|
|
134015
134035
|
postgres: Object.freeze({
|
|
134016
134036
|
...NONE,
|
|
134037
|
+
containerCatalog: "pg_namespace",
|
|
134017
134038
|
stringCollation: "column",
|
|
134018
134039
|
passthroughNumericAsDouble: true,
|
|
134019
134040
|
incrementalSourceRange: true,
|
|
@@ -134059,6 +134080,7 @@ var init_dialect = __esm(() => {
|
|
|
134059
134080
|
onlyBigIntegerType: "INT64",
|
|
134060
134081
|
leafBudget: 120,
|
|
134061
134082
|
stringCollation: "dataset",
|
|
134083
|
+
containerCatalog: "dataset",
|
|
134062
134084
|
ungroupableTypes: {
|
|
134063
134085
|
malloy: ["json", "array", "record"],
|
|
134064
134086
|
native: ["geography"]
|
|
@@ -134066,6 +134088,7 @@ var init_dialect = __esm(() => {
|
|
|
134066
134088
|
}),
|
|
134067
134089
|
snowflake: Object.freeze({
|
|
134068
134090
|
...NONE,
|
|
134091
|
+
containerCatalog: "schemata",
|
|
134069
134092
|
decodedTablePath: true,
|
|
134070
134093
|
catalogHidesTables: true,
|
|
134071
134094
|
incrementalSourceRange: true,
|
|
@@ -137598,6 +137621,21 @@ var init_declaration_text = __esm(() => {
|
|
|
137598
137621
|
TERM_NOT_FOUND = "a `where:` reading a given could not be found as written in the " + "source's declaration, so it cannot be left out of the build";
|
|
137599
137622
|
});
|
|
137600
137623
|
|
|
137624
|
+
// src/service/materialization/domain/rollup_grain.ts
|
|
137625
|
+
function pathColumnName(join, field) {
|
|
137626
|
+
return `${join}__${field}`;
|
|
137627
|
+
}
|
|
137628
|
+
function grainPathOf(grain) {
|
|
137629
|
+
const at = grain.indexOf(".");
|
|
137630
|
+
if (at < 0)
|
|
137631
|
+
return;
|
|
137632
|
+
return { join: grain.slice(0, at), field: grain.slice(at + 1) };
|
|
137633
|
+
}
|
|
137634
|
+
function grainColumnOf(grain) {
|
|
137635
|
+
const path = grainPathOf(grain);
|
|
137636
|
+
return path ? pathColumnName(path.join, path.field) : grain;
|
|
137637
|
+
}
|
|
137638
|
+
|
|
137601
137639
|
// src/service/materialization/domain/table_plans.ts
|
|
137602
137640
|
function splitSourceID(sourceID) {
|
|
137603
137641
|
const match = /^(.+)@([a-z][a-z0-9+.-]*:.*)$/i.exec(sourceID);
|
|
@@ -137761,7 +137799,10 @@ function persistLine(plan) {
|
|
|
137761
137799
|
return "#@ persist";
|
|
137762
137800
|
}
|
|
137763
137801
|
function emitRollupBuildSource(plan) {
|
|
137764
|
-
const grain = plan.grainDimensions.map((g) =>
|
|
137802
|
+
const grain = plan.grainDimensions.map((g) => {
|
|
137803
|
+
const path = grainPathOf(g);
|
|
137804
|
+
return path ? ` ${identifier(grainColumnOf(g))} is ${identifier(path.join)}.${identifier(path.field)}` : ` ${identifier(g)}`;
|
|
137805
|
+
}).join(`
|
|
137765
137806
|
`);
|
|
137766
137807
|
const partials = plan.rollupMeasures.flatMap((m) => m.partials).map((p) => ` ${identifier(p.column)} is ${emitMeasureExpr(p.leaf.expr)}`).join(`
|
|
137767
137808
|
`);
|
|
@@ -152489,16 +152530,7 @@ function declarationRefusal(decl, facts, ctx) {
|
|
|
152489
152530
|
return "skip";
|
|
152490
152531
|
return unservable("hidden_field", decl, "the measure is not public, and a rollup would publish it");
|
|
152491
152532
|
}
|
|
152492
|
-
const grainProblem = decl.grain
|
|
152493
|
-
const f = byName.get(g);
|
|
152494
|
-
if (g.includes(".")) {
|
|
152495
|
-
return `the grain names \`${g}\`, a path; declare a dimension on the source that reads it, and name that`;
|
|
152496
|
-
}
|
|
152497
|
-
if (!f || !isDimension(f)) {
|
|
152498
|
-
return `the grain names \`${g}\`, which is not a dimension of the source`;
|
|
152499
|
-
}
|
|
152500
|
-
return;
|
|
152501
|
-
}).find((p) => p !== undefined);
|
|
152533
|
+
const grainProblem = grainProblemOf(decl.grain, facts);
|
|
152502
152534
|
if (grainProblem) {
|
|
152503
152535
|
if (decl.v1)
|
|
152504
152536
|
return "skip";
|
|
@@ -152510,7 +152542,7 @@ function declarationRefusal(decl, facts, ctx) {
|
|
|
152510
152542
|
measure: decl.measure
|
|
152511
152543
|
};
|
|
152512
152544
|
}
|
|
152513
|
-
const timeRead = facts.windowed ? "the source's rows read the current time (a `where:` with `now` or a relative time filter such as `f'last 7 days'`, a rolling window)" : timeFields.has(decl.measure) ? "the measure reads the current time (`now`, or a relative time filter)" : decl.grain.filter((g) => timeFields.has(g)).map((g) => `its grain dimension \`${g}\` reads the current time (\`now\`, or a relative time filter)`)[0];
|
|
152545
|
+
const timeRead = facts.windowed ? "the source's rows read the current time (a `where:` with `now` or a relative time filter such as `f'last 7 days'`, a rolling window)" : timeFields.has(decl.measure) ? "the measure reads the current time (`now`, or a relative time filter)" : decl.grain.filter((g) => timeFields.has(g) || pathReadsCurrentTime(g, facts)).map((g) => `its grain dimension \`${g}\` reads the current time (\`now\`, or a relative time filter)`)[0];
|
|
152514
152546
|
if (timeRead) {
|
|
152515
152547
|
return unservable("current_time", decl, `${timeRead}, which a rollup would fix at build time while a live query reads it again at every read`);
|
|
152516
152548
|
}
|
|
@@ -152529,7 +152561,12 @@ function declarationRefusal(decl, facts, ctx) {
|
|
|
152529
152561
|
if (hiddenGrain) {
|
|
152530
152562
|
return unservable("hidden_field", decl, `its grain dimension \`${hiddenGrain}\` is private on a source it extends, declared in another file, which a rollup's build copy cannot lift`);
|
|
152531
152563
|
}
|
|
152532
|
-
const unreadableGrain = decl.storage === undefined ? undefined : unreadableStoredGrain(decl.grain,
|
|
152564
|
+
const unreadableGrain = decl.storage === undefined ? undefined : unreadableStoredGrain(decl.grain, (g) => {
|
|
152565
|
+
if (!g.includes("."))
|
|
152566
|
+
return byName.get(g);
|
|
152567
|
+
const path = pathGrainOf(g, facts);
|
|
152568
|
+
return "problem" in path ? undefined : path.joined;
|
|
152569
|
+
}, facts.dialect);
|
|
152533
152570
|
if (unreadableGrain) {
|
|
152534
152571
|
return unservable("unreadable_grain", decl, `its grain dimension \`${unreadableGrain.name}\` is stored as ${unreadableGrain.storedType}, which no read of a storage destination declares, so its table would cost a build no query reads; leave out storage= to build it in the source's own warehouse, which reads it`);
|
|
152535
152572
|
}
|
|
@@ -152558,11 +152595,142 @@ function declarationRefusal(decl, facts, ctx) {
|
|
|
152558
152595
|
}
|
|
152559
152596
|
return;
|
|
152560
152597
|
}
|
|
152561
|
-
function
|
|
152598
|
+
function grainProblemOf(grain, facts) {
|
|
152599
|
+
const { byName } = facts;
|
|
152600
|
+
const columns = new Map;
|
|
152601
|
+
return grain.map((g) => {
|
|
152602
|
+
const f = byName.get(g);
|
|
152603
|
+
if (g.includes(".")) {
|
|
152604
|
+
const path = pathGrainOf(g, facts);
|
|
152605
|
+
if ("problem" in path)
|
|
152606
|
+
return path.problem;
|
|
152607
|
+
const column = grainColumnOf(g);
|
|
152608
|
+
if (byName.has(column) || columns.has(column)) {
|
|
152609
|
+
return `the grain names \`${g}\`, stored as \`${column}\`, which is already the name of ${byName.has(column) ? "a field of the source" : `\`${columns.get(column)}\``}`;
|
|
152610
|
+
}
|
|
152611
|
+
columns.set(column, g);
|
|
152612
|
+
return;
|
|
152613
|
+
}
|
|
152614
|
+
if (!f || !isDimension(f)) {
|
|
152615
|
+
return `the grain names \`${g}\`, which is not a dimension of the source`;
|
|
152616
|
+
}
|
|
152617
|
+
columns.set(g, g);
|
|
152618
|
+
return;
|
|
152619
|
+
}).find((p) => p !== undefined);
|
|
152620
|
+
}
|
|
152621
|
+
function pathGrainOf(grain, facts) {
|
|
152622
|
+
const [head, second, ...rest] = grain.split(".");
|
|
152623
|
+
const join = facts.joins.get(head);
|
|
152624
|
+
const joinField = facts.byName.get(head);
|
|
152625
|
+
if (!join || !joinField) {
|
|
152626
|
+
return {
|
|
152627
|
+
problem: `the grain names \`${grain}\`, which reads no join of the source; a truncation or a field of a record is named through a dimension on the source that reads it`
|
|
152628
|
+
};
|
|
152629
|
+
}
|
|
152630
|
+
const joinedFields = new Map((joinField.fields ?? []).map((f) => [fieldNameOf(f), f]));
|
|
152631
|
+
const joined = joinedFields.get(second);
|
|
152632
|
+
if (rest.length > 0) {
|
|
152633
|
+
return {
|
|
152634
|
+
problem: joined?.join !== undefined ? `the grain names \`${grain}\`, a path through more than one join; a grain reads one join, so declare a dimension on \`${head}\`'s source that reads the rest, and name \`${head}.<that dimension>\`` : `the grain names \`${grain}\`, a truncation through a join; declare the truncated dimension on \`${head}\`'s source, and name \`${head}.<that dimension>\``
|
|
152635
|
+
};
|
|
152636
|
+
}
|
|
152637
|
+
if (join.relationship === "cross") {
|
|
152638
|
+
return {
|
|
152639
|
+
problem: `the grain names \`${grain}\`, through \`${head}\`, a join_cross; a path grain reads a join_one or a join_many`
|
|
152640
|
+
};
|
|
152641
|
+
}
|
|
152642
|
+
if (!joined || !isDimension(joined)) {
|
|
152643
|
+
return {
|
|
152644
|
+
problem: `the grain names \`${grain}\`, but \`${second}\` is not a dimension of \`${head}\`'s source`
|
|
152645
|
+
};
|
|
152646
|
+
}
|
|
152647
|
+
if (isHidden(joinField) || isHidden(joined)) {
|
|
152648
|
+
return {
|
|
152649
|
+
problem: `the grain names \`${grain}\`, which is not public (${isHidden(joinField) ? `the join \`${head}\`` : `\`${second}\` on its source`} is not), so a rollup's build cannot read it`
|
|
152650
|
+
};
|
|
152651
|
+
}
|
|
152652
|
+
return {
|
|
152653
|
+
join: head,
|
|
152654
|
+
field: second,
|
|
152655
|
+
joined,
|
|
152656
|
+
relationship: join.relationship
|
|
152657
|
+
};
|
|
152658
|
+
}
|
|
152659
|
+
function pathColumnsOf(grain, facts) {
|
|
152660
|
+
const out = [];
|
|
152661
|
+
const add = (entry, column, join, joined) => {
|
|
152662
|
+
const field = fieldNameOf(joined);
|
|
152663
|
+
const timeframe = joined.timeframe;
|
|
152664
|
+
out.push({
|
|
152665
|
+
grain: entry,
|
|
152666
|
+
column,
|
|
152667
|
+
join,
|
|
152668
|
+
field,
|
|
152669
|
+
...typeof timeframe === "string" ? { timeframe } : {},
|
|
152670
|
+
...fieldNotes(joined).length > 0 ? { annotated: true } : {}
|
|
152671
|
+
});
|
|
152672
|
+
};
|
|
152673
|
+
for (const g of grain) {
|
|
152674
|
+
if (g.includes(".")) {
|
|
152675
|
+
const path = pathGrainOf(g, facts);
|
|
152676
|
+
if (!("problem" in path))
|
|
152677
|
+
add(g, grainColumnOf(g), path.join, path.joined);
|
|
152678
|
+
continue;
|
|
152679
|
+
}
|
|
152680
|
+
const read = exactPathRead(facts.byName.get(g)?.e);
|
|
152681
|
+
if (!read)
|
|
152682
|
+
continue;
|
|
152683
|
+
const path = pathGrainOf(read.join("."), facts);
|
|
152684
|
+
if ("problem" in path)
|
|
152685
|
+
continue;
|
|
152686
|
+
add(g, g, path.join, path.joined);
|
|
152687
|
+
}
|
|
152688
|
+
return out;
|
|
152689
|
+
}
|
|
152690
|
+
function pathReadsCurrentTime(g, facts) {
|
|
152691
|
+
const path = grainPathOf(g);
|
|
152692
|
+
if (!path || !facts.joins.has(path.join))
|
|
152693
|
+
return false;
|
|
152694
|
+
const joinField = facts.byName.get(path.join);
|
|
152695
|
+
return currentTimeFields(joinField?.fields).has(path.field);
|
|
152696
|
+
}
|
|
152697
|
+
function joinOneGrainOf(grain, facts) {
|
|
152698
|
+
const byJoin = new Map;
|
|
152699
|
+
const add = (join, entry) => {
|
|
152700
|
+
if (facts.joins.get(join)?.relationship !== "one")
|
|
152701
|
+
return;
|
|
152702
|
+
const entries = byJoin.get(join) ?? [];
|
|
152703
|
+
if (!entries.includes(entry))
|
|
152704
|
+
entries.push(entry);
|
|
152705
|
+
byJoin.set(join, entries);
|
|
152706
|
+
};
|
|
152707
|
+
for (const g of grain) {
|
|
152708
|
+
const path = grainPathOf(g);
|
|
152709
|
+
if (path) {
|
|
152710
|
+
add(path.join, g);
|
|
152711
|
+
continue;
|
|
152712
|
+
}
|
|
152713
|
+
for (const j of facts.joinUsage.get(g)?.joins ?? [])
|
|
152714
|
+
add(j, g);
|
|
152715
|
+
}
|
|
152716
|
+
if (byJoin.size === 0)
|
|
152717
|
+
return {};
|
|
152718
|
+
return {
|
|
152719
|
+
joinOneGrain: [...byJoin].sort(([a], [b]) => byCodepoint3(a, b)).map(([join, entries]) => ({ join, grain: entries }))
|
|
152720
|
+
};
|
|
152721
|
+
}
|
|
152722
|
+
function exactPathRead(e) {
|
|
152723
|
+
const n = e;
|
|
152724
|
+
if (n?.node !== "field" || !Array.isArray(n.path) || n.path.length !== 2 || !n.path.every((p) => typeof p === "string")) {
|
|
152725
|
+
return;
|
|
152726
|
+
}
|
|
152727
|
+
return n.path;
|
|
152728
|
+
}
|
|
152729
|
+
function unreadableStoredGrain(grain, fieldOf, dialect) {
|
|
152562
152730
|
if (dialect !== STORAGE_DIALECT)
|
|
152563
152731
|
return;
|
|
152564
152732
|
for (const name of grain) {
|
|
152565
|
-
const f =
|
|
152733
|
+
const f = fieldOf(name);
|
|
152566
152734
|
if (f?.type !== "sql native" || typeof f.rawType !== "string")
|
|
152567
152735
|
continue;
|
|
152568
152736
|
const storedType = f.rawType.toUpperCase();
|
|
@@ -152650,6 +152818,7 @@ function rollupPlanOf({ decl, measures }, node, facts, ctx) {
|
|
|
152650
152818
|
inherited.set(`${at.range.start.line}:${at.range.start.character}`, at);
|
|
152651
152819
|
}
|
|
152652
152820
|
}
|
|
152821
|
+
const pathColumns = pathColumnsOf(decl.grain, facts);
|
|
152653
152822
|
const liftedAncestors = [...inherited.values()].sort((a, b) => a.range.start.line - b.range.start.line || a.range.start.character - b.range.start.character);
|
|
152654
152823
|
return {
|
|
152655
152824
|
variant: true,
|
|
@@ -152675,7 +152844,12 @@ function rollupPlanOf({ decl, measures }, node, facts, ctx) {
|
|
|
152675
152844
|
...liftedAncestors.length > 0 ? { liftedAncestors } : {},
|
|
152676
152845
|
..."terms" in facts.given && facts.given.terms.length > 0 ? { readTimeTerms: facts.given.terms } : {},
|
|
152677
152846
|
...(privateGrain.length > 0 || ("terms" in facts.given) && facts.given.terms.length > 0) && facts.declaration ? { declaration: facts.declaration } : {},
|
|
152847
|
+
...pathColumns.length > 0 ? { pathColumns } : {},
|
|
152848
|
+
...joinOneGrainOf(decl.grain, facts),
|
|
152678
152849
|
fanOutDimensions: decl.grain.filter((g) => {
|
|
152850
|
+
const path = grainPathOf(g);
|
|
152851
|
+
if (path)
|
|
152852
|
+
return joins.get(path.join)?.relationship !== "one";
|
|
152679
152853
|
const usage = joinUsage.get(g);
|
|
152680
152854
|
if (usage === undefined)
|
|
152681
152855
|
return joinUsage.has(g);
|
|
@@ -152846,8 +153020,9 @@ function storedDestinationsOf(map, struct) {
|
|
|
152846
153020
|
}
|
|
152847
153021
|
function rollupKeyCheckQuery(plan) {
|
|
152848
153022
|
const [key, ...rest] = plan.grainDimensions;
|
|
152849
|
-
if (key === undefined || rest.length > 0)
|
|
153023
|
+
if (key === undefined || rest.length > 0 || grainPathOf(key)) {
|
|
152850
153024
|
return;
|
|
153025
|
+
}
|
|
152851
153026
|
return `run: ${keyCheckPipeline("rollup_key", rollupBaseAlias(plan.baseDeclaredName), key)}`;
|
|
152852
153027
|
}
|
|
152853
153028
|
function parentKeyNeedsOf(map) {
|
|
@@ -158269,7 +158444,7 @@ var init_generated_files = __esm(() => {
|
|
|
158269
158444
|
});
|
|
158270
158445
|
|
|
158271
158446
|
// package.json
|
|
158272
|
-
var version = "0.18.
|
|
158447
|
+
var version = "0.18.5";
|
|
158273
158448
|
var init_package = () => {};
|
|
158274
158449
|
|
|
158275
158450
|
// src/version.ts
|
|
@@ -162048,6 +162223,28 @@ var init_access_closure = __esm(() => {
|
|
|
162048
162223
|
]);
|
|
162049
162224
|
});
|
|
162050
162225
|
|
|
162226
|
+
// src/service/materialization/domain/target_containers.ts
|
|
162227
|
+
function targetContainerKey(target) {
|
|
162228
|
+
return JSON.stringify([target.connectionName, target.container]);
|
|
162229
|
+
}
|
|
162230
|
+
function containerOfTableName(name) {
|
|
162231
|
+
const dot = name.lastIndexOf(".");
|
|
162232
|
+
return dot > 0 ? name.slice(0, dot) : undefined;
|
|
162233
|
+
}
|
|
162234
|
+
function missingContainerReason(target, dialect, reading) {
|
|
162235
|
+
const kind = capabilitiesOf(dialect).containerCatalog === "dataset" ? "dataset" : "schema";
|
|
162236
|
+
const where = `its name= places its table in ${kind} "${target.container}"`;
|
|
162237
|
+
if ("otherLocation" in reading) {
|
|
162238
|
+
const { location, expected } = reading.otherLocation;
|
|
162239
|
+
return `${where}, which is in location "${location}", but connection ` + `"${target.connectionName}" runs its queries in "${expected}"; ` + `create the ${kind} in "${expected}", or change name= to a ${kind} ` + `there`;
|
|
162240
|
+
}
|
|
162241
|
+
const project = reading.project ? ` (project "${reading.project}")` : "";
|
|
162242
|
+
return `${where}${project}, which connection "${target.connectionName}" does ` + `not hold, and no build creates one; create the ${kind}, or change ` + `name= to one that exists`;
|
|
162243
|
+
}
|
|
162244
|
+
var init_target_containers = __esm(() => {
|
|
162245
|
+
init_dialect();
|
|
162246
|
+
});
|
|
162247
|
+
|
|
162051
162248
|
// src/service/materialization/domain/package_plan.ts
|
|
162052
162249
|
function countRefusal(counts, reason) {
|
|
162053
162250
|
counts[reason] = (counts[reason] ?? 0) + 1;
|
|
@@ -162577,18 +162774,19 @@ function inDestinationStringReads(args, stored, planned, upstreams) {
|
|
|
162577
162774
|
const run = planned.kind === "query" ? `run: ${quotedIdentifier(planned.queryName)}` : `run: ${quotedIdentifier(planned.sourceName)} -> ${quotedIdentifier(planned.viewName)}`;
|
|
162578
162775
|
return planStringReads(args.stringReads, args.materializer, { run, stored: stored.upstreams.map((u) => u.sourceID) }, planned.storage, upstreams);
|
|
162579
162776
|
}
|
|
162580
|
-
async function chainedStringReads(source, modelDef, materializer, ports, judged) {
|
|
162777
|
+
async function chainedStringReads(source, modelDef, materializer, ports, judged, planned) {
|
|
162581
162778
|
const destination = declaredStorage(source)?.trim();
|
|
162582
162779
|
if (!destination)
|
|
162583
162780
|
return;
|
|
162584
162781
|
const map = SourceMap.of(modelDef);
|
|
162585
162782
|
const def = map.node(source.sourceID)?.def;
|
|
162586
|
-
if (def?.type !== "query_source"
|
|
162783
|
+
if (def?.type !== "query_source")
|
|
162587
162784
|
return;
|
|
162588
|
-
}
|
|
162589
162785
|
const stored = reachedUpstreams(def, modelDef, map).filter((u) => u.storage === destination && u.sourceID !== source.sourceID).map((u) => u.sourceID);
|
|
162590
162786
|
if (stored.length === 0)
|
|
162591
162787
|
return;
|
|
162788
|
+
if (sharesStoredBuild(source, stored, planned))
|
|
162789
|
+
return;
|
|
162592
162790
|
const reads = await planStringReads(ports, materializer, { downstream: source.name, stored }, destination, { modelDef, judged });
|
|
162593
162791
|
if (!("refused" in reads) || !reads.unstored)
|
|
162594
162792
|
return reads;
|
|
@@ -162599,6 +162797,19 @@ async function chainedStringReads(source, modelDef, materializer, ports, judged)
|
|
|
162599
162797
|
unstored: true
|
|
162600
162798
|
} : reads;
|
|
162601
162799
|
}
|
|
162800
|
+
function sharesStoredBuild(source, stored, planned) {
|
|
162801
|
+
const keyOf = (s) => {
|
|
162802
|
+
if (!s)
|
|
162803
|
+
return;
|
|
162804
|
+
try {
|
|
162805
|
+
return compilerBuildId(s);
|
|
162806
|
+
} catch {
|
|
162807
|
+
return;
|
|
162808
|
+
}
|
|
162809
|
+
};
|
|
162810
|
+
const own = keyOf(source);
|
|
162811
|
+
return own !== undefined && stored.some((id) => keyOf(planned.get(id)) === own);
|
|
162812
|
+
}
|
|
162602
162813
|
async function collectGeneratedPersistedViews(parts, args) {
|
|
162603
162814
|
const authorDef = modelDefOf(args.malloyModel);
|
|
162604
162815
|
const { generated, refused, refusedQueries, omitted, failure } = await tryCompilePersistedViewCompanion({
|
|
@@ -162945,6 +163156,7 @@ function reportPersistLineFindings(parts, targets, planned, args) {
|
|
|
162945
163156
|
async function planV1PersistSources(parts, planned, args) {
|
|
162946
163157
|
const { modelPath, packagePath, materializer, malloyModel } = args;
|
|
162947
163158
|
let classificationCtx;
|
|
163159
|
+
const plannedByID = new Map(planned.map((s) => [s.sourceID, s]));
|
|
162948
163160
|
for (const source of planned) {
|
|
162949
163161
|
const sourceID = source.sourceID;
|
|
162950
163162
|
try {
|
|
@@ -162974,7 +163186,7 @@ async function planV1PersistSources(parts, planned, args) {
|
|
|
162974
163186
|
modelDef: modelDefOf(malloyModel),
|
|
162975
163187
|
deps: gateDepsFor(malloyModel, modelPath)
|
|
162976
163188
|
};
|
|
162977
|
-
const stringReads = declaringModelPath(sourceIDFileURL(sourceID), packagePath, modelPath) === modelPath ? await chainedStringReads(source, classificationCtx.modelDef, materializer, args.stringReads, parts.stringCapabilityReads) : parts.tables[sourceID]?.stringReads;
|
|
163189
|
+
const stringReads = declaringModelPath(sourceIDFileURL(sourceID), packagePath, modelPath) === modelPath ? await chainedStringReads(source, classificationCtx.modelDef, materializer, args.stringReads, parts.stringCapabilityReads, plannedByID) : parts.tables[sourceID]?.stringReads;
|
|
162978
163190
|
const destination = declaredStorage(source)?.trim();
|
|
162979
163191
|
const map = SourceMap.of(classificationCtx.modelDef);
|
|
162980
163192
|
const query = map.node(sourceID)?.def?.query;
|
|
@@ -163151,7 +163363,7 @@ function finishBuildPlan(parts, ctx) {
|
|
|
163151
163363
|
addresses: planAddresses({ ...plan, tableFolds })
|
|
163152
163364
|
};
|
|
163153
163365
|
const refused = refuseCollidingMaterialize(refuseRewrittenNames(full));
|
|
163154
|
-
const known = refuseUpstreamUnread(refused);
|
|
163366
|
+
const known = refuseMissingContainers(refuseUpstreamUnread(refused), ctx.targetContainers);
|
|
163155
163367
|
return refuseOverMissingUpstreams(refuseUncomparableStrings(refuseAcrossPlacements(ctx.keepIncrementalUnbuildable ? known : refuseIncrementalUnbuildable(known))), full);
|
|
163156
163368
|
}
|
|
163157
163369
|
function refuseAcrossPlacements(compiled) {
|
|
@@ -163271,21 +163483,45 @@ function refuseOverMissingUpstreams(compiled, full = compiled) {
|
|
|
163271
163483
|
return dropped.size === 0 ? compiled : withoutSources(compiled, findings, dropped);
|
|
163272
163484
|
}
|
|
163273
163485
|
async function finishPackagePlan(parts, ctx) {
|
|
163274
|
-
const {
|
|
163486
|
+
const {
|
|
163487
|
+
getMalloyConnection,
|
|
163488
|
+
readUpstreamSchemas,
|
|
163489
|
+
readTargetContainers,
|
|
163490
|
+
...finish
|
|
163491
|
+
} = ctx;
|
|
163275
163492
|
const connections = await resolvePackageConnections({ getMalloyConnection }, parts.builds.map((b) => b.connectionName));
|
|
163276
163493
|
const digestSkipped = [];
|
|
163277
163494
|
const connectionDigests = await resolveConnectionDigests(connections, parts.builds, (name) => digestSkipped.push(name));
|
|
163278
163495
|
const upstreamSchemas = readUpstreamSchemas ? await readUpstreamSchemas(planUpstreamTables(parts.tables)) : undefined;
|
|
163496
|
+
const containers = planTargetContainers(parts.tables);
|
|
163497
|
+
const targetContainers = readTargetContainers && containers.length > 0 ? await readTargetContainers(containers) : undefined;
|
|
163279
163498
|
return {
|
|
163280
163499
|
compiled: finishBuildPlan(parts, {
|
|
163281
163500
|
...finish,
|
|
163282
163501
|
connectionDigests,
|
|
163283
163502
|
...upstreamSchemas ? { upstreamSchemas } : {},
|
|
163503
|
+
...targetContainers ? { targetContainers } : {},
|
|
163284
163504
|
connections
|
|
163285
163505
|
}),
|
|
163286
163506
|
digestSkipped
|
|
163287
163507
|
};
|
|
163288
163508
|
}
|
|
163509
|
+
function targetContainerOf(source) {
|
|
163510
|
+
if (declaredStorage(source) !== undefined)
|
|
163511
|
+
return;
|
|
163512
|
+
const name = deriveAnnotationFields(source).name;
|
|
163513
|
+
const container = name ? containerOfTableName(name) : undefined;
|
|
163514
|
+
return container ? { connectionName: source.connectionName, container } : undefined;
|
|
163515
|
+
}
|
|
163516
|
+
function planTargetContainers(tables) {
|
|
163517
|
+
const out = new Map;
|
|
163518
|
+
for (const { source } of Object.values(tables)) {
|
|
163519
|
+
const target = targetContainerOf(source);
|
|
163520
|
+
if (target)
|
|
163521
|
+
out.set(targetContainerKey(target), target);
|
|
163522
|
+
}
|
|
163523
|
+
return [...out.entries()].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([, t]) => t);
|
|
163524
|
+
}
|
|
163289
163525
|
function planUpstreamTables(tables) {
|
|
163290
163526
|
const out = new Map;
|
|
163291
163527
|
for (const { source } of Object.values(tables)) {
|
|
@@ -163452,6 +163688,26 @@ function refuseUpstreamUnread(compiled) {
|
|
|
163452
163688
|
}
|
|
163453
163689
|
return withoutSources(compiled, findings, dropped);
|
|
163454
163690
|
}
|
|
163691
|
+
function refuseMissingContainers(compiled, readings) {
|
|
163692
|
+
if (!readings)
|
|
163693
|
+
return compiled;
|
|
163694
|
+
const shared = sharedTables(compiled);
|
|
163695
|
+
const findings = [];
|
|
163696
|
+
const dropped = new Set;
|
|
163697
|
+
for (const [sourceID, { source }] of Object.entries(compiled.tables)) {
|
|
163698
|
+
if (shared.has(sourceID))
|
|
163699
|
+
continue;
|
|
163700
|
+
const target = targetContainerOf(source);
|
|
163701
|
+
if (!target)
|
|
163702
|
+
continue;
|
|
163703
|
+
const reading = readings[targetContainerKey(target)];
|
|
163704
|
+
if (!reading || "found" in reading || "unread" in reading)
|
|
163705
|
+
continue;
|
|
163706
|
+
dropped.add(sourceID);
|
|
163707
|
+
findings.push(notBuiltFinding(compiled, sourceID, "container_not_found", missingContainerReason(target, source.dialectName, reading)));
|
|
163708
|
+
}
|
|
163709
|
+
return withoutSources(compiled, findings, dropped);
|
|
163710
|
+
}
|
|
163455
163711
|
function notBuiltFinding(compiled, sourceID, reason, why) {
|
|
163456
163712
|
const table = compiled.tables[sourceID];
|
|
163457
163713
|
const source = table.source;
|
|
@@ -163656,6 +163912,7 @@ var init_build_plan = __esm(() => {
|
|
|
163656
163912
|
init_persist_source_fields();
|
|
163657
163913
|
init_quoting();
|
|
163658
163914
|
init_addressing();
|
|
163915
|
+
init_target_containers();
|
|
163659
163916
|
init_eligibility_collect();
|
|
163660
163917
|
init_plan_layers();
|
|
163661
163918
|
init_addressing();
|
|
@@ -164888,7 +165145,11 @@ async function collectPackageParts(pkg, signal, keyChecks) {
|
|
|
164888
165145
|
}
|
|
164889
165146
|
function upstreamReaderOf(pkg, use) {
|
|
164890
165147
|
const read = pkg.readUpstreamSchemas?.bind(pkg);
|
|
164891
|
-
|
|
165148
|
+
const containers = pkg.readTargetContainers?.bind(pkg);
|
|
165149
|
+
return {
|
|
165150
|
+
...read ? { readUpstreamSchemas: (tables) => read(tables, use) } : {},
|
|
165151
|
+
...containers ? { readTargetContainers: containers } : {}
|
|
165152
|
+
};
|
|
164892
165153
|
}
|
|
164893
165154
|
async function compilePackageBuildPlan(pkg, signal, {
|
|
164894
165155
|
keepIncrementalUnbuildable = false
|
|
@@ -165868,8 +166129,7 @@ async function applyLoadSessionSettings(session) {
|
|
|
165868
166129
|
`memory_limit='${escapeSQL(memoryLimit)}'`,
|
|
165869
166130
|
`max_temp_directory_size='${escapeSQL(settings.get("admin.maxTempDirectorySize"))}'`,
|
|
165870
166131
|
"preserve_insertion_order=false",
|
|
165871
|
-
"enable_http_metadata_cache=true"
|
|
165872
|
-
"parquet_metadata_cache=true"
|
|
166132
|
+
"enable_http_metadata_cache=true"
|
|
165873
166133
|
]) {
|
|
165874
166134
|
await session.runSQL(`SET ${setting}`);
|
|
165875
166135
|
}
|
|
@@ -168642,7 +168902,46 @@ function namesServedCopyAlias(text) {
|
|
|
168642
168902
|
function withoutServedCopyAliases(text) {
|
|
168643
168903
|
return text.replace(new RegExp(`'?__publisher_storage_${TOKEN}_\\d+'?`, "g"), "the storage destination");
|
|
168644
168904
|
}
|
|
168645
|
-
function
|
|
168905
|
+
function destinationOfAlias(name) {
|
|
168906
|
+
return destinationsByAlias.get(name);
|
|
168907
|
+
}
|
|
168908
|
+
function servedConnectionLabel(name) {
|
|
168909
|
+
const destination = destinationsByAlias.get(name);
|
|
168910
|
+
return destination !== undefined ? `storage destination '${destination}'` : `connection '${name}'`;
|
|
168911
|
+
}
|
|
168912
|
+
function underAlias(connection, alias) {
|
|
168913
|
+
let views = aliasedViews.get(connection);
|
|
168914
|
+
if (!views) {
|
|
168915
|
+
views = new Map;
|
|
168916
|
+
aliasedViews.set(connection, views);
|
|
168917
|
+
}
|
|
168918
|
+
const known = views.get(alias);
|
|
168919
|
+
if (known)
|
|
168920
|
+
return known;
|
|
168921
|
+
const view = new Proxy(connection, {
|
|
168922
|
+
get(target, prop) {
|
|
168923
|
+
if (prop === "name")
|
|
168924
|
+
return alias;
|
|
168925
|
+
if (prop === "fetchSchemaForTables") {
|
|
168926
|
+
return async (...args) => {
|
|
168927
|
+
const fetched = await target.fetchSchemaForTables(...args);
|
|
168928
|
+
return {
|
|
168929
|
+
...fetched,
|
|
168930
|
+
schemas: Object.fromEntries(Object.entries(fetched.schemas).map(([key, def]) => [
|
|
168931
|
+
key,
|
|
168932
|
+
{ ...def, connection: alias }
|
|
168933
|
+
]))
|
|
168934
|
+
};
|
|
168935
|
+
};
|
|
168936
|
+
}
|
|
168937
|
+
const value = Reflect.get(target, prop, target);
|
|
168938
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
168939
|
+
}
|
|
168940
|
+
});
|
|
168941
|
+
views.set(alias, view);
|
|
168942
|
+
return view;
|
|
168943
|
+
}
|
|
168944
|
+
function servedCopyConfig(packageConfig, destinations, allowed, tablesUnderAlias = new Set) {
|
|
168646
168945
|
const base = toMalloyConfig(packageConfig);
|
|
168647
168946
|
const config = new MalloyConfig3({ connections: {} });
|
|
168648
168947
|
config.wrapConnections(() => ({
|
|
@@ -168653,7 +168952,8 @@ function servedCopyConfig(packageConfig, destinations, allowed) {
|
|
|
168653
168952
|
if (!allowed.has(destination)) {
|
|
168654
168953
|
throw new Error(`A storage destination is not available to this served copy`);
|
|
168655
168954
|
}
|
|
168656
|
-
|
|
168955
|
+
const connection = await destinations.connections.lookupConnection(destination);
|
|
168956
|
+
return tablesUnderAlias.has(destination) ? underAlias(connection, name) : connection;
|
|
168657
168957
|
}
|
|
168658
168958
|
}
|
|
168659
168959
|
return base.connections.lookupConnection(name);
|
|
@@ -168661,16 +168961,35 @@ function servedCopyConfig(packageConfig, destinations, allowed) {
|
|
|
168661
168961
|
}));
|
|
168662
168962
|
return config;
|
|
168663
168963
|
}
|
|
168664
|
-
var TOKEN, aliases, destinationsByAlias;
|
|
168964
|
+
var TOKEN, aliases, destinationsByAlias, aliasedViews;
|
|
168665
168965
|
var init_served_copy_config = __esm(() => {
|
|
168666
168966
|
init_model_runtime();
|
|
168667
168967
|
TOKEN = randomBytes2(12).toString("hex");
|
|
168668
168968
|
aliases = new Map;
|
|
168669
168969
|
destinationsByAlias = new Map;
|
|
168970
|
+
aliasedViews = new WeakMap;
|
|
168670
168971
|
});
|
|
168671
168972
|
|
|
168672
168973
|
// src/service/materialization/text/cross_connection_text.ts
|
|
168673
168974
|
import { MalloyError as MalloyError4 } from "@malloydata/malloy";
|
|
168975
|
+
function refusedJoinConnections(message) {
|
|
168976
|
+
const named = /which is on connection '([^']*)', into a source on connection '([^']*)'/.exec(message ?? "");
|
|
168977
|
+
return named ? { joined: named[1], into: named[2] } : undefined;
|
|
168978
|
+
}
|
|
168979
|
+
function refusedJoinPairs(error) {
|
|
168980
|
+
if (!isCrossConnectionRefusal(error))
|
|
168981
|
+
return;
|
|
168982
|
+
const pairs = [];
|
|
168983
|
+
for (const p of errorProblems(error) ?? []) {
|
|
168984
|
+
if (p.code !== JOIN_CONNECTION_MISMATCH)
|
|
168985
|
+
continue;
|
|
168986
|
+
const pair = refusedJoinConnections(p.message);
|
|
168987
|
+
if (!pair)
|
|
168988
|
+
return;
|
|
168989
|
+
pairs.push(pair);
|
|
168990
|
+
}
|
|
168991
|
+
return pairs;
|
|
168992
|
+
}
|
|
168674
168993
|
function isJoinConnectionMismatch(code) {
|
|
168675
168994
|
return code === JOIN_CONNECTION_MISMATCH;
|
|
168676
168995
|
}
|
|
@@ -168787,10 +169106,12 @@ async function leaveOut(args, escalated) {
|
|
|
168787
169106
|
continue;
|
|
168788
169107
|
}
|
|
168789
169108
|
cuts.push(cut);
|
|
169109
|
+
const connections = refused ? refusedJoinConnections(p.message) : undefined;
|
|
168790
169110
|
leftOut.push({
|
|
168791
169111
|
url,
|
|
168792
169112
|
...cut.left,
|
|
168793
169113
|
crossConnection: refused,
|
|
169114
|
+
...connections ? { connections } : {},
|
|
168794
169115
|
...cut !== own && own?.left.keyword.startsWith("join_") ? { join: own.left.name } : {}
|
|
168795
169116
|
});
|
|
168796
169117
|
}
|
|
@@ -169883,6 +170204,230 @@ var init_query_walks = __esm(() => {
|
|
|
169883
170204
|
walks2 = new Map;
|
|
169884
170205
|
});
|
|
169885
170206
|
|
|
170207
|
+
// src/service/materialization/serve/same_catalog_reads.ts
|
|
170208
|
+
function destinationTablePath(path, move) {
|
|
170209
|
+
const parts = path.split(".");
|
|
170210
|
+
if (!PLAIN.test(move.destination) || !parts.every((p) => PLAIN.test(p))) {
|
|
170211
|
+
return;
|
|
170212
|
+
}
|
|
170213
|
+
const self2 = move.connection.toLowerCase();
|
|
170214
|
+
const readable = (s) => move.schemas.has(s.toLowerCase());
|
|
170215
|
+
const at = (schema, table) => `${move.destination}.${schema}.${table}`;
|
|
170216
|
+
if (parts.length === 1)
|
|
170217
|
+
return at("main", parts[0]);
|
|
170218
|
+
if (parts.length === 2) {
|
|
170219
|
+
const [first, table] = parts;
|
|
170220
|
+
if (first.toLowerCase() === self2) {
|
|
170221
|
+
return readable(first) ? undefined : at("main", table);
|
|
170222
|
+
}
|
|
170223
|
+
return readable(first) ? at(first, table) : undefined;
|
|
170224
|
+
}
|
|
170225
|
+
if (parts.length === 3) {
|
|
170226
|
+
const [catalog, schema, table] = parts;
|
|
170227
|
+
return catalog.toLowerCase() === self2 && readable(schema) ? at(schema, table) : undefined;
|
|
170228
|
+
}
|
|
170229
|
+
return;
|
|
170230
|
+
}
|
|
170231
|
+
function literalValue(token) {
|
|
170232
|
+
const m = /^(['"])([^'"\\]*)\1$/.exec(token?.text ?? "");
|
|
170233
|
+
return m ? m[2] : undefined;
|
|
170234
|
+
}
|
|
170235
|
+
function namesConnection(token, name) {
|
|
170236
|
+
return token.kind === "word" && token.text === name || token.text.length === name.length + 2 && token.text.startsWith("`") && token.text.endsWith("`") && token.text.slice(1, -1) === name;
|
|
170237
|
+
}
|
|
170238
|
+
function readThroughDestination(text, move) {
|
|
170239
|
+
const tokens = lexAll(text);
|
|
170240
|
+
if (!tokens)
|
|
170241
|
+
return;
|
|
170242
|
+
const edits = [];
|
|
170243
|
+
const paths = [];
|
|
170244
|
+
for (let k = 0;k < tokens.length; k++) {
|
|
170245
|
+
const t = tokens[k];
|
|
170246
|
+
if (!namesConnection(t, move.connection))
|
|
170247
|
+
continue;
|
|
170248
|
+
if (tokens[k - 1]?.text === ".")
|
|
170249
|
+
continue;
|
|
170250
|
+
if (tokens[k + 1]?.text !== ".")
|
|
170251
|
+
continue;
|
|
170252
|
+
const method = tokens[k + 2];
|
|
170253
|
+
if (method?.kind !== "word")
|
|
170254
|
+
continue;
|
|
170255
|
+
if (method.text !== "table")
|
|
170256
|
+
return;
|
|
170257
|
+
const value = literalValue(tokens[k + 4]);
|
|
170258
|
+
if (tokens[k + 3]?.text !== "(" || value === undefined || tokens[k + 5]?.text !== ")") {
|
|
170259
|
+
return;
|
|
170260
|
+
}
|
|
170261
|
+
const moved = destinationTablePath(value, move);
|
|
170262
|
+
if (moved === undefined)
|
|
170263
|
+
return;
|
|
170264
|
+
paths.push(value);
|
|
170265
|
+
edits.push({
|
|
170266
|
+
start: t.start,
|
|
170267
|
+
end: tokens[k + 5].end,
|
|
170268
|
+
text: `${identifier(move.alias)}.table(${stringLiteral(moved)})`
|
|
170269
|
+
});
|
|
170270
|
+
k += 5;
|
|
170271
|
+
}
|
|
170272
|
+
let out = text;
|
|
170273
|
+
for (const e of edits.reverse()) {
|
|
170274
|
+
out = out.slice(0, e.start) + e.text + out.slice(e.end);
|
|
170275
|
+
}
|
|
170276
|
+
return { text: out, paths };
|
|
170277
|
+
}
|
|
170278
|
+
async function sameCatalogMoves(error, ports) {
|
|
170279
|
+
const pairs = refusedJoinPairs(error);
|
|
170280
|
+
if (!pairs?.length)
|
|
170281
|
+
return;
|
|
170282
|
+
const moves = new Map;
|
|
170283
|
+
for (const { joined, into } of pairs) {
|
|
170284
|
+
const intoDestination = destinationOfAlias(into);
|
|
170285
|
+
const joinedDestination = destinationOfAlias(joined);
|
|
170286
|
+
const [connection, alias, destination] = intoDestination !== undefined && joinedDestination === undefined ? [joined, into, intoDestination] : joinedDestination !== undefined && intoDestination === undefined ? [into, joined, joinedDestination] : [];
|
|
170287
|
+
if (!connection || !alias || !destination)
|
|
170288
|
+
return;
|
|
170289
|
+
const known = moves.get(connection);
|
|
170290
|
+
if (known) {
|
|
170291
|
+
if (known.alias !== alias)
|
|
170292
|
+
return;
|
|
170293
|
+
continue;
|
|
170294
|
+
}
|
|
170295
|
+
const schemas = await ports.scope(connection, alias);
|
|
170296
|
+
if (!schemas)
|
|
170297
|
+
return;
|
|
170298
|
+
moves.set(connection, { connection, alias, destination, schemas });
|
|
170299
|
+
}
|
|
170300
|
+
return [...moves.values()];
|
|
170301
|
+
}
|
|
170302
|
+
function movedAuthorSqlCause(modelDef, connections, rerooted) {
|
|
170303
|
+
const { contents } = authorModelReachContext(modelDef);
|
|
170304
|
+
for (const [name, def] of Object.entries(contents)) {
|
|
170305
|
+
const d = def;
|
|
170306
|
+
if (typeof d.connection !== "string" || !connections.has(d.connection)) {
|
|
170307
|
+
continue;
|
|
170308
|
+
}
|
|
170309
|
+
if (typeof d.sourceID === "string" && rerooted.has(d.sourceID)) {
|
|
170310
|
+
for (const field of Array.isArray(d.fields) ? d.fields : []) {
|
|
170311
|
+
const f = field;
|
|
170312
|
+
if (f.join === undefined)
|
|
170313
|
+
continue;
|
|
170314
|
+
const cause = authorSqlCause(field);
|
|
170315
|
+
if (cause)
|
|
170316
|
+
return `the join '${String(f.name)}' of '${name}': ${cause}`;
|
|
170317
|
+
}
|
|
170318
|
+
continue;
|
|
170319
|
+
}
|
|
170320
|
+
const cause = authorSqlCause(def);
|
|
170321
|
+
if (cause)
|
|
170322
|
+
return `the source '${name}': ${cause}`;
|
|
170323
|
+
}
|
|
170324
|
+
return;
|
|
170325
|
+
}
|
|
170326
|
+
function declaringFiles(modelDef, connections) {
|
|
170327
|
+
const { contents } = authorModelReachContext(modelDef);
|
|
170328
|
+
const urls = new Set;
|
|
170329
|
+
for (const def of Object.values(contents)) {
|
|
170330
|
+
const d = def;
|
|
170331
|
+
if (typeof d.connection === "string" && connections.has(d.connection) && typeof d.location?.url === "string") {
|
|
170332
|
+
urls.add(d.location.url);
|
|
170333
|
+
}
|
|
170334
|
+
}
|
|
170335
|
+
return [...urls];
|
|
170336
|
+
}
|
|
170337
|
+
async function readSameCatalogThroughDestination(args) {
|
|
170338
|
+
const moves = await sameCatalogMoves(args.error, args.ports);
|
|
170339
|
+
if (!moves) {
|
|
170340
|
+
return {
|
|
170341
|
+
declined: "a refused join is not into a managed connection's own catalog"
|
|
170342
|
+
};
|
|
170343
|
+
}
|
|
170344
|
+
const names = new Set(moves.map((m) => m.connection));
|
|
170345
|
+
const sql = movedAuthorSqlCause(args.modelDef, names, args.rerooted);
|
|
170346
|
+
if (sql)
|
|
170347
|
+
return { declined: `${sql}, which carries author SQL` };
|
|
170348
|
+
const urls = new Set([
|
|
170349
|
+
...args.files.keys(),
|
|
170350
|
+
...declaringFiles(args.modelDef, names)
|
|
170351
|
+
]);
|
|
170352
|
+
const out = new Map(args.files);
|
|
170353
|
+
for (const move of moves) {
|
|
170354
|
+
const paths = [];
|
|
170355
|
+
for (const url of urls) {
|
|
170356
|
+
const text = out.get(url) ?? args.readText(url);
|
|
170357
|
+
if (text === undefined)
|
|
170358
|
+
return { declined: "a file it cannot read" };
|
|
170359
|
+
const read = readThroughDestination(text, move);
|
|
170360
|
+
if (!read) {
|
|
170361
|
+
return {
|
|
170362
|
+
declined: `connection '${move.connection}' is named other than in a plain .table() it can place`
|
|
170363
|
+
};
|
|
170364
|
+
}
|
|
170365
|
+
if (read.paths.length === 0)
|
|
170366
|
+
continue;
|
|
170367
|
+
paths.push(...read.paths);
|
|
170368
|
+
out.set(url, read.text);
|
|
170369
|
+
}
|
|
170370
|
+
for (const path of paths) {
|
|
170371
|
+
const refused = await args.ports.pathRefusal(path, move.connection, move.schemas);
|
|
170372
|
+
if (refused !== undefined) {
|
|
170373
|
+
return {
|
|
170374
|
+
declined: `table '${path}' is outside the connection's scope`
|
|
170375
|
+
};
|
|
170376
|
+
}
|
|
170377
|
+
}
|
|
170378
|
+
const tables = [...new Set(paths)].map((path) => {
|
|
170379
|
+
const [catalog, schema, table] = destinationTablePath(path, move).split(".");
|
|
170380
|
+
return [catalog, schema, table];
|
|
170381
|
+
});
|
|
170382
|
+
if (!await args.ports.baseTables(move.alias, tables)) {
|
|
170383
|
+
return { declined: "a table it reads is not a base table" };
|
|
170384
|
+
}
|
|
170385
|
+
}
|
|
170386
|
+
return {
|
|
170387
|
+
files: out,
|
|
170388
|
+
destinations: new Set(moves.map((m) => m.destination))
|
|
170389
|
+
};
|
|
170390
|
+
}
|
|
170391
|
+
var PLAIN;
|
|
170392
|
+
var init_same_catalog_reads = __esm(() => {
|
|
170393
|
+
init_malloy_lexer_core();
|
|
170394
|
+
init_malloy_text();
|
|
170395
|
+
init_same_catalog_build();
|
|
170396
|
+
init_author_model();
|
|
170397
|
+
init_cross_connection_text();
|
|
170398
|
+
init_served_copy_config();
|
|
170399
|
+
PLAIN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
170400
|
+
});
|
|
170401
|
+
|
|
170402
|
+
// src/service/same_catalog_destination.ts
|
|
170403
|
+
async function sameCatalogScope(config, connection, alias) {
|
|
170404
|
+
const [source, destination] = await Promise.all([
|
|
170405
|
+
config.connections.lookupConnection(connection).catch(() => {
|
|
170406
|
+
return;
|
|
170407
|
+
}),
|
|
170408
|
+
config.connections.lookupConnection(alias).catch(() => {
|
|
170409
|
+
return;
|
|
170410
|
+
})
|
|
170411
|
+
]);
|
|
170412
|
+
const schemas = managedSchemasOf(source);
|
|
170413
|
+
return schemas && isSameCatalog(connectionConfigOf(source), connectionConfigOf(destination)) ? schemas : undefined;
|
|
170414
|
+
}
|
|
170415
|
+
async function allBaseTables(config, alias, tables) {
|
|
170416
|
+
const destination = await config.connections.lookupConnection(alias);
|
|
170417
|
+
for (const [catalog, schema, table] of tables) {
|
|
170418
|
+
const result = await destination.runSQL("SELECT table_type FROM information_schema.tables " + `WHERE table_catalog = '${catalog}' ` + `AND lower(table_schema) = lower('${schema}') ` + `AND lower(table_name) = lower('${table}')`);
|
|
170419
|
+
const rows = result.rows;
|
|
170420
|
+
if (rows.length !== 1 || rows[0].table_type !== "BASE TABLE") {
|
|
170421
|
+
return false;
|
|
170422
|
+
}
|
|
170423
|
+
}
|
|
170424
|
+
return true;
|
|
170425
|
+
}
|
|
170426
|
+
var init_same_catalog_destination = __esm(() => {
|
|
170427
|
+
init_connection_type();
|
|
170428
|
+
init_same_catalog_build();
|
|
170429
|
+
});
|
|
170430
|
+
|
|
169886
170431
|
// src/service/materialization/serve/result_reads.ts
|
|
169887
170432
|
function nonStringType2(t) {
|
|
169888
170433
|
return typeof t === "string" && t !== "string";
|
|
@@ -170731,27 +171276,54 @@ import {
|
|
|
170731
171276
|
function servedConnectionOf(b) {
|
|
170732
171277
|
return isDatabase(b) ? b.destinationName : servedCopyAlias(b.destinationName);
|
|
170733
171278
|
}
|
|
170734
|
-
function
|
|
171279
|
+
function leftOutJoinDetail(joins) {
|
|
171280
|
+
const named = joins.map((j) => {
|
|
171281
|
+
const join = j.join ?? j.name;
|
|
171282
|
+
const source = j.declaration ?? (j.join !== undefined ? j.name : undefined);
|
|
171283
|
+
const where = source ? ` of \`${source}\`` : "";
|
|
171284
|
+
const across = j.connections ? ` (${servedConnectionLabel(j.connections.joined)} into ` + `${servedConnectionLabel(j.connections.into)})` : "";
|
|
171285
|
+
return `\`${join}\`${where}${across}`;
|
|
171286
|
+
});
|
|
171287
|
+
const subject = named.length === 0 ? "a join" : `the join${named.length === 1 ? "" : "s"} ${named.join(", ")}`;
|
|
171288
|
+
return `The query uses ${subject}, whose joined source is on another connection ` + "than the storage destination its table is read from, so it is answered live.";
|
|
171289
|
+
}
|
|
171290
|
+
function leftOutJoinsRead(compiled, error, queryString) {
|
|
170735
171291
|
if (!compiled.leftOut?.length)
|
|
170736
|
-
return
|
|
170737
|
-
|
|
171292
|
+
return;
|
|
171293
|
+
const read = missingNamesRead(new Set(compiled.leftOut.map((l) => l.name)), error, queryString);
|
|
171294
|
+
if (read === undefined)
|
|
171295
|
+
return;
|
|
171296
|
+
const joins = compiled.leftOut.filter((l) => l.crossConnection);
|
|
171297
|
+
const direct = joins.filter((l) => read.has(l.name));
|
|
171298
|
+
return direct.length > 0 ? direct : joins;
|
|
170738
171299
|
}
|
|
170739
171300
|
function readsMissingName(names, error, queryString) {
|
|
171301
|
+
return missingNamesRead(names, error, queryString) !== undefined;
|
|
171302
|
+
}
|
|
171303
|
+
function missingNamesRead(names, error, queryString) {
|
|
170740
171304
|
if (!(error instanceof MalloyError5))
|
|
170741
|
-
return
|
|
170742
|
-
|
|
170743
|
-
|
|
170744
|
-
|
|
170745
|
-
|
|
171305
|
+
return;
|
|
171306
|
+
const read = new Set;
|
|
171307
|
+
let any = false;
|
|
171308
|
+
for (const p of error.problems) {
|
|
171309
|
+
if (p.code === undefined || !MISSING_FIELD_CODES.has(p.code))
|
|
171310
|
+
continue;
|
|
170746
171311
|
const start = p.at?.range?.start;
|
|
170747
171312
|
const offset = start ? offsetOf(queryString, start) : -1;
|
|
170748
|
-
|
|
170749
|
-
|
|
170750
|
-
|
|
170751
|
-
|
|
170752
|
-
|
|
170753
|
-
|
|
170754
|
-
|
|
171313
|
+
const path = offset < 0 ? undefined : /^[`A-Za-z0-9_.]+/.exec(queryString.slice(offset))?.[0];
|
|
171314
|
+
if (!path) {
|
|
171315
|
+
any = true;
|
|
171316
|
+
continue;
|
|
171317
|
+
}
|
|
171318
|
+
for (const part of path.split(".")) {
|
|
171319
|
+
const name = part.replace(/^`|`$/g, "");
|
|
171320
|
+
if (names.has(name)) {
|
|
171321
|
+
read.add(name);
|
|
171322
|
+
any = true;
|
|
171323
|
+
}
|
|
171324
|
+
}
|
|
171325
|
+
}
|
|
171326
|
+
return any ? read : undefined;
|
|
170755
171327
|
}
|
|
170756
171328
|
function rerootFailureKey(packagePath, modelPath, bindings, overlay) {
|
|
170757
171329
|
const hash = createHash9("sha256");
|
|
@@ -170921,8 +171493,10 @@ class ServedCopyServe {
|
|
|
170921
171493
|
try {
|
|
170922
171494
|
return await work();
|
|
170923
171495
|
} catch (error) {
|
|
170924
|
-
|
|
170925
|
-
|
|
171496
|
+
const leftOutJoins = leftOutJoinsRead(compiled, error, queryString);
|
|
171497
|
+
if (leftOutJoins) {
|
|
171498
|
+
const detail = leftOutJoinDetail(leftOutJoins);
|
|
171499
|
+
decline(`the query reads a join the served copy leaves out across connections: ${detail}`, "served_copy_cross_connection", detail);
|
|
170926
171500
|
}
|
|
170927
171501
|
const zoned = new Set([...compiled.zonedLeftOut?.values() ?? []].flatMap((n) => [
|
|
170928
171502
|
...n
|
|
@@ -171669,9 +172243,11 @@ class ServedCopyServe {
|
|
|
171669
172243
|
}));
|
|
171670
172244
|
const overlay = new Map(copy.files);
|
|
171671
172245
|
const packagePath = this.packagePath;
|
|
171672
|
-
const
|
|
172246
|
+
const packageConfig = this.packageConfig;
|
|
172247
|
+
const config = servedCopyConfig(packageConfig, destinations(), new Set(rerooted.filter((b) => !isDatabase(b)).map((b) => b.destinationName)));
|
|
171673
172248
|
const load = this.passLoader(packagePath, config);
|
|
171674
|
-
const
|
|
172249
|
+
const underAlias = this.underAliasLoader(packagePath, packageConfig, destinations, rerooted);
|
|
172250
|
+
const loaded = await this.loadCopy(state, copy, overlay, load, lift, config, underAlias);
|
|
171675
172251
|
if (loaded === "retry")
|
|
171676
172252
|
continue;
|
|
171677
172253
|
if (loaded === "failed") {
|
|
@@ -171686,6 +172262,7 @@ class ServedCopyServe {
|
|
|
171686
172262
|
};
|
|
171687
172263
|
}
|
|
171688
172264
|
const { materializer, servedDef, servedRuntime, leftOut, files } = loaded;
|
|
172265
|
+
const compiledConfig = loaded.config ?? config;
|
|
171689
172266
|
problems.push(...state.inlinedKept.filter((p) => state.candidates.some((c) => c.reroot.sourceName === p.sourceName)));
|
|
171690
172267
|
state.inlinedKept = [];
|
|
171691
172268
|
problems.push(...state.pairsDropped);
|
|
@@ -171705,7 +172282,7 @@ class ServedCopyServe {
|
|
|
171705
172282
|
materializer,
|
|
171706
172283
|
leftOut,
|
|
171707
172284
|
files,
|
|
171708
|
-
config,
|
|
172285
|
+
config: compiledConfig,
|
|
171709
172286
|
rerooted,
|
|
171710
172287
|
aliased,
|
|
171711
172288
|
throughBase
|
|
@@ -171721,6 +172298,12 @@ class ServedCopyServe {
|
|
|
171721
172298
|
problems
|
|
171722
172299
|
};
|
|
171723
172300
|
}
|
|
172301
|
+
underAliasLoader(packagePath, packageConfig, destinations, rerooted) {
|
|
172302
|
+
return (names) => {
|
|
172303
|
+
const config = servedCopyConfig(packageConfig, destinations(), new Set(rerooted.filter((b) => !isDatabase(b)).map((b) => b.destinationName)), names);
|
|
172304
|
+
return { config, load: this.passLoader(packagePath, config) };
|
|
172305
|
+
};
|
|
172306
|
+
}
|
|
171724
172307
|
passLoader(packagePath, config) {
|
|
171725
172308
|
const modelPath = this.host.modelPath();
|
|
171726
172309
|
const compiler = packageFiles(packagePath, modelPath, config);
|
|
@@ -171778,7 +172361,7 @@ class ServedCopyServe {
|
|
|
171778
172361
|
}
|
|
171779
172362
|
byKey.set(key, { error, until: asOf + REROOT_FAILURE_TTL_MS });
|
|
171780
172363
|
}
|
|
171781
|
-
async loadCopy(state, copy, overlay, load, lift) {
|
|
172364
|
+
async loadCopy(state, copy, overlay, load, lift, config, underAlias) {
|
|
171782
172365
|
const { withoutKept, problems } = state;
|
|
171783
172366
|
let materializer;
|
|
171784
172367
|
let servedDef;
|
|
@@ -171811,6 +172394,9 @@ class ServedCopyServe {
|
|
|
171811
172394
|
return "retry";
|
|
171812
172395
|
}
|
|
171813
172396
|
const byURL = new Map([...copy.files].map(([url, text]) => [url, text]));
|
|
172397
|
+
const merged = await this.readSameCatalogThroughDestination(state, err, byURL, lift, config, underAlias);
|
|
172398
|
+
if (merged)
|
|
172399
|
+
return merged;
|
|
171814
172400
|
const kept = await leaveOutCrossConnectionJoins({
|
|
171815
172401
|
firstError: err,
|
|
171816
172402
|
overlay: byURL,
|
|
@@ -171876,6 +172462,44 @@ class ServedCopyServe {
|
|
|
171876
172462
|
}
|
|
171877
172463
|
return { materializer, servedDef, servedRuntime, leftOut, files };
|
|
171878
172464
|
}
|
|
172465
|
+
async readSameCatalogThroughDestination(state, err, files, lift, config, underAlias) {
|
|
172466
|
+
const moved = await readSameCatalogThroughDestination({
|
|
172467
|
+
error: err,
|
|
172468
|
+
files,
|
|
172469
|
+
readText: (u) => lift.fileText(u),
|
|
172470
|
+
modelDef: this.host.modelDef(),
|
|
172471
|
+
rerooted: new Set(state.candidates.map((c) => c.reroot.sourceID)),
|
|
172472
|
+
ports: {
|
|
172473
|
+
scope: (connection, alias) => sameCatalogScope(config, connection, alias),
|
|
172474
|
+
pathRefusal: (path, connection, schemas) => this.host.managedTablePathRefusal ? this.host.managedTablePathRefusal(path, connection, schemas) : Promise.resolve("no managed scope check is available"),
|
|
172475
|
+
baseTables: (alias, tables) => allBaseTables(config, alias, tables)
|
|
172476
|
+
}
|
|
172477
|
+
}).catch(() => ({ declined: "a read of its connections failed" }));
|
|
172478
|
+
if ("declined" in moved) {
|
|
172479
|
+
logger.debug("A served copy's join across one catalog is not read through the destination; its joins are left out", { modelPath: this.host.modelPath(), why: moved.declined });
|
|
172480
|
+
return;
|
|
172481
|
+
}
|
|
172482
|
+
const keyed = keyedOverlay(moved.files);
|
|
172483
|
+
const { config: aliased, load } = underAlias(moved.destinations);
|
|
172484
|
+
try {
|
|
172485
|
+
const loaded = await load(keyed);
|
|
172486
|
+
logger.debug("A served copy reads a joined source on its destination's catalog through the destination", { modelPath: this.host.modelPath() });
|
|
172487
|
+
return {
|
|
172488
|
+
materializer: loaded.materializer,
|
|
172489
|
+
servedDef: loaded.def,
|
|
172490
|
+
servedRuntime: loaded.runtime,
|
|
172491
|
+
leftOut: [],
|
|
172492
|
+
files: keyed,
|
|
172493
|
+
config: aliased
|
|
172494
|
+
};
|
|
172495
|
+
} catch (again) {
|
|
172496
|
+
logger.debug("A served copy's same-catalog read does not compile; its joins are left out", {
|
|
172497
|
+
modelPath: this.host.modelPath(),
|
|
172498
|
+
codes: errorProblems(again)?.map((p) => p.code)
|
|
172499
|
+
});
|
|
172500
|
+
return;
|
|
172501
|
+
}
|
|
172502
|
+
}
|
|
171879
172503
|
contain(state, copy, error, files, mode, remembered = false) {
|
|
171880
172504
|
const { withoutKept, problems } = state;
|
|
171881
172505
|
const failing = new Map(failingReroots(error, files, copy.spans, mode).map((f) => [
|
|
@@ -171941,7 +172565,9 @@ class ServedCopyServe {
|
|
|
171941
172565
|
if (!l.crossConnection)
|
|
171942
172566
|
continue;
|
|
171943
172567
|
const sourceName = l.declaration ?? l.name;
|
|
172568
|
+
const sourceID = l.join === undefined ? candidates.find((c) => c.reroot.sourceName === sourceName && c.reroot.url === l.url)?.reroot.sourceID : undefined;
|
|
171944
172569
|
problems.push({
|
|
172570
|
+
...sourceID !== undefined ? { storedSourceID: sourceID } : {},
|
|
171945
172571
|
sourceName,
|
|
171946
172572
|
reason: "cross_connection_join",
|
|
171947
172573
|
join: l.join ?? l.name,
|
|
@@ -173136,7 +173762,7 @@ function zonedTruncations(columns, def, fieldsByName, chainZone, restatesStageZo
|
|
|
173136
173762
|
restated: []
|
|
173137
173763
|
};
|
|
173138
173764
|
}
|
|
173139
|
-
var NOTHING_PINNED, NO_DESTINATIONS = () => new MalloyConfig4({ connections: {} }), PAIR_BLOCKS_DETAIL = "The table stores more than one inlined join_many, one block of rows each, and the query reads more than one of them (live aggregates each by its own key over their cross product, which no block holds), so it is answered without this table.",
|
|
173765
|
+
var NOTHING_PINNED, NO_DESTINATIONS = () => new MalloyConfig4({ connections: {} }), PAIR_BLOCKS_DETAIL = "The table stores more than one inlined join_many, one block of rows each, and the query reads more than one of them (live aggregates each by its own key over their cross product, which no block holds), so it is answered without this table.", MISSING_FIELD_CODES, SERVED_COPY_WARNING_CODE = "served-copy-not-served", DECLINED_LIMIT = 1000, knownRerootFailures, REROOT_FAILURE_TTL_MS, ESCAPED_FAILURE_RETRY_MS = 30000, REROOT_FAILURES_PER_CONFIG = 64, GATE_GRAFT_DECLINE, HIDDEN_COLUMN = "a hidden column", JOIN_DEPTH_LIMIT = 8;
|
|
173140
173766
|
var init_served_copy_serve = __esm(() => {
|
|
173141
173767
|
init_ducklake_catalog_unavailable();
|
|
173142
173768
|
init_served_copy_lanes();
|
|
@@ -173172,6 +173798,8 @@ var init_served_copy_serve = __esm(() => {
|
|
|
173172
173798
|
init_utils();
|
|
173173
173799
|
init_served_copy_checks();
|
|
173174
173800
|
init_query_walks();
|
|
173801
|
+
init_same_catalog_reads();
|
|
173802
|
+
init_same_catalog_destination();
|
|
173175
173803
|
init_chain_string_reads();
|
|
173176
173804
|
NOTHING_PINNED = pin(EMPTY_SNAPSHOT, new Date(0));
|
|
173177
173805
|
MISSING_FIELD_CODES = new Set([
|
|
@@ -180392,7 +181020,7 @@ function storageWarnings(plan, mode, databaseFresh = () => false) {
|
|
|
180392
181020
|
}
|
|
180393
181021
|
return warnings;
|
|
180394
181022
|
}
|
|
180395
|
-
function servedCopyWarnings(models, takesInline) {
|
|
181023
|
+
function servedCopyWarnings(models, takesInline, writesStorage) {
|
|
180396
181024
|
const warnings = [];
|
|
180397
181025
|
for (const [modelPath, model] of models) {
|
|
180398
181026
|
const problems = model.servedCopyProblems() ?? [];
|
|
@@ -180405,7 +181033,7 @@ function servedCopyWarnings(models, takesInline) {
|
|
|
180405
181033
|
code: SERVED_COPY_WARNING_CODE,
|
|
180406
181034
|
reason: p.reason,
|
|
180407
181035
|
severity: "warn",
|
|
180408
|
-
message: servedCopyProblemMessage(p, keptInline.has(`${p.sourceName}\x00${p.join}`), p.sourceID === undefined || !takesInline ? true : takesInline(p.sourceID))
|
|
181036
|
+
message: servedCopyProblemMessage(p, keptInline.has(`${p.sourceName}\x00${p.join}`), p.sourceID === undefined || !takesInline ? true : takesInline(p.sourceID), writesStorage ? writesStorage(p, modelPath) : true)
|
|
180409
181037
|
});
|
|
180410
181038
|
for (const message of p.coverage ?? []) {
|
|
180411
181039
|
warnings.push({
|
|
@@ -180564,11 +181192,11 @@ function fellBackMessage(message) {
|
|
|
180564
181192
|
const head = message.slice(0, at);
|
|
180565
181193
|
return head.endsWith(". ") || head === "" ? `${head}${instead[0].toUpperCase()}${instead.slice(1)}` : `${head}${instead}`;
|
|
180566
181194
|
}
|
|
180567
|
-
function servedCopyProblemMessage(problem, inlinedButKept = false, takesInline = true) {
|
|
180568
|
-
const message = servedCopyProblemReasonMessage(problem, inlinedButKept, takesInline);
|
|
181195
|
+
function servedCopyProblemMessage(problem, inlinedButKept = false, takesInline = true, writesStorage = true) {
|
|
181196
|
+
const message = servedCopyProblemReasonMessage(problem, inlinedButKept, takesInline, writesStorage);
|
|
180569
181197
|
return problem.servedFromDatabase ? fellBackMessage(message) : message;
|
|
180570
181198
|
}
|
|
180571
|
-
function servedCopyProblemReasonMessage(problem, inlinedButKept = false, takesInline = true) {
|
|
181199
|
+
function servedCopyProblemReasonMessage(problem, inlinedButKept = false, takesInline = true, writesStorage = true) {
|
|
180572
181200
|
const { reason, join } = problem;
|
|
180573
181201
|
switch (reason) {
|
|
180574
181202
|
case "compile_failed":
|
|
@@ -180594,14 +181222,17 @@ function servedCopyProblemReasonMessage(problem, inlinedButKept = false, takesIn
|
|
|
180594
181222
|
return "This source filters by a given in a place its stored table cannot keep, or is filtered and reached here only through a join, so the served copy leaves it as written rather than answer every caller alike.";
|
|
180595
181223
|
case "fields_not_carried":
|
|
180596
181224
|
return "This source inherits fields (a measure, view or join declared on the source it is built from) that its stored table does not carry, so the served copy leaves it as written.";
|
|
180597
|
-
case "cross_connection_join":
|
|
181225
|
+
case "cross_connection_join": {
|
|
181226
|
+
const orOwnDatabase = (what, drop) => writesStorage ? `, or build ${what} in its own database (drop ${drop})` : "";
|
|
180598
181227
|
if (problem.leftOutWhole) {
|
|
180599
|
-
return `This source's join${join ? ` \`${join}\`` : ""} reads a source the served copy moves to its ` + "storage destination, so the join crosses connections there, and it cannot be left out alone " + "(what reads it cannot be left out with it). The served copy leaves this source out, so its " + "queries are answered live, and the model's other stored sources still serve. To serve it, " + "store this source in the same destination
|
|
181228
|
+
return `This source's join${join ? ` \`${join}\`` : ""} reads a source the served copy moves to its ` + "storage destination, so the join crosses connections there, and it cannot be left out alone " + "(what reads it cannot be left out with it). The served copy leaves this source out, so its " + "queries are answered live, and the model's other stored sources still serve. To serve it, " + "store this source in the same destination" + orOwnDatabase("the joined source", "`storage=`") + ".";
|
|
180600
181229
|
}
|
|
180601
181230
|
if (problem.declarerNotStored) {
|
|
180602
|
-
return `This source's join${join ? ` \`${join}\`` : ""} reads a source the served copy reads from its ` + "storage destination, which this source's own connection cannot reach. Queries that use the " + "join are answered live; the others are answered as before. To serve them too, store this " + "source in the same destination
|
|
181231
|
+
return `This source's join${join ? ` \`${join}\`` : ""} reads a source the served copy reads from its ` + "storage destination, which this source's own connection cannot reach. Queries that use the " + "join are answered live; the others are answered as before. To serve them too, store this " + "source in the same destination" + orOwnDatabase("the joined source", "its `storage=`") + ".";
|
|
180603
181232
|
}
|
|
180604
|
-
|
|
181233
|
+
const ownDatabase = orOwnDatabase("this source", "`storage=`");
|
|
181234
|
+
return `This source is stored in a destination its join${join ? ` \`${join}\`` : ""} cannot reach: ` + "the joined source reads another connection. Queries that use the join are answered live; " + "the others read the stored table. To serve them too, " + (inlinedButKept ? "fix what keeps the inlined join from being answered from its stored columns (the warning on " + "this join says what), " + (ownDatabase ? `materialize the joined source into the same destination${ownDatabase}.` : "or materialize the joined source into the same destination.") : takesInline ? "inline the join (inline=)" + (ownDatabase ? `, materialize the joined source into the same destination${ownDatabase}.` : " or materialize the joined source into the same destination.") : `materialize the joined source into the same destination${ownDatabase}.`);
|
|
181235
|
+
}
|
|
180605
181236
|
case "inline_join_kept":
|
|
180606
181237
|
return `This source inlines its join${join ? ` \`${join}\`` : ""} (inline=), but its served copy does not compile ` + "with the join answered from the stored columns, so the join is kept as written and every query " + "through it reads the joined source through the join" + compilerReasons(problem.detail) + " A definition that reads the joined source past one hop (a join of the joined source), or reads " + "one of its measures or views, is the usual cause.";
|
|
180607
181238
|
case "classification_not_kept":
|
|
@@ -184823,7 +185454,11 @@ class PackageMaterialization {
|
|
|
184823
185454
|
}
|
|
184824
185455
|
servedCopyWarnings() {
|
|
184825
185456
|
const materialized = this.plan.materializePlans;
|
|
184826
|
-
|
|
185457
|
+
const buildPlan = this.plan.buildPlan;
|
|
185458
|
+
const planned = buildPlan?.sources ?? {};
|
|
185459
|
+
const writes = (sourceID) => Object.hasOwn(materialized, sourceID) ? materialized[sourceID].persist.storage !== undefined : Object.hasOwn(planned, sourceID) ? planned[sourceID].annotationFields?.storage !== undefined : undefined;
|
|
185460
|
+
const anyWrites = () => !buildPlan || Object.values(materialized).some((m) => m.persist.storage !== undefined) || Object.values(planned).some((s) => (s.origin ?? "persist") === "persist" && s.annotationFields?.storage !== undefined);
|
|
185461
|
+
return servedCopyWarnings(this.owner.models(), (sourceID) => Object.hasOwn(materialized, sourceID), (problem) => (problem.storedSourceID !== undefined ? writes(problem.storedSourceID) : undefined) ?? anyWrites());
|
|
184827
185462
|
}
|
|
184828
185463
|
storedColumnTypeWarnings() {
|
|
184829
185464
|
return storedColumnTypeWarnings(this.owner.models(), this.boundTypeFindings);
|
|
@@ -186374,7 +187009,7 @@ function classifyBuildError(err) {
|
|
|
186374
187009
|
return true;
|
|
186375
187010
|
if (isUpstreamMissingError(err))
|
|
186376
187011
|
return;
|
|
186377
|
-
if (err instanceof MaterializationEligibilityError || err instanceof InlinedJoinNotUniqueError || err instanceof ChainedShapeNotCarriedError || err instanceof ModelCompilationError || err instanceof MalloyError6 || err instanceof BadRequestError || err instanceof ConnectionAuthError || err instanceof UnconfiguredConnectionError || err instanceof DestinationNotFoundError) {
|
|
187012
|
+
if (err instanceof MaterializationEligibilityError || err instanceof InlinedJoinNotUniqueError || err instanceof ChainedShapeNotCarriedError || err instanceof ModelCompilationError || err instanceof MalloyError6 || err instanceof BadRequestError || err instanceof ConnectionAuthError || err instanceof UnconfiguredConnectionError || err instanceof DestinationNotFoundError || err instanceof ContainerNotFoundError) {
|
|
186378
187013
|
return false;
|
|
186379
187014
|
}
|
|
186380
187015
|
if (err instanceof ConnectionError)
|
|
@@ -187716,7 +188351,174 @@ var init_build_table_names = __esm(() => {
|
|
|
187716
188351
|
init_run_plan();
|
|
187717
188352
|
});
|
|
187718
188353
|
|
|
188354
|
+
// src/service/materialization/run/target_container_read.ts
|
|
188355
|
+
async function readTargetContainers(args) {
|
|
188356
|
+
const out = {};
|
|
188357
|
+
const distinct = new Map(args.containers.map((c) => [targetContainerKey(c), c]));
|
|
188358
|
+
const tasks = [...distinct].map(([key, target]) => async () => {
|
|
188359
|
+
out[key] = await readTargetContainerOrUnread(() => args.connection(target.connectionName), target, { timeoutMs: args.timeoutMs });
|
|
188360
|
+
});
|
|
188361
|
+
await runBounded2(tasks, CONTAINER_READ_CONCURRENCY);
|
|
188362
|
+
return out;
|
|
188363
|
+
}
|
|
188364
|
+
async function readTargetContainerOrUnread(connection, target, options = {}) {
|
|
188365
|
+
try {
|
|
188366
|
+
return await withTimeout2((async () => readTargetContainer(await connection(), target.container, options.runOptions))(), options.timeoutMs ?? CONTAINER_READ_TIMEOUT_MS);
|
|
188367
|
+
} catch (err) {
|
|
188368
|
+
logger.warn("A table's container could not be read; nothing is refused or stopped for it", { connectionName: target.connectionName, code: errorCodeOf(err) });
|
|
188369
|
+
return { unread: true };
|
|
188370
|
+
}
|
|
188371
|
+
}
|
|
188372
|
+
async function readTargetContainer(connection, container, runOptions) {
|
|
188373
|
+
const parts = container.split(".").map(unquoted2);
|
|
188374
|
+
if (parts.some((p) => p === ""))
|
|
188375
|
+
return { unread: true };
|
|
188376
|
+
switch (capabilitiesOf(connection.dialectName).containerCatalog) {
|
|
188377
|
+
case "dataset":
|
|
188378
|
+
return readBigQueryDataset(connection, container);
|
|
188379
|
+
case "pg_namespace": {
|
|
188380
|
+
if (parts.length > 2)
|
|
188381
|
+
return { unread: true };
|
|
188382
|
+
const [database, schema] = parts.length === 2 ? parts : [undefined, parts[0]];
|
|
188383
|
+
const row = await countRow(connection, `SELECT row_to_json(p) AS "row" FROM (SELECT current_database() AS db, (SELECT COUNT(*) FROM pg_catalog.pg_namespace WHERE nspname = ${literal(schema)}) AS n) AS p`, runOptions);
|
|
188384
|
+
if (row === undefined || database !== undefined && String(row.db) !== database) {
|
|
188385
|
+
return { unread: true };
|
|
188386
|
+
}
|
|
188387
|
+
return answer(row);
|
|
188388
|
+
}
|
|
188389
|
+
case "schemata": {
|
|
188390
|
+
if (parts.length > 2)
|
|
188391
|
+
return { unread: true };
|
|
188392
|
+
const [database, schema] = parts.length === 2 ? parts : [undefined, parts[0]];
|
|
188393
|
+
const catalog = database === undefined ? "information_schema" : `"${database.replace(/"/g, '""')}".information_schema`;
|
|
188394
|
+
return answer(await countRow(connection, `SELECT COUNT(*) AS n FROM ${catalog}.schemata WHERE schema_name = ${literal(schema)}`, runOptions));
|
|
188395
|
+
}
|
|
188396
|
+
case "duckdb_schemas": {
|
|
188397
|
+
if (parts.length > 2)
|
|
188398
|
+
return { unread: true };
|
|
188399
|
+
const where = parts.length === 2 ? `lower(database_name) = lower(${literal(parts[0])}) AND lower(schema_name) = lower(${literal(parts[1])})` : `(database_name = current_database() AND lower(schema_name) = lower(${literal(parts[0])})) OR lower(database_name) = lower(${literal(parts[0])})`;
|
|
188400
|
+
const sql = `SELECT COUNT(*) AS n FROM duckdb_schemas() WHERE ${where}`;
|
|
188401
|
+
return answer(await runAsInternalStatement(sql, () => countRow(connection, sql, runOptions)));
|
|
188402
|
+
}
|
|
188403
|
+
default:
|
|
188404
|
+
return { unread: true };
|
|
188405
|
+
}
|
|
188406
|
+
}
|
|
188407
|
+
function billingProject(internals) {
|
|
188408
|
+
for (const p of [
|
|
188409
|
+
internals.billingProjectId,
|
|
188410
|
+
internals.bigQuery?.projectId
|
|
188411
|
+
]) {
|
|
188412
|
+
if (typeof p === "string" && p !== "" && !p.includes("{{"))
|
|
188413
|
+
return p;
|
|
188414
|
+
}
|
|
188415
|
+
return;
|
|
188416
|
+
}
|
|
188417
|
+
async function readBigQueryDataset(connection, container) {
|
|
188418
|
+
const internals = connection;
|
|
188419
|
+
const client = internals.bigQuery;
|
|
188420
|
+
if (!client || typeof client.dataset !== "function") {
|
|
188421
|
+
return { unread: true };
|
|
188422
|
+
}
|
|
188423
|
+
const lastDot = container.lastIndexOf(".");
|
|
188424
|
+
const dataset = unquoted2(container.slice(lastDot + 1));
|
|
188425
|
+
const named = lastDot > 0 ? unquoted2(container.slice(0, lastDot)) : "";
|
|
188426
|
+
const project = named !== "" ? named : billingProject(internals);
|
|
188427
|
+
let metadata;
|
|
188428
|
+
try {
|
|
188429
|
+
[metadata] = await client.dataset(dataset, project !== undefined ? { projectId: project } : {}).getMetadata();
|
|
188430
|
+
} catch (err) {
|
|
188431
|
+
if (isNotFound(err)) {
|
|
188432
|
+
const read = project ?? billingProject(internals);
|
|
188433
|
+
return {
|
|
188434
|
+
notFound: true,
|
|
188435
|
+
...named === "" && read !== undefined ? { project: read } : {}
|
|
188436
|
+
};
|
|
188437
|
+
}
|
|
188438
|
+
throw err;
|
|
188439
|
+
}
|
|
188440
|
+
const expected = typeof internals.location === "string" ? internals.location : "";
|
|
188441
|
+
const location = typeof metadata?.location === "string" ? metadata.location : "";
|
|
188442
|
+
if (expected !== "" && location !== "" && expected.toLowerCase() !== location.toLowerCase()) {
|
|
188443
|
+
return { otherLocation: { location, expected } };
|
|
188444
|
+
}
|
|
188445
|
+
return { found: true };
|
|
188446
|
+
}
|
|
188447
|
+
function isNotFound(err) {
|
|
188448
|
+
const e = err;
|
|
188449
|
+
if (e?.code === 404)
|
|
188450
|
+
return true;
|
|
188451
|
+
return Array.isArray(e?.errors) && e.errors.some((x) => x?.reason === "notFound");
|
|
188452
|
+
}
|
|
188453
|
+
async function countRow(connection, sql, runOptions) {
|
|
188454
|
+
const result = await connection.runSQL(sql, {
|
|
188455
|
+
...runOptions,
|
|
188456
|
+
rowLimit: 1
|
|
188457
|
+
});
|
|
188458
|
+
const row = (result.rows ?? [])[0];
|
|
188459
|
+
if (row === undefined)
|
|
188460
|
+
return;
|
|
188461
|
+
return Object.fromEntries(Object.entries(row).map(([k, v]) => [k.toLowerCase(), v]));
|
|
188462
|
+
}
|
|
188463
|
+
function answer(row) {
|
|
188464
|
+
const n = row === undefined ? NaN : Number(row.n);
|
|
188465
|
+
if (!Number.isFinite(n))
|
|
188466
|
+
return { unread: true };
|
|
188467
|
+
return n > 0 ? { found: true } : { notFound: true };
|
|
188468
|
+
}
|
|
188469
|
+
function literal(value) {
|
|
188470
|
+
return `'${value.replace(/'/g, "''")}'`;
|
|
188471
|
+
}
|
|
188472
|
+
function unquoted2(segment) {
|
|
188473
|
+
const s = segment.trim();
|
|
188474
|
+
return /^(`.*`|".*")$/.test(s) ? s.slice(1, -1) : s;
|
|
188475
|
+
}
|
|
188476
|
+
function withTimeout2(promise, ms) {
|
|
188477
|
+
let timer;
|
|
188478
|
+
return Promise.race([
|
|
188479
|
+
promise,
|
|
188480
|
+
new Promise((_, reject) => {
|
|
188481
|
+
timer = setTimeout(() => reject(new ContainerReadTimeout(ms)), ms);
|
|
188482
|
+
})
|
|
188483
|
+
]).finally(() => clearTimeout(timer));
|
|
188484
|
+
}
|
|
188485
|
+
async function runBounded2(tasks, limit) {
|
|
188486
|
+
let next = 0;
|
|
188487
|
+
const worker = async () => {
|
|
188488
|
+
while (next < tasks.length) {
|
|
188489
|
+
const task = tasks[next++];
|
|
188490
|
+
await task();
|
|
188491
|
+
}
|
|
188492
|
+
};
|
|
188493
|
+
await Promise.all(Array.from({ length: Math.min(limit, tasks.length) }, worker));
|
|
188494
|
+
}
|
|
188495
|
+
var CONTAINER_READ_TIMEOUT_MS = 15000, CONTAINER_READ_CONCURRENCY = 4, ContainerReadTimeout;
|
|
188496
|
+
var init_target_container_read = __esm(() => {
|
|
188497
|
+
init_error_code();
|
|
188498
|
+
init_logger();
|
|
188499
|
+
init_duckdb_lockdown();
|
|
188500
|
+
init_dialect();
|
|
188501
|
+
init_target_containers();
|
|
188502
|
+
ContainerReadTimeout = class ContainerReadTimeout extends Error {
|
|
188503
|
+
constructor(ms) {
|
|
188504
|
+
super(`the container read timed out after ${ms}ms`);
|
|
188505
|
+
this.name = "ContainerReadTimeout";
|
|
188506
|
+
}
|
|
188507
|
+
};
|
|
188508
|
+
});
|
|
188509
|
+
|
|
187719
188510
|
// src/service/materialization/run/database_build_strategy.ts
|
|
188511
|
+
async function assertContainerExists(args) {
|
|
188512
|
+
const container = containerOfTableName(args.physicalTableName);
|
|
188513
|
+
if (container === undefined)
|
|
188514
|
+
return;
|
|
188515
|
+
const target = { connectionName: args.connectionName, container };
|
|
188516
|
+
const reading = await readTargetContainerOrUnread(async () => args.connection, target, { runOptions: args.runOptions });
|
|
188517
|
+
if ("notFound" in reading || "otherLocation" in reading) {
|
|
188518
|
+
throw new ContainerNotFoundError(`Source '${args.sourceName}' cannot be built: ` + `${missingContainerReason(target, args.connection.dialectName, reading)}.`);
|
|
188519
|
+
}
|
|
188520
|
+
}
|
|
188521
|
+
|
|
187720
188522
|
class DatabaseTier {
|
|
187721
188523
|
tier = "database";
|
|
187722
188524
|
async build(request) {
|
|
@@ -187761,6 +188563,13 @@ class DatabaseTier {
|
|
|
187761
188563
|
if (incrementalRefresh) {
|
|
187762
188564
|
await resetLedger(incrementalRefresh.context, incrementalRefresh.lineage);
|
|
187763
188565
|
}
|
|
188566
|
+
await assertContainerExists({
|
|
188567
|
+
connection,
|
|
188568
|
+
physicalTableName,
|
|
188569
|
+
connectionName: persistSource.connectionName,
|
|
188570
|
+
sourceName: persistSource.name,
|
|
188571
|
+
runOptions
|
|
188572
|
+
});
|
|
187764
188573
|
const startTime = performance.now();
|
|
187765
188574
|
await connection.runSQL(`DROP TABLE IF EXISTS ${quotedStaging}`, runOptions);
|
|
187766
188575
|
let buildCostBytes;
|
|
@@ -188059,6 +188868,9 @@ var init_database_build_strategy = __esm(() => {
|
|
|
188059
188868
|
init_build_table_names();
|
|
188060
188869
|
init_warehouse_sql();
|
|
188061
188870
|
init_duckdb_lockdown();
|
|
188871
|
+
init_errors2();
|
|
188872
|
+
init_target_containers();
|
|
188873
|
+
init_target_container_read();
|
|
188062
188874
|
});
|
|
188063
188875
|
|
|
188064
188876
|
// src/service/materialization/run/storage_admin.ts
|
|
@@ -191746,7 +192558,7 @@ function renderBuildSQL(persistSource, instruction, manifest, builtEntries, plan
|
|
|
191746
192558
|
const { lift, reached, reachedIds } = reach;
|
|
191747
192559
|
const reducedManifest = withoutEntries(manifestExcludingStorage(manifest, builtEntries, planFacts), moved);
|
|
191748
192560
|
const buildManifest = manifestForCompiler(isStorageBuild ? { ...reducedManifest, strict: false } : reducedManifest, planFacts, reachedIds);
|
|
191749
|
-
const wrongTier = Object.entries(builtEntries).filter(([address, entry]) =>
|
|
192561
|
+
const wrongTier = Object.entries(builtEntries).filter(([address, entry]) => suppliedAtWrongTier(address, entry, manifest, planFacts));
|
|
191750
192562
|
const staleMisses = (err) => {
|
|
191751
192563
|
const message = err instanceof Error ? err.message : String(err);
|
|
191752
192564
|
return wrongTier.flatMap(([address, entry]) => {
|
|
@@ -192030,7 +192842,8 @@ async function buildSource(options, storage) {
|
|
|
192030
192842
|
liveCollations: liveCollationsOf(connection, buildSQL, environment.bigqueryBuildCompareBinary ? () => environment.bigqueryBuildCompareBinary({
|
|
192031
192843
|
connection,
|
|
192032
192844
|
source: persistSource,
|
|
192033
|
-
sql: buildSQL
|
|
192845
|
+
sql: buildSQL,
|
|
192846
|
+
onUnread: (unread) => logBigQueryBuildUnread(persistSource, unread)
|
|
192034
192847
|
}) : undefined)
|
|
192035
192848
|
});
|
|
192036
192849
|
return withExtensionReuse(built, planFacts, persistSource.sourceID);
|
|
@@ -192109,6 +192922,21 @@ function reportingDrift(environment, render) {
|
|
|
192109
192922
|
throw err;
|
|
192110
192923
|
}
|
|
192111
192924
|
}
|
|
192925
|
+
function suppliedAtWrongTier(address, entry, manifest, planFacts) {
|
|
192926
|
+
return !isLegacyFailedEntry(entry) && !entry.storageDestinationName && address in manifest.buildManifest.entries && !upstreamEntryIsCurrent(address, entry, planFacts);
|
|
192927
|
+
}
|
|
192928
|
+
function logBigQueryBuildUnread(source, unread) {
|
|
192929
|
+
logger.warn("BigQuery catalog read did not prove a storage= build's strings byte-exact; its column contract records them compared none, which refuses a storage= table built over it that compares them", {
|
|
192930
|
+
sourceName: source.name,
|
|
192931
|
+
connectionName: source.connectionName,
|
|
192932
|
+
reason: unread.reason,
|
|
192933
|
+
...unread.project !== undefined ? { project: unread.project } : {},
|
|
192934
|
+
location: unread.location ?? "per-dataset",
|
|
192935
|
+
...unread.dataset !== undefined ? { dataset: unread.dataset } : {},
|
|
192936
|
+
...unread.table !== undefined ? { table: unread.table } : {},
|
|
192937
|
+
...unread.tableType !== undefined ? { tableType: unread.tableType } : {}
|
|
192938
|
+
});
|
|
192939
|
+
}
|
|
192112
192940
|
var DATABASE2;
|
|
192113
192941
|
var init_source_build = __esm(() => {
|
|
192114
192942
|
init_error_code();
|
|
@@ -192120,6 +192948,7 @@ var init_source_build = __esm(() => {
|
|
|
192120
192948
|
init_run_plan();
|
|
192121
192949
|
init_author_model();
|
|
192122
192950
|
init_source_map();
|
|
192951
|
+
init_types3();
|
|
192123
192952
|
init_column_contract();
|
|
192124
192953
|
init_table_plans();
|
|
192125
192954
|
init_database_build_strategy();
|
|
@@ -195558,70 +196387,143 @@ var init_upstream_schema_read = __esm(() => {
|
|
|
195558
196387
|
|
|
195559
196388
|
// src/service/materialization/serve/collation/bigquery_build.ts
|
|
195560
196389
|
async function bigqueryBuildCompareBinary(args) {
|
|
196390
|
+
const io = catalogIO(args.connection);
|
|
196391
|
+
let read;
|
|
195561
196392
|
try {
|
|
195562
|
-
|
|
196393
|
+
read = await bigqueryCollatedPaths({
|
|
195563
196394
|
reads: new Map,
|
|
195564
|
-
io
|
|
196395
|
+
io,
|
|
195565
196396
|
connectionName: args.source.connectionName,
|
|
195566
196397
|
sql: args.sql,
|
|
195567
|
-
tables: sourceReads(args.source)
|
|
196398
|
+
tables: sourceReads(args.source),
|
|
196399
|
+
datasetReadLimit: args.datasetReadLimit ?? MAX_BUILD_DATASET_READS
|
|
195568
196400
|
});
|
|
195569
|
-
return read.known && read.collated.size === 0;
|
|
195570
196401
|
} catch {
|
|
196402
|
+
read = { known: false, unread: { reason: "read_failed" } };
|
|
196403
|
+
}
|
|
196404
|
+
if (!read.known) {
|
|
196405
|
+
args.onUnread?.(withJob(read.unread, io));
|
|
195571
196406
|
return false;
|
|
195572
196407
|
}
|
|
196408
|
+
return read.collated.size === 0;
|
|
196409
|
+
}
|
|
196410
|
+
function withJob(unread, io) {
|
|
196411
|
+
let job = {
|
|
196412
|
+
projects: [],
|
|
196413
|
+
location: undefined
|
|
196414
|
+
};
|
|
196415
|
+
try {
|
|
196416
|
+
job = io.jobContext();
|
|
196417
|
+
} catch {}
|
|
196418
|
+
const project = unread.project ?? job.projects[0];
|
|
196419
|
+
return {
|
|
196420
|
+
...unread,
|
|
196421
|
+
...project !== undefined ? { project } : {},
|
|
196422
|
+
...job.location !== undefined ? { location: job.location } : {}
|
|
196423
|
+
};
|
|
195573
196424
|
}
|
|
195574
196425
|
async function bigqueryCollatedPaths(args) {
|
|
195575
|
-
const unknown = { known: false };
|
|
196426
|
+
const unknown = (unread) => ({ known: false, unread });
|
|
195576
196427
|
const { sql, tables, connectionName } = args;
|
|
196428
|
+
let at = {};
|
|
195577
196429
|
try {
|
|
195578
196430
|
if (/\bcollate\b/i.test(sql))
|
|
195579
|
-
return unknown;
|
|
196431
|
+
return unknown({ reason: "collate_in_sql" });
|
|
195580
196432
|
const catalog = new BigQueryCatalog(args.reads, args.io, connectionName);
|
|
195581
196433
|
const { job } = catalog;
|
|
195582
|
-
if (job.projects.length === 0)
|
|
195583
|
-
return unknown;
|
|
196434
|
+
if (job.projects.length === 0) {
|
|
196435
|
+
return unknown({ reason: "no_job_project" });
|
|
196436
|
+
}
|
|
195584
196437
|
const placed = [];
|
|
195585
196438
|
for (const t of tables ?? []) {
|
|
195586
196439
|
if (connectionName !== undefined && t.connectionName !== connectionName) {
|
|
195587
|
-
return unknown;
|
|
196440
|
+
return unknown({ reason: "table_on_other_connection" });
|
|
195588
196441
|
}
|
|
195589
196442
|
const p = placeTable(t.table, job.projects);
|
|
195590
196443
|
if (p === undefined)
|
|
195591
|
-
return unknown;
|
|
196444
|
+
return unknown({ reason: "table_unplaceable" });
|
|
195592
196445
|
placed.push(p);
|
|
195593
196446
|
}
|
|
195594
|
-
const
|
|
196447
|
+
const unclean = async (projects, where = {}) => {
|
|
195595
196448
|
for (const project of projects) {
|
|
195596
196449
|
const d = await catalog.collatedDatasets(project);
|
|
195597
|
-
if (d === undefined
|
|
195598
|
-
return
|
|
196450
|
+
if (d === undefined) {
|
|
196451
|
+
return { reason: "project_unread", project, ...where };
|
|
196452
|
+
}
|
|
196453
|
+
if (d.size > 0) {
|
|
196454
|
+
return { reason: "project_collated", project, ...where };
|
|
196455
|
+
}
|
|
195599
196456
|
}
|
|
195600
|
-
return
|
|
196457
|
+
return;
|
|
195601
196458
|
};
|
|
195602
196459
|
if (tables === undefined) {
|
|
195603
196460
|
const projects = new Set([...job.projects, ...sqlProjects(sql)]);
|
|
195604
|
-
|
|
196461
|
+
const why = await unclean(projects);
|
|
196462
|
+
return why ? unknown(why) : { known: true, collated: new Map, catalog };
|
|
196463
|
+
}
|
|
196464
|
+
if (new Set(placed.map((t) => t.dataset)).size <= args.datasetReadLimit) {
|
|
196465
|
+
const collated = new Map;
|
|
196466
|
+
for (const t of placed) {
|
|
196467
|
+
const where = { dataset: t.datasetName, table: t.name };
|
|
196468
|
+
at = { project: t.projects[0], ...where };
|
|
196469
|
+
let listed;
|
|
196470
|
+
try {
|
|
196471
|
+
listed = await catalog.datasetTables(t.dataset);
|
|
196472
|
+
} catch {
|
|
196473
|
+
return unknown({ reason: "dataset_unread", ...at });
|
|
196474
|
+
}
|
|
196475
|
+
const datasetTable = listed.get(t.name);
|
|
196476
|
+
if (datasetTable === undefined) {
|
|
196477
|
+
return unknown({ reason: "dataset_table_not_listed", ...at });
|
|
196478
|
+
}
|
|
196479
|
+
if (!TABLE_TYPES.has(datasetTable.type)) {
|
|
196480
|
+
const why = await unclean(t.projects, {
|
|
196481
|
+
...where,
|
|
196482
|
+
tableType: datasetTable.type
|
|
196483
|
+
});
|
|
196484
|
+
if (why)
|
|
196485
|
+
return unknown(why);
|
|
196486
|
+
continue;
|
|
196487
|
+
}
|
|
196488
|
+
addCollated(collated, datasetTable.collated);
|
|
196489
|
+
}
|
|
196490
|
+
return { known: true, collated, catalog };
|
|
195605
196491
|
}
|
|
195606
196492
|
const types = await catalog.tableTypes(placed);
|
|
195607
|
-
if (types === undefined)
|
|
195608
|
-
return unknown
|
|
196493
|
+
if (types === undefined) {
|
|
196494
|
+
return unknown({
|
|
196495
|
+
reason: "table_types_unread",
|
|
196496
|
+
project: placed[0]?.projects[0]
|
|
196497
|
+
});
|
|
196498
|
+
}
|
|
195609
196499
|
const collated = new Map;
|
|
195610
196500
|
for (const t of placed) {
|
|
196501
|
+
const where = { dataset: t.datasetName, table: t.name };
|
|
196502
|
+
at = { project: t.projects[0], ...where };
|
|
195611
196503
|
if (types !== "no_region") {
|
|
195612
196504
|
const type = t.projects.map((p) => types.get(`${p}.${t.datasetName}.${t.name}`)).find((x) => x !== undefined);
|
|
195613
|
-
if (type === undefined)
|
|
195614
|
-
return unknown;
|
|
196505
|
+
if (type === undefined) {
|
|
196506
|
+
return unknown({ reason: "table_not_listed", ...at });
|
|
196507
|
+
}
|
|
195615
196508
|
if (!TABLE_TYPES.has(type)) {
|
|
195616
|
-
|
|
195617
|
-
|
|
196509
|
+
const why = await unclean(t.projects, {
|
|
196510
|
+
...where,
|
|
196511
|
+
tableType: type
|
|
196512
|
+
});
|
|
196513
|
+
if (why)
|
|
196514
|
+
return unknown(why);
|
|
195618
196515
|
continue;
|
|
195619
196516
|
}
|
|
195620
196517
|
let inCollated = false;
|
|
195621
196518
|
for (const p of t.projects) {
|
|
195622
196519
|
const d = await catalog.collatedDatasets(p);
|
|
195623
|
-
if (d === undefined)
|
|
195624
|
-
return unknown
|
|
196520
|
+
if (d === undefined) {
|
|
196521
|
+
return unknown({
|
|
196522
|
+
reason: "project_unread",
|
|
196523
|
+
...at,
|
|
196524
|
+
project: p
|
|
196525
|
+
});
|
|
196526
|
+
}
|
|
195625
196527
|
if (d.has(t.datasetName))
|
|
195626
196528
|
inCollated = true;
|
|
195627
196529
|
}
|
|
@@ -195630,22 +196532,30 @@ async function bigqueryCollatedPaths(args) {
|
|
|
195630
196532
|
}
|
|
195631
196533
|
const datasetTable = (await catalog.datasetTables(t.dataset)).get(t.name);
|
|
195632
196534
|
if (datasetTable === undefined || !TABLE_TYPES.has(datasetTable.type)) {
|
|
195633
|
-
return unknown
|
|
195634
|
-
|
|
195635
|
-
|
|
195636
|
-
|
|
195637
|
-
|
|
195638
|
-
set = new Set;
|
|
195639
|
-
collated.set(path, set);
|
|
195640
|
-
}
|
|
195641
|
-
set.add(c);
|
|
196535
|
+
return unknown({
|
|
196536
|
+
reason: "dataset_table_not_listed",
|
|
196537
|
+
...at,
|
|
196538
|
+
...datasetTable ? { tableType: datasetTable.type } : {}
|
|
196539
|
+
});
|
|
195642
196540
|
}
|
|
196541
|
+
addCollated(collated, datasetTable.collated);
|
|
195643
196542
|
}
|
|
195644
196543
|
return { known: true, collated, catalog };
|
|
195645
196544
|
} catch {
|
|
195646
|
-
return unknown;
|
|
196545
|
+
return unknown({ reason: "read_failed", ...at });
|
|
195647
196546
|
}
|
|
195648
196547
|
}
|
|
196548
|
+
function addCollated(collated, table) {
|
|
196549
|
+
for (const [path, c] of table) {
|
|
196550
|
+
let set = collated.get(path);
|
|
196551
|
+
if (!set) {
|
|
196552
|
+
set = new Set;
|
|
196553
|
+
collated.set(path, set);
|
|
196554
|
+
}
|
|
196555
|
+
set.add(c);
|
|
196556
|
+
}
|
|
196557
|
+
}
|
|
196558
|
+
var MAX_BUILD_DATASET_READS = 20;
|
|
195649
196559
|
var init_bigquery_build = __esm(() => {
|
|
195650
196560
|
init_source_reads();
|
|
195651
196561
|
init_catalog_io();
|
|
@@ -195663,6 +196573,7 @@ var init_materialization = __esm(() => {
|
|
|
195663
196573
|
init_manifest_loader();
|
|
195664
196574
|
init_materialization_scheduler();
|
|
195665
196575
|
init_upstream_schema_read();
|
|
196576
|
+
init_target_container_read();
|
|
195666
196577
|
init_served_copy_serve();
|
|
195667
196578
|
init_bigquery_build();
|
|
195668
196579
|
});
|
|
@@ -369074,6 +369985,7 @@ function getEntitiesFromExplore(explore, docString, relativePath, parentPath, so
|
|
|
369074
369985
|
nameOverride = `${joinPath}.${field.name}`;
|
|
369075
369986
|
}
|
|
369076
369987
|
const codeEntity = getEntityFromMalloyField(field, entitySource, docString, explore.sourceStructDef?.connection ?? null, explore.sourceStructDef && "tablePath" in explore.sourceStructDef ? explore.sourceStructDef.tablePath ?? null : null, joinMetadata, nameOverride, explore.sourceStructDef?.dialect ?? null);
|
|
369988
|
+
inheritJoinedDoc(codeEntity, field, explore);
|
|
369077
369989
|
const fingerprint = dimIndexFingerprints.get(makeDimIndexLookupKey(sourceName, field.name));
|
|
369078
369990
|
if (fingerprint) {
|
|
369079
369991
|
codeEntity.dim_index_fingerprint = {
|
|
@@ -369085,6 +369997,39 @@ function getEntitiesFromExplore(explore, docString, relativePath, parentPath, so
|
|
|
369085
369997
|
}
|
|
369086
369998
|
return entities;
|
|
369087
369999
|
}
|
|
370000
|
+
function inheritJoinedDoc(entity, field, explore) {
|
|
370001
|
+
if (entity.description !== undefined || field.isExploreField())
|
|
370002
|
+
return;
|
|
370003
|
+
const defs = explore.structDef.fields;
|
|
370004
|
+
const pathOf = (name) => {
|
|
370005
|
+
const e = defs?.find((f) => (f.as ?? f.name) === name)?.e;
|
|
370006
|
+
return e?.node === "field" && Array.isArray(e.path) && e.path.every((p) => typeof p === "string") ? e.path : undefined;
|
|
370007
|
+
};
|
|
370008
|
+
let path = pathOf(field.name);
|
|
370009
|
+
for (let depth = 0;path?.length === 1; depth++) {
|
|
370010
|
+
const link = explore.getFieldByNameIfExists(path[0]);
|
|
370011
|
+
if (depth >= MAX_ALIAS_CHAIN || !link || link.isExploreField() || getAccessModifier(link) !== "public" /* Public */ || getDescriptionFromTags(getTags(link)) !== undefined) {
|
|
370012
|
+
return;
|
|
370013
|
+
}
|
|
370014
|
+
path = pathOf(link.name);
|
|
370015
|
+
}
|
|
370016
|
+
if (path?.length !== 2)
|
|
370017
|
+
return;
|
|
370018
|
+
const [joinName, fieldName] = path;
|
|
370019
|
+
const join = explore.getFieldByNameIfExists(joinName);
|
|
370020
|
+
if (!join?.isExploreField() || getAccessModifier(join) !== "public" /* Public */) {
|
|
370021
|
+
return;
|
|
370022
|
+
}
|
|
370023
|
+
const joined = join.getFieldByNameIfExists(fieldName);
|
|
370024
|
+
if (!joined || joined.isExploreField() || getAccessModifier(joined) !== "public" /* Public */) {
|
|
370025
|
+
return;
|
|
370026
|
+
}
|
|
370027
|
+
const doc = getDescriptionFromTags(getTags(joined));
|
|
370028
|
+
if (doc === undefined)
|
|
370029
|
+
return;
|
|
370030
|
+
entity.description = doc;
|
|
370031
|
+
entity.doc_inherited_from = `${joinName}.${fieldName}`;
|
|
370032
|
+
}
|
|
369088
370033
|
function planJoinAuthorizeMetadata(explore, docString, relativePath, parentPath, parentAuthorize, sourceToModelPath, topLevelExploreNames, boundary, modelGivens, modelAuthorize, alwaysSeenSourceKeys, guarded, sourceDefsByName) {
|
|
369089
370034
|
const plan = [];
|
|
369090
370035
|
const sourceName = composeSourceName(parentPath, explore.name);
|
|
@@ -369185,7 +370130,7 @@ function resolveJoinMetadata(plan, nonQueryableSourceNames, rootIsQueryable, see
|
|
|
369185
370130
|
resolveJoinMetadata(descend.children, nonQueryableSourceNames, rootIsQueryable, seenSourceKeys, out);
|
|
369186
370131
|
}
|
|
369187
370132
|
}
|
|
369188
|
-
var extractDocsFromExplore = (explore) => {
|
|
370133
|
+
var MAX_ALIAS_CHAIN = 8, extractDocsFromExplore = (explore) => {
|
|
369189
370134
|
const parts = getDirectTaglines(explore).map((text) => parseDocAnnotation(text)).filter((doc) => !!doc && doc.length > 0);
|
|
369190
370135
|
return parts.length > 0 ? parts.join(`
|
|
369191
370136
|
`) : null;
|
|
@@ -369823,6 +370768,9 @@ function toApiField(entity) {
|
|
|
369823
370768
|
field.dataType = entity.field_data_type;
|
|
369824
370769
|
if (entity.description !== undefined)
|
|
369825
370770
|
field.doc = entity.description;
|
|
370771
|
+
if (entity.doc_inherited_from !== undefined) {
|
|
370772
|
+
field.docInheritedFrom = entity.doc_inherited_from;
|
|
370773
|
+
}
|
|
369826
370774
|
const join = entity.join_source_metadata;
|
|
369827
370775
|
if (join) {
|
|
369828
370776
|
field.join = {
|
|
@@ -369953,7 +370901,7 @@ function toApiSources(result) {
|
|
|
369953
370901
|
var init_to_api = () => {};
|
|
369954
370902
|
|
|
369955
370903
|
// src/package_load/protocol.ts
|
|
369956
|
-
var PACKAGE_LOAD_PROTOCOL_VERSION =
|
|
370904
|
+
var PACKAGE_LOAD_PROTOCOL_VERSION = 9;
|
|
369957
370905
|
|
|
369958
370906
|
// src/package_load/protocol_decode.ts
|
|
369959
370907
|
function isRecord2(value) {
|
|
@@ -370452,6 +371400,7 @@ class PackageLoadPool {
|
|
|
370452
371400
|
connections: qj.request.malloyConfig.connections,
|
|
370453
371401
|
urlReader: qj.request.urlReader ?? defaultUrlReader,
|
|
370454
371402
|
...qj.request.upstreamSchemas ? { upstreamSchemas: qj.request.upstreamSchemas } : {},
|
|
371403
|
+
...qj.request.targetContainers ? { targetContainers: qj.request.targetContainers } : {},
|
|
370455
371404
|
resolve: (result) => {
|
|
370456
371405
|
clearTimeout(timeout);
|
|
370457
371406
|
const checked = checkLoadPackageResult(result);
|
|
@@ -370597,6 +371546,9 @@ class PackageLoadPool {
|
|
|
370597
371546
|
case "upstream-schemas":
|
|
370598
371547
|
this.answerWorker(pw, msg, this.handleUpstreamSchemas(pw, msg));
|
|
370599
371548
|
return;
|
|
371549
|
+
case "target-containers":
|
|
371550
|
+
this.answerWorker(pw, msg, this.handleTargetContainers(pw, msg));
|
|
371551
|
+
return;
|
|
370600
371552
|
case "read-url":
|
|
370601
371553
|
this.answerWorker(pw, msg, this.handleReadUrl(pw, msg));
|
|
370602
371554
|
return;
|
|
@@ -370704,6 +371656,40 @@ class PackageLoadPool {
|
|
|
370704
371656
|
});
|
|
370705
371657
|
}
|
|
370706
371658
|
}
|
|
371659
|
+
async handleTargetContainers(pw, msg) {
|
|
371660
|
+
const ctx = this.jobs.get(msg.jobId);
|
|
371661
|
+
const reply = (response) => {
|
|
371662
|
+
this.postToWorker(pw, response);
|
|
371663
|
+
};
|
|
371664
|
+
if (!ctx) {
|
|
371665
|
+
reply({
|
|
371666
|
+
type: "rpc-error",
|
|
371667
|
+
requestId: msg.requestId,
|
|
371668
|
+
ok: false,
|
|
371669
|
+
error: { name: "Error", message: `Unknown jobId ${msg.jobId}` }
|
|
371670
|
+
});
|
|
371671
|
+
return;
|
|
371672
|
+
}
|
|
371673
|
+
try {
|
|
371674
|
+
const readings = ctx.targetContainers ? await ctx.targetContainers({
|
|
371675
|
+
containers: msg.containers,
|
|
371676
|
+
connection: async (name) => await ctx.connections.lookupConnection(name)
|
|
371677
|
+
}) : {};
|
|
371678
|
+
reply({
|
|
371679
|
+
type: "target-containers-response",
|
|
371680
|
+
requestId: msg.requestId,
|
|
371681
|
+
ok: true,
|
|
371682
|
+
readings
|
|
371683
|
+
});
|
|
371684
|
+
} catch (error) {
|
|
371685
|
+
reply({
|
|
371686
|
+
type: "rpc-error",
|
|
371687
|
+
requestId: msg.requestId,
|
|
371688
|
+
ok: false,
|
|
371689
|
+
error: serializeError(error)
|
|
371690
|
+
});
|
|
371691
|
+
}
|
|
371692
|
+
}
|
|
370707
371693
|
async handleUpstreamSchemas(pw, msg) {
|
|
370708
371694
|
const ctx = this.jobs.get(msg.jobId);
|
|
370709
371695
|
const reply = (response) => {
|
|
@@ -379327,7 +380313,7 @@ class RollupVariantServe {
|
|
|
379327
380313
|
const usage = branches.length > 0 ? queryFieldUsagePaths(prepared) : [];
|
|
379328
380314
|
for (const [i, { branch, refusal }] of branches.entries()) {
|
|
379329
380315
|
if (zoned) {
|
|
379330
|
-
const zone = zoneDecline(branch.plan, SourceMap.of(this.host.modelDef()).node(branch.plan.baseSourceID)?.def, usage === undefined ? undefined : usage.filter((p) => p[0] === branch.join.name).map((p) => p.slice(1)), undefined, branch.plan.grainDimensions.map((d) =>
|
|
380316
|
+
const zone = zoneDecline(branch.plan, SourceMap.of(this.host.modelDef()).node(branch.plan.baseSourceID)?.def, usage === undefined ? undefined : usage.filter((p) => p[0] === branch.join.name).map((p) => p.slice(1)), undefined, branch.plan.grainDimensions.map((d) => d.split(".")));
|
|
379331
380317
|
if (zone) {
|
|
379332
380318
|
first ??= zone;
|
|
379333
380319
|
members.set(branch.plan.rollupSourceName, zone);
|
|
@@ -379429,9 +380415,13 @@ class RollupVariantServe {
|
|
|
379429
380415
|
if ((recordedTimezoneOf(childDef) ?? "") !== (parentZone ?? "")) {
|
|
379430
380416
|
throw new LegDecline("rollup_time_zone", `\`${name}\` is read in the query source's time zone, and its rollup was built in its own`, { shapeCheck: true });
|
|
379431
380417
|
}
|
|
379432
|
-
const grain = new Set(plan.grainDimensions);
|
|
380418
|
+
const grain = new Set(plan.grainDimensions.filter((g) => grainPathOf(g) === undefined));
|
|
379433
380419
|
const measures = new Set(plan.rollupMeasures.map((m) => m.name));
|
|
379434
|
-
const coarse = joinGrainDecline(name, q.shape, grain, measures)
|
|
380420
|
+
const coarse = joinGrainDecline(name, q.shape, grain, measures) ?? joinOneDecline(plan, {
|
|
380421
|
+
groupedBy: readThroughJoin(name, q.shape.groupedBy),
|
|
380422
|
+
filteredBy: readThroughJoin(name, q.shape.filteredBy),
|
|
380423
|
+
measures: readThroughJoin(name, q.shape.measures)
|
|
380424
|
+
});
|
|
379435
380425
|
if (coarse)
|
|
379436
380426
|
throw coarse;
|
|
379437
380427
|
const missing = joinCoverageDecline(name, q.shape, grain, measures);
|
|
@@ -379684,16 +380674,10 @@ class RollupVariantServe {
|
|
|
379684
380674
|
}
|
|
379685
380675
|
const measures = new Set(plan.rollupMeasures.map((m) => m.name));
|
|
379686
380676
|
const dimensions = query.extension ? extensionDimensions(query.extension, plan, measures) : [];
|
|
379687
|
-
const grain =
|
|
379688
|
-
|
|
379689
|
-
|
|
379690
|
-
|
|
379691
|
-
const coarse = grainDecline(shape, grain, measures);
|
|
379692
|
-
if (coarse)
|
|
379693
|
-
throw coarse;
|
|
379694
|
-
const missing = coverageDecline(shape, measures);
|
|
379695
|
-
if (missing)
|
|
379696
|
-
throw missing;
|
|
380677
|
+
const grain = queryGrainOf(plan, dimensions);
|
|
380678
|
+
const shapeSkip = baseShapeDecline(plan, shape, grain, measures);
|
|
380679
|
+
if (shapeSkip)
|
|
380680
|
+
throw shapeSkip;
|
|
379697
380681
|
if (query.zoned) {
|
|
379698
380682
|
const zone = zoneDecline(plan, query.struct, query.zoned.usage, query.gates);
|
|
379699
380683
|
if (zone)
|
|
@@ -379747,6 +380731,7 @@ class RollupVariantServe {
|
|
|
379747
380731
|
}
|
|
379748
380732
|
const routed = await readPreparedQuery(runnable);
|
|
379749
380733
|
checkCoverage(plan, queryLevelFacts(routed));
|
|
380734
|
+
annotatedPathDecline(plan, routed.pipeline, query.struct);
|
|
379750
380735
|
if (query.gates)
|
|
379751
380736
|
proveGates(plan, query, routed, variant.modelDef);
|
|
379752
380737
|
proveGivenTerms(query, routed, variant.modelDef);
|
|
@@ -380349,7 +381334,8 @@ function withoutLeftOut(plan, modelDef, leftOut) {
|
|
|
380349
381334
|
...plan,
|
|
380350
381335
|
rollupMeasures: kept,
|
|
380351
381336
|
...plan.internalGrain ? { internalGrain: plan.internalGrain.filter((g) => !gone(g)) } : {},
|
|
380352
|
-
...plan.privateGrain ? { privateGrain: plan.privateGrain.filter((g) => !gone(g)) } : {}
|
|
381337
|
+
...plan.privateGrain ? { privateGrain: plan.privateGrain.filter((g) => !gone(g)) } : {},
|
|
381338
|
+
...plan.pathColumns ? { pathColumns: plan.pathColumns.filter((p) => !gone(p.column)) } : {}
|
|
380353
381339
|
},
|
|
380354
381340
|
dropped
|
|
380355
381341
|
};
|
|
@@ -380476,7 +381462,7 @@ function parentAlias(plan) {
|
|
|
380476
381462
|
function sourceOverRollup(plan, use, servedName, additions) {
|
|
380477
381463
|
if (use.kind === "base") {
|
|
380478
381464
|
const extension = additions;
|
|
380479
|
-
return `source: ${identifier(use.localName)} is ${identifier(servedName)}${internalPartials(plan)}${reappliedTerms(plan)}${extension}`;
|
|
381465
|
+
return `source: ${identifier(use.localName)} is ${identifier(servedName)}${internalPartials(plan)}${pathRecords(plan)}${reappliedTerms(plan)}${extension}`;
|
|
380480
381466
|
}
|
|
380481
381467
|
const { join } = use.branch;
|
|
380482
381468
|
const keyword = use.branch.relationship === "one" ? "join_one" : "join_many";
|
|
@@ -380518,13 +381504,59 @@ function baseFieldNotes(plan, modelDef) {
|
|
|
380518
381504
|
function internalPartials(plan) {
|
|
380519
381505
|
const hidden = [
|
|
380520
381506
|
...plan.rollupMeasures.flatMap((m) => m.partials.map((p) => p.column)),
|
|
380521
|
-
...plan.internalGrain ?? []
|
|
381507
|
+
...plan.internalGrain ?? [],
|
|
381508
|
+
...storedPathColumns(plan)
|
|
380522
381509
|
].map((n) => identifier(n)).join(", ");
|
|
380523
381510
|
const priv = (plan.privateGrain ?? []).map((n) => identifier(n)).join(", ");
|
|
380524
381511
|
if (!hidden && !priv)
|
|
380525
381512
|
return "";
|
|
380526
381513
|
return ` include {${hidden ? ` internal: ${hidden}` : ""}${priv ? ` private: ${priv}` : ""} public: * }`;
|
|
380527
381514
|
}
|
|
381515
|
+
function storedPathColumns(plan) {
|
|
381516
|
+
return (plan.pathColumns ?? []).filter((p) => p.column !== p.grain).map((p) => p.column);
|
|
381517
|
+
}
|
|
381518
|
+
function pathRecords(plan) {
|
|
381519
|
+
const byJoin = new Map;
|
|
381520
|
+
for (const p of plan.pathColumns ?? []) {
|
|
381521
|
+
const fields = byJoin.get(p.join) ?? new Map;
|
|
381522
|
+
if (!fields.has(p.field))
|
|
381523
|
+
fields.set(p.field, p);
|
|
381524
|
+
byJoin.set(p.join, fields);
|
|
381525
|
+
}
|
|
381526
|
+
if (byJoin.size === 0)
|
|
381527
|
+
return "";
|
|
381528
|
+
const records = [...byJoin].map(([join, fields]) => {
|
|
381529
|
+
const lines = [...fields.values()].map((p) => {
|
|
381530
|
+
const read = p.timeframe && TIMEFRAMES.has(p.timeframe) ? `${identifier(p.column)}.${p.timeframe}` : identifier(p.column);
|
|
381531
|
+
return ` ${identifier(p.field)} is ${read}`;
|
|
381532
|
+
}).join(`,
|
|
381533
|
+
`);
|
|
381534
|
+
return ` ${identifier(join)} is {
|
|
381535
|
+
${lines}
|
|
381536
|
+
}`;
|
|
381537
|
+
}).join(`
|
|
381538
|
+
`);
|
|
381539
|
+
return ` extend {
|
|
381540
|
+
dimension:
|
|
381541
|
+
${records}
|
|
381542
|
+
}`;
|
|
381543
|
+
}
|
|
381544
|
+
function queryGrainOf(plan, dimensions) {
|
|
381545
|
+
return new Set([
|
|
381546
|
+
...plan.grainDimensions,
|
|
381547
|
+
...pathGrainEntries(plan).keys(),
|
|
381548
|
+
...dimensions.map((d) => d.name)
|
|
381549
|
+
]);
|
|
381550
|
+
}
|
|
381551
|
+
function pathGrainEntries(plan) {
|
|
381552
|
+
const out = new Map;
|
|
381553
|
+
for (const p of plan.pathColumns ?? []) {
|
|
381554
|
+
const path = `${p.join}.${p.field}`;
|
|
381555
|
+
if (!out.has(path))
|
|
381556
|
+
out.set(path, p.grain);
|
|
381557
|
+
}
|
|
381558
|
+
return out;
|
|
381559
|
+
}
|
|
380528
381560
|
function reappliedTerms(plan) {
|
|
380529
381561
|
const terms = plan.readTimeTerms ?? [];
|
|
380530
381562
|
return terms.length > 0 ? ` extend {
|
|
@@ -380541,7 +381573,13 @@ function grainColumns(plan, modelDef) {
|
|
|
380541
381573
|
}
|
|
380542
381574
|
}
|
|
380543
381575
|
const notes = baseFieldNotes(plan, modelDef);
|
|
380544
|
-
|
|
381576
|
+
for (const p of plan.pathColumns ?? []) {
|
|
381577
|
+
if (p.column !== p.grain && p.timeframe !== undefined) {
|
|
381578
|
+
timeframes.set(p.column, p.timeframe);
|
|
381579
|
+
}
|
|
381580
|
+
}
|
|
381581
|
+
return plan.grainDimensions.map((grain) => {
|
|
381582
|
+
const name = grainColumnOf(grain);
|
|
380545
381583
|
const timeframe = timeframes.get(name);
|
|
380546
381584
|
return {
|
|
380547
381585
|
name,
|
|
@@ -380633,6 +381671,22 @@ function proveGivenTerms(query, routed, variantModelDef) {
|
|
|
380633
381671
|
throw contractSkip();
|
|
380634
381672
|
}
|
|
380635
381673
|
}
|
|
381674
|
+
function annotatedPathDecline(plan, pipeline, struct) {
|
|
381675
|
+
const annotated = new Map;
|
|
381676
|
+
for (const p of plan.pathColumns ?? []) {
|
|
381677
|
+
if (!p.annotated)
|
|
381678
|
+
continue;
|
|
381679
|
+
const fields = annotated.get(p.join) ?? new Set;
|
|
381680
|
+
fields.add(p.field);
|
|
381681
|
+
annotated.set(p.join, fields);
|
|
381682
|
+
}
|
|
381683
|
+
if (annotated.size === 0)
|
|
381684
|
+
return;
|
|
381685
|
+
const out = annotatedJoinedOutput(pipeline, struct?.fields, annotated);
|
|
381686
|
+
if (out.output || out.unreadable) {
|
|
381687
|
+
throw new LegDecline("rollup_missing_field", out.output ? `the query returns \`${out.output.path.join(".")}\`, whose annotations the rollup's record of stored columns cannot carry; a field under a name of its own (\`group_by: r is ${out.output.path.join(".")}\`), which carries none live either, is served from the rollup` : "the query's output columns cannot be read");
|
|
381688
|
+
}
|
|
381689
|
+
}
|
|
380636
381690
|
function checkCoverage(plan, levels) {
|
|
380637
381691
|
if (!levels) {
|
|
380638
381692
|
throw new LegDecline("rollup_count_semantics", "the query has no stage the rollup can answer");
|
|
@@ -380640,6 +381694,8 @@ function checkCoverage(plan, levels) {
|
|
|
380640
381694
|
const fanOut = new Set(plan.fanOutDimensions);
|
|
380641
381695
|
const measureFanOut = new Map(plan.rollupMeasures.map((m) => [m.name, m.fanOutDimensions]));
|
|
380642
381696
|
const anyMeasureFanOut = new Set(plan.rollupMeasures.flatMap((m) => m.fanOutDimensions));
|
|
381697
|
+
const paths = pathGrainEntries(plan);
|
|
381698
|
+
const grainOfRef = (ref) => ref?.length === 1 ? ref[0] : ref?.length === 2 ? paths.get(ref.join(".")) : undefined;
|
|
380643
381699
|
const visit = (level, fixedAbove) => {
|
|
380644
381700
|
if (level.kind !== "reduce") {
|
|
380645
381701
|
throw new LegDecline("rollup_count_semantics", `a ${level.kind === "project" ? "select:" : level.kind === "index" ? "index:" : `${level.kind}`} stage reads the source's rows, which the rollup does not keep`);
|
|
@@ -380664,7 +381720,7 @@ function checkCoverage(plan, levels) {
|
|
|
380664
381720
|
if (f.ungrouped && (fanOut.size > 0 || anyMeasureFanOut.size > 0)) {
|
|
380665
381721
|
throw new LegDecline("rollup_grain_too_coarse", `\`${f.name}\` re-sums across a fan-out dimension of the rollup's grain`);
|
|
380666
381722
|
}
|
|
380667
|
-
const ref = f.ref
|
|
381723
|
+
const ref = grainOfRef(f.ref);
|
|
380668
381724
|
const named = ref !== undefined ? measureFanOut.get(ref) : undefined;
|
|
380669
381725
|
if (ref !== undefined && named === undefined)
|
|
380670
381726
|
grouped.add(ref);
|
|
@@ -380771,10 +381827,45 @@ function zoneDecline(plan, struct, usage, gates, extra = []) {
|
|
|
380771
381827
|
return [String(field.as ?? field.name), f];
|
|
380772
381828
|
}));
|
|
380773
381829
|
const memo = new Map;
|
|
381830
|
+
const storedPaths = pathGrainEntries(plan);
|
|
381831
|
+
const joinOf = (name) => fields.get(name);
|
|
381832
|
+
const joinedOf = (join) => new Map((join.fields ?? []).map((f) => {
|
|
381833
|
+
const field = f;
|
|
381834
|
+
return [String(field.as ?? field.name), f];
|
|
381835
|
+
}));
|
|
381836
|
+
const temporal = (f) => !f || f.join !== undefined || ZONED_TYPES.has(String(f.type));
|
|
381837
|
+
const conditionDependsOnZone = (name) => {
|
|
381838
|
+
const join = joinOf(name);
|
|
381839
|
+
if (!join || join.join === undefined)
|
|
381840
|
+
return true;
|
|
381841
|
+
const joined = joinedOf(join);
|
|
381842
|
+
return hasZonedNode(join.onExpression) || fieldPathsIn(join.onExpression).some((p) => p.length === 1 ? temporal(fields.get(p[0])) : p.length !== 2 || p[0] !== name || temporal(joined.get(p[1])));
|
|
381843
|
+
};
|
|
381844
|
+
const joinedDependsOnZone = (path) => {
|
|
381845
|
+
const join = joinOf(path[0]);
|
|
381846
|
+
if (!join || conditionDependsOnZone(path[0]))
|
|
381847
|
+
return true;
|
|
381848
|
+
const joined = joinedOf(join);
|
|
381849
|
+
const f = joined.get(path[1]);
|
|
381850
|
+
if (!f || f.join !== undefined)
|
|
381851
|
+
return true;
|
|
381852
|
+
if (f.e === undefined) {
|
|
381853
|
+
return f.timeframe !== undefined && ZONED_TYPES.has(String(f.type));
|
|
381854
|
+
}
|
|
381855
|
+
return ZONED_TYPES.has(String(f.type)) || hasZonedNode(f.e) || fieldPathsIn(f.e).some((p) => p.length !== 1 || temporal(joined.get(p[0])) || joined.get(p[0])?.e !== undefined);
|
|
381856
|
+
};
|
|
381857
|
+
const pathJoins = new Set([...storedPaths.keys()].map((p) => p.slice(0, p.indexOf("."))));
|
|
381858
|
+
const conditionRead = (path) => path.length === 2 && pathJoins.has(path[0]) && fieldPathsIn(joinOf(path[0])?.onExpression).some((p) => p.join(".") === path.join("."));
|
|
381859
|
+
const isStoredPath = (path) => path.length === 2 && storedPaths.has(path.join("."));
|
|
380774
381860
|
const storedDependsOnZone = (path) => {
|
|
380775
381861
|
const [name] = path;
|
|
380776
381862
|
if (name === undefined)
|
|
380777
381863
|
return false;
|
|
381864
|
+
if (isStoredPath(path))
|
|
381865
|
+
return joinedDependsOnZone(path);
|
|
381866
|
+
if (conditionRead(path)) {
|
|
381867
|
+
return conditionDependsOnZone(path[0]);
|
|
381868
|
+
}
|
|
380778
381869
|
if (path.length !== 1)
|
|
380779
381870
|
return true;
|
|
380780
381871
|
const f = fields.get(name);
|
|
@@ -380797,6 +381888,8 @@ function zoneDecline(plan, struct, usage, gates, extra = []) {
|
|
|
380797
381888
|
const [name] = path;
|
|
380798
381889
|
if (name === undefined)
|
|
380799
381890
|
return false;
|
|
381891
|
+
if (isStoredPath(path))
|
|
381892
|
+
return joinedDependsOnZone(path);
|
|
380800
381893
|
if (path.length !== 1)
|
|
380801
381894
|
return true;
|
|
380802
381895
|
const f = fields.get(name);
|
|
@@ -380819,6 +381912,17 @@ function grainDecline(shape, grain, measures) {
|
|
|
380819
381912
|
}
|
|
380820
381913
|
return;
|
|
380821
381914
|
}
|
|
381915
|
+
function baseShapeDecline(plan, shape, grain, measures) {
|
|
381916
|
+
return grainDecline(shape, grain, measures) ?? coverageDecline(shape, measures) ?? joinOneDecline(plan, shape);
|
|
381917
|
+
}
|
|
381918
|
+
function joinOneDecline(plan, shape) {
|
|
381919
|
+
const reads = [...shape.groupedBy, ...shape.filteredBy, ...shape.measures];
|
|
381920
|
+
const measureReads = (name, join) => plan.rollupMeasures.some((m) => m.name === name && m.partials.some((p) => p.leaf.joinPath[0] === join || p.leaf.reads.some((r) => r[0] === join)));
|
|
381921
|
+
const unread = (plan.joinOneGrain ?? []).find(({ join, grain }) => !reads.some((p) => p.startsWith(`${join}.`) || grain.includes(p) || measureReads(p, join)));
|
|
381922
|
+
if (unread === undefined)
|
|
381923
|
+
return;
|
|
381924
|
+
return new LegDecline("rollup_count_semantics", `the query reads nothing through \`${unread.join}\`, a join_one the rollup's grain reads (${unread.grain.map((g) => `\`${g}\``).join(", ")}); the rollup was built over that join, so a key it repeats would inflate a coarser answer that live, not joining it, does not`, { shapeCheck: true });
|
|
381925
|
+
}
|
|
380822
381926
|
function coverageDecline(shape, measures) {
|
|
380823
381927
|
const missing = shape.measures.find((m) => !measures.has(m));
|
|
380824
381928
|
if (missing !== undefined) {
|
|
@@ -380863,6 +381967,7 @@ var init_rollup_variants = __esm(() => {
|
|
|
380863
381967
|
init_gate_reads();
|
|
380864
381968
|
init_read_text();
|
|
380865
381969
|
init_table_plans();
|
|
381970
|
+
init_inlined_join_text();
|
|
380866
381971
|
init_source_map();
|
|
380867
381972
|
init_author_imports();
|
|
380868
381973
|
init_join_rollup();
|
|
@@ -381071,6 +382176,7 @@ var init_model = __esm(() => {
|
|
|
381071
382176
|
init_model_policy();
|
|
381072
382177
|
init_model_query_request();
|
|
381073
382178
|
init_annotation_near_miss();
|
|
382179
|
+
init_managed_catalog_scope();
|
|
381074
382180
|
init_column_contract();
|
|
381075
382181
|
init_model_query_request();
|
|
381076
382182
|
init_model_policy();
|
|
@@ -382284,6 +383390,7 @@ var init_model = __esm(() => {
|
|
|
382284
383390
|
}
|
|
382285
383391
|
newServedCopy() {
|
|
382286
383392
|
return new ServedCopyServe({
|
|
383393
|
+
managedTablePathRefusal,
|
|
382287
383394
|
authorResultShape: async (queryString, givens) => {
|
|
382288
383395
|
const materializer = this.modelMaterializer;
|
|
382289
383396
|
if (!materializer)
|
|
@@ -382548,6 +383655,7 @@ var init_model = __esm(() => {
|
|
|
382548
383655
|
const destinations = this.serveDestinationConfig;
|
|
382549
383656
|
const pinned = pin(makeSnapshot(bindings), new Date(0));
|
|
382550
383657
|
const copy = new ServedCopyServe({
|
|
383658
|
+
managedTablePathRefusal,
|
|
382551
383659
|
modelPath: () => this.modelPath,
|
|
382552
383660
|
modelDef: () => this.modelDef,
|
|
382553
383661
|
serveDestinationConfig: () => destinations && storageServes(getPersistStorageMode()) ? () => compileOnlyDestinationConfig(destinations()) : undefined,
|
|
@@ -382573,6 +383681,7 @@ var init_model = __esm(() => {
|
|
|
382573
383681
|
return out;
|
|
382574
383682
|
const pinned = pin(makeSnapshot(stored), new Date(0));
|
|
382575
383683
|
const copy = new ServedCopyServe({
|
|
383684
|
+
managedTablePathRefusal,
|
|
382576
383685
|
modelPath: () => this.modelPath,
|
|
382577
383686
|
modelDef: () => this.modelDef,
|
|
382578
383687
|
quiet: true,
|
|
@@ -383705,6 +384814,7 @@ var init_package2 = __esm(() => {
|
|
|
383705
384814
|
const dispatchTime = performance.now();
|
|
383706
384815
|
const workerOutcome = loadOutcomeOrThrow(pool.loadPackage({
|
|
383707
384816
|
upstreamSchemas: readUpstreamSchemas,
|
|
384817
|
+
targetContainers: readTargetContainers,
|
|
383708
384818
|
packagePath,
|
|
383709
384819
|
packageName,
|
|
383710
384820
|
environmentName,
|
|
@@ -384217,6 +385327,7 @@ var init_package2 = __esm(() => {
|
|
|
384217
385327
|
return this.mz.refreshBuildPlan(async () => {
|
|
384218
385328
|
const outcome = await loadOutcomeOrThrow(getPackageLoadPool().loadPackage({
|
|
384219
385329
|
upstreamSchemas: readUpstreamSchemas,
|
|
385330
|
+
targetContainers: readTargetContainers,
|
|
384220
385331
|
packagePath: this.packagePath,
|
|
384221
385332
|
packageName: this.packageName,
|
|
384222
385333
|
environmentName: this.environmentName,
|
|
@@ -384493,6 +385604,12 @@ var init_package2 = __esm(() => {
|
|
|
384493
385604
|
this.mz.plan.withdraw(withdrawn.map(([sourceID]) => sourceID));
|
|
384494
385605
|
return { sources: names, tables: tableNames };
|
|
384495
385606
|
}
|
|
385607
|
+
readTargetContainers(containers) {
|
|
385608
|
+
return readTargetContainers({
|
|
385609
|
+
containers,
|
|
385610
|
+
connection: (name) => this.getMalloyConnection(name)
|
|
385611
|
+
});
|
|
385612
|
+
}
|
|
384496
385613
|
async readUpstreamSchemas(tables, use) {
|
|
384497
385614
|
const connection = (name) => this.getMalloyConnection(name);
|
|
384498
385615
|
if (use === "load") {
|
|
@@ -386670,6 +387787,7 @@ async function loadPackageInWorker(ctx) {
|
|
|
386670
387787
|
try {
|
|
386671
387788
|
return await getPackageLoadPool().loadPackage({
|
|
386672
387789
|
upstreamSchemas: readUpstreamSchemas,
|
|
387790
|
+
targetContainers: readTargetContainers,
|
|
386673
387791
|
packagePath: ctx.packagePath,
|
|
386674
387792
|
packageName: ctx.packageName,
|
|
386675
387793
|
environmentName: ctx.environmentName,
|
|
@@ -401495,6 +402613,29 @@ function readFieldProvenance(modelDef, sourceName, sourceTextFor) {
|
|
|
401495
402613
|
}
|
|
401496
402614
|
return provenance;
|
|
401497
402615
|
}
|
|
402616
|
+
function fieldDocs(field, aliasOf, siblings, aliasOfField) {
|
|
402617
|
+
const own = entityDocs(field.annotations);
|
|
402618
|
+
if (field.kind !== "dimension" || own.embedDoc)
|
|
402619
|
+
return own;
|
|
402620
|
+
let path = aliasOf;
|
|
402621
|
+
for (let depth = 0;path !== undefined && !path.includes("."); depth++) {
|
|
402622
|
+
const link = siblings.find((f) => f.kind === "dimension" && memberSegment(f.name) === path);
|
|
402623
|
+
if (depth >= MAX_ALIAS_CHAIN2 || !link)
|
|
402624
|
+
return own;
|
|
402625
|
+
if (entityDocs(link.annotations).embedDoc)
|
|
402626
|
+
return own;
|
|
402627
|
+
path = aliasOfField(link.name);
|
|
402628
|
+
}
|
|
402629
|
+
const parts = path?.split(".") ?? [];
|
|
402630
|
+
if (parts.length !== 2)
|
|
402631
|
+
return own;
|
|
402632
|
+
const join = siblings.find((f) => f.kind === "join" && memberSegment(f.name) === parts[0]);
|
|
402633
|
+
const joined = join?.schema?.fields?.find((f) => f.kind !== "join" && memberSegment(f.name) === parts[1]);
|
|
402634
|
+
if (!join || !joined)
|
|
402635
|
+
return own;
|
|
402636
|
+
const inherited = entityDocs(joined.annotations);
|
|
402637
|
+
return inherited.embedDoc ? { ...inherited, docInheritedFrom: `${join.name}.${joined.name}` } : own;
|
|
402638
|
+
}
|
|
401498
402639
|
function memberSegment(name) {
|
|
401499
402640
|
return identifier(name);
|
|
401500
402641
|
}
|
|
@@ -401820,7 +402961,7 @@ async function collectEntities(pkg) {
|
|
|
401820
402961
|
name: field.name,
|
|
401821
402962
|
source: sourceName,
|
|
401822
402963
|
modelPath,
|
|
401823
|
-
...
|
|
402964
|
+
...fieldDocs(field, fieldProvenance?.aliasOf, sourceInfo.schema.fields, (name) => provenance.get(name)?.aliasOf),
|
|
401824
402965
|
...field.kind === "view" ? {} : {
|
|
401825
402966
|
dataType: malloyType(field),
|
|
401826
402967
|
...classificationOf(lineage, field.name, field.annotations)
|
|
@@ -402018,6 +403159,9 @@ function collapseAliases(entities) {
|
|
|
402018
403159
|
keep.embedDoc = donor.embedDoc;
|
|
402019
403160
|
if (donor.docSource)
|
|
402020
403161
|
keep.docSource = donor.docSource;
|
|
403162
|
+
if (donor.docInheritedFrom) {
|
|
403163
|
+
keep.docInheritedFrom = donor.docInheritedFrom;
|
|
403164
|
+
}
|
|
402021
403165
|
}
|
|
402022
403166
|
}
|
|
402023
403167
|
if (!keep.classifications) {
|
|
@@ -402142,7 +403286,7 @@ async function packageIndexOf(indexes, pkg, packageName) {
|
|
|
402142
403286
|
});
|
|
402143
403287
|
return built;
|
|
402144
403288
|
}
|
|
402145
|
-
var SOURCE_DOC_MAX_CHARS = 500, JOIN_DOC_MAX_CHARS = 200, AUTHORED_DOC_ROUTES, MAX_JOIN_PATH_DEPTH = 2, MAX_RECORD_DEPTH2 = 4, MAX_RECORD_MEMBERS_PER_SOURCE = 300, PLAIN_MEMBER_NAME2, JOIN_TOPOLOGY_MAX_DEPTH = 10, ONE_LINE_SUMMARY_MAX_CHARS = 120;
|
|
403289
|
+
var SOURCE_DOC_MAX_CHARS = 500, JOIN_DOC_MAX_CHARS = 200, AUTHORED_DOC_ROUTES, MAX_JOIN_PATH_DEPTH = 2, MAX_ALIAS_CHAIN2 = 8, MAX_RECORD_DEPTH2 = 4, MAX_RECORD_MEMBERS_PER_SOURCE = 300, PLAIN_MEMBER_NAME2, JOIN_TOPOLOGY_MAX_DEPTH = 10, ONE_LINE_SUMMARY_MAX_CHARS = 120;
|
|
402146
403290
|
var init_package_entities = __esm(() => {
|
|
402147
403291
|
init_access_gates();
|
|
402148
403292
|
init_annotation_reader();
|
|
@@ -402250,6 +403394,7 @@ function toSourceResults(results, sourceContext, environmentName, packageName, s
|
|
|
402250
403394
|
...r.score !== undefined ? { relevance: r.score } : {},
|
|
402251
403395
|
...r.doc ? { description: r.doc } : {},
|
|
402252
403396
|
...r.doc && r.docSource ? { description_source: r.docSource } : {},
|
|
403397
|
+
...r.doc && r.docInheritedFrom ? { description_inherited_from: r.docInheritedFrom } : {},
|
|
402253
403398
|
...r.dataType ? { data_type: r.dataType } : {},
|
|
402254
403399
|
...r.classifications ? { classifications: r.classifications } : {},
|
|
402255
403400
|
...r.classificationInferred ? { classification_inferred: true } : {},
|
|
@@ -402330,6 +403475,7 @@ function projectEntity(e, environmentName, packageName) {
|
|
|
402330
403475
|
doc: e.doc,
|
|
402331
403476
|
...e.embedDoc ? { embedDoc: e.embedDoc } : {},
|
|
402332
403477
|
...e.docSource ? { docSource: e.docSource } : {},
|
|
403478
|
+
...e.docInheritedFrom ? { docInheritedFrom: e.docInheritedFrom } : {},
|
|
402333
403479
|
...e.relationship ? { relationship: e.relationship } : {},
|
|
402334
403480
|
...e.aliases ? { aliases: e.aliases } : {},
|
|
402335
403481
|
...e.joinPath ? { joinPath: e.joinPath } : {},
|
|
@@ -402883,6 +404029,7 @@ function buildCatalog(input) {
|
|
|
402883
404029
|
doc: e.embedDoc,
|
|
402884
404030
|
displayDoc: e.doc,
|
|
402885
404031
|
...e.docSource ? { docSource: e.docSource } : {},
|
|
404032
|
+
...e.docInheritedFrom ? { docInheritedFrom: e.docInheritedFrom } : {},
|
|
402886
404033
|
...e.dataType ? { dataType: e.dataType } : {},
|
|
402887
404034
|
...e.code ? { code: e.code } : {},
|
|
402888
404035
|
...e.joinPath ? { joinPath: e.joinPath } : {},
|
|
@@ -408163,6 +409310,7 @@ async function place(args, cluster, node, home, homePath, target, matched, warni
|
|
|
408163
409310
|
doc,
|
|
408164
409311
|
...node.doc ? { embedDoc: node.doc } : {},
|
|
408165
409312
|
...node.docSource ? { docSource: node.docSource } : {},
|
|
409313
|
+
...node.docInheritedFrom ? { docInheritedFrom: node.docInheritedFrom } : {},
|
|
408166
409314
|
joinPath: path.join("."),
|
|
408167
409315
|
...throughFanout(entry.fanout, fieldFanout(node)) ? { relationship: throughFanout(entry.fanout, fieldFanout(node)) } : {},
|
|
408168
409316
|
...node.dataType ? { dataType: node.dataType } : {},
|
|
@@ -408196,6 +409344,7 @@ function routeRow(args, route) {
|
|
|
408196
409344
|
doc: node.displayDoc ? `${node.displayDoc} ${note}` : note,
|
|
408197
409345
|
...node.doc ? { embedDoc: node.doc } : {},
|
|
408198
409346
|
...node.docSource ? { docSource: node.docSource } : {},
|
|
409347
|
+
...node.docInheritedFrom ? { docInheritedFrom: node.docInheritedFrom } : {},
|
|
408199
409348
|
joinPath,
|
|
408200
409349
|
...throughFanout(hop?.fanout, fieldFanout(node)) ? { relationship: throughFanout(hop?.fanout, fieldFanout(node)) } : {},
|
|
408201
409350
|
...node.dataType ? { dataType: node.dataType } : {},
|
|
@@ -458027,7 +459176,7 @@ function _enum(values, params) {
|
|
|
458027
459176
|
...normalizeParams(params)
|
|
458028
459177
|
});
|
|
458029
459178
|
}
|
|
458030
|
-
function
|
|
459179
|
+
function literal2(value, params) {
|
|
458031
459180
|
return new ZodLiteral({
|
|
458032
459181
|
type: "literal",
|
|
458033
459182
|
values: Array.isArray(value) ? value : [value],
|
|
@@ -458642,16 +459791,16 @@ var init_types5 = __esm(() => {
|
|
|
458642
459791
|
});
|
|
458643
459792
|
RequestIdSchema = union([string3(), number3().int()]);
|
|
458644
459793
|
JSONRPCRequestSchema = object({
|
|
458645
|
-
jsonrpc:
|
|
459794
|
+
jsonrpc: literal2(JSONRPC_VERSION),
|
|
458646
459795
|
id: RequestIdSchema,
|
|
458647
459796
|
...RequestSchema.shape
|
|
458648
459797
|
}).strict();
|
|
458649
459798
|
JSONRPCNotificationSchema = object({
|
|
458650
|
-
jsonrpc:
|
|
459799
|
+
jsonrpc: literal2(JSONRPC_VERSION),
|
|
458651
459800
|
...NotificationSchema.shape
|
|
458652
459801
|
}).strict();
|
|
458653
459802
|
JSONRPCResultResponseSchema = object({
|
|
458654
|
-
jsonrpc:
|
|
459803
|
+
jsonrpc: literal2(JSONRPC_VERSION),
|
|
458655
459804
|
id: RequestIdSchema,
|
|
458656
459805
|
result: ResultSchema
|
|
458657
459806
|
}).strict();
|
|
@@ -458666,7 +459815,7 @@ var init_types5 = __esm(() => {
|
|
|
458666
459815
|
ErrorCode[ErrorCode["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
|
|
458667
459816
|
})(ErrorCode || (ErrorCode = {}));
|
|
458668
459817
|
JSONRPCErrorResponseSchema = object({
|
|
458669
|
-
jsonrpc:
|
|
459818
|
+
jsonrpc: literal2(JSONRPC_VERSION),
|
|
458670
459819
|
id: RequestIdSchema.optional(),
|
|
458671
459820
|
error: object({
|
|
458672
459821
|
code: number3().int(),
|
|
@@ -458687,7 +459836,7 @@ var init_types5 = __esm(() => {
|
|
|
458687
459836
|
reason: string3().optional()
|
|
458688
459837
|
});
|
|
458689
459838
|
CancelledNotificationSchema = NotificationSchema.extend({
|
|
458690
|
-
method:
|
|
459839
|
+
method: literal2("notifications/cancelled"),
|
|
458691
459840
|
params: CancelledNotificationParamsSchema
|
|
458692
459841
|
});
|
|
458693
459842
|
IconSchema = object({
|
|
@@ -458764,7 +459913,7 @@ var init_types5 = __esm(() => {
|
|
|
458764
459913
|
clientInfo: ImplementationSchema
|
|
458765
459914
|
});
|
|
458766
459915
|
InitializeRequestSchema = RequestSchema.extend({
|
|
458767
|
-
method:
|
|
459916
|
+
method: literal2("initialize"),
|
|
458768
459917
|
params: InitializeRequestParamsSchema
|
|
458769
459918
|
});
|
|
458770
459919
|
ServerCapabilitiesSchema = object({
|
|
@@ -458791,11 +459940,11 @@ var init_types5 = __esm(() => {
|
|
|
458791
459940
|
instructions: string3().optional()
|
|
458792
459941
|
});
|
|
458793
459942
|
InitializedNotificationSchema = NotificationSchema.extend({
|
|
458794
|
-
method:
|
|
459943
|
+
method: literal2("notifications/initialized"),
|
|
458795
459944
|
params: NotificationsParamsSchema.optional()
|
|
458796
459945
|
});
|
|
458797
459946
|
PingRequestSchema = RequestSchema.extend({
|
|
458798
|
-
method:
|
|
459947
|
+
method: literal2("ping"),
|
|
458799
459948
|
params: BaseRequestParamsSchema.optional()
|
|
458800
459949
|
});
|
|
458801
459950
|
ProgressSchema = object({
|
|
@@ -458809,7 +459958,7 @@ var init_types5 = __esm(() => {
|
|
|
458809
459958
|
progressToken: ProgressTokenSchema
|
|
458810
459959
|
});
|
|
458811
459960
|
ProgressNotificationSchema = NotificationSchema.extend({
|
|
458812
|
-
method:
|
|
459961
|
+
method: literal2("notifications/progress"),
|
|
458813
459962
|
params: ProgressNotificationParamsSchema
|
|
458814
459963
|
});
|
|
458815
459964
|
PaginatedRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
@@ -458836,31 +459985,31 @@ var init_types5 = __esm(() => {
|
|
|
458836
459985
|
});
|
|
458837
459986
|
TaskStatusNotificationParamsSchema = NotificationsParamsSchema.merge(TaskSchema);
|
|
458838
459987
|
TaskStatusNotificationSchema = NotificationSchema.extend({
|
|
458839
|
-
method:
|
|
459988
|
+
method: literal2("notifications/tasks/status"),
|
|
458840
459989
|
params: TaskStatusNotificationParamsSchema
|
|
458841
459990
|
});
|
|
458842
459991
|
GetTaskRequestSchema = RequestSchema.extend({
|
|
458843
|
-
method:
|
|
459992
|
+
method: literal2("tasks/get"),
|
|
458844
459993
|
params: BaseRequestParamsSchema.extend({
|
|
458845
459994
|
taskId: string3()
|
|
458846
459995
|
})
|
|
458847
459996
|
});
|
|
458848
459997
|
GetTaskResultSchema = ResultSchema.merge(TaskSchema);
|
|
458849
459998
|
GetTaskPayloadRequestSchema = RequestSchema.extend({
|
|
458850
|
-
method:
|
|
459999
|
+
method: literal2("tasks/result"),
|
|
458851
460000
|
params: BaseRequestParamsSchema.extend({
|
|
458852
460001
|
taskId: string3()
|
|
458853
460002
|
})
|
|
458854
460003
|
});
|
|
458855
460004
|
GetTaskPayloadResultSchema = ResultSchema.loose();
|
|
458856
460005
|
ListTasksRequestSchema = PaginatedRequestSchema.extend({
|
|
458857
|
-
method:
|
|
460006
|
+
method: literal2("tasks/list")
|
|
458858
460007
|
});
|
|
458859
460008
|
ListTasksResultSchema = PaginatedResultSchema.extend({
|
|
458860
460009
|
tasks: array(TaskSchema)
|
|
458861
460010
|
});
|
|
458862
460011
|
CancelTaskRequestSchema = RequestSchema.extend({
|
|
458863
|
-
method:
|
|
460012
|
+
method: literal2("tasks/cancel"),
|
|
458864
460013
|
params: BaseRequestParamsSchema.extend({
|
|
458865
460014
|
taskId: string3()
|
|
458866
460015
|
})
|
|
@@ -458911,13 +460060,13 @@ var init_types5 = __esm(() => {
|
|
|
458911
460060
|
_meta: optional2(looseObject({}))
|
|
458912
460061
|
});
|
|
458913
460062
|
ListResourcesRequestSchema = PaginatedRequestSchema.extend({
|
|
458914
|
-
method:
|
|
460063
|
+
method: literal2("resources/list")
|
|
458915
460064
|
});
|
|
458916
460065
|
ListResourcesResultSchema = PaginatedResultSchema.extend({
|
|
458917
460066
|
resources: array(ResourceSchema)
|
|
458918
460067
|
});
|
|
458919
460068
|
ListResourceTemplatesRequestSchema = PaginatedRequestSchema.extend({
|
|
458920
|
-
method:
|
|
460069
|
+
method: literal2("resources/templates/list")
|
|
458921
460070
|
});
|
|
458922
460071
|
ListResourceTemplatesResultSchema = PaginatedResultSchema.extend({
|
|
458923
460072
|
resourceTemplates: array(ResourceTemplateSchema)
|
|
@@ -458927,31 +460076,31 @@ var init_types5 = __esm(() => {
|
|
|
458927
460076
|
});
|
|
458928
460077
|
ReadResourceRequestParamsSchema = ResourceRequestParamsSchema;
|
|
458929
460078
|
ReadResourceRequestSchema = RequestSchema.extend({
|
|
458930
|
-
method:
|
|
460079
|
+
method: literal2("resources/read"),
|
|
458931
460080
|
params: ReadResourceRequestParamsSchema
|
|
458932
460081
|
});
|
|
458933
460082
|
ReadResourceResultSchema = ResultSchema.extend({
|
|
458934
460083
|
contents: array(union([TextResourceContentsSchema, BlobResourceContentsSchema]))
|
|
458935
460084
|
});
|
|
458936
460085
|
ResourceListChangedNotificationSchema = NotificationSchema.extend({
|
|
458937
|
-
method:
|
|
460086
|
+
method: literal2("notifications/resources/list_changed"),
|
|
458938
460087
|
params: NotificationsParamsSchema.optional()
|
|
458939
460088
|
});
|
|
458940
460089
|
SubscribeRequestParamsSchema = ResourceRequestParamsSchema;
|
|
458941
460090
|
SubscribeRequestSchema = RequestSchema.extend({
|
|
458942
|
-
method:
|
|
460091
|
+
method: literal2("resources/subscribe"),
|
|
458943
460092
|
params: SubscribeRequestParamsSchema
|
|
458944
460093
|
});
|
|
458945
460094
|
UnsubscribeRequestParamsSchema = ResourceRequestParamsSchema;
|
|
458946
460095
|
UnsubscribeRequestSchema = RequestSchema.extend({
|
|
458947
|
-
method:
|
|
460096
|
+
method: literal2("resources/unsubscribe"),
|
|
458948
460097
|
params: UnsubscribeRequestParamsSchema
|
|
458949
460098
|
});
|
|
458950
460099
|
ResourceUpdatedNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
458951
460100
|
uri: string3()
|
|
458952
460101
|
});
|
|
458953
460102
|
ResourceUpdatedNotificationSchema = NotificationSchema.extend({
|
|
458954
|
-
method:
|
|
460103
|
+
method: literal2("notifications/resources/updated"),
|
|
458955
460104
|
params: ResourceUpdatedNotificationParamsSchema
|
|
458956
460105
|
});
|
|
458957
460106
|
PromptArgumentSchema = object({
|
|
@@ -458967,7 +460116,7 @@ var init_types5 = __esm(() => {
|
|
|
458967
460116
|
_meta: optional2(looseObject({}))
|
|
458968
460117
|
});
|
|
458969
460118
|
ListPromptsRequestSchema = PaginatedRequestSchema.extend({
|
|
458970
|
-
method:
|
|
460119
|
+
method: literal2("prompts/list")
|
|
458971
460120
|
});
|
|
458972
460121
|
ListPromptsResultSchema = PaginatedResultSchema.extend({
|
|
458973
460122
|
prompts: array(PromptSchema)
|
|
@@ -458977,44 +460126,44 @@ var init_types5 = __esm(() => {
|
|
|
458977
460126
|
arguments: record(string3(), string3()).optional()
|
|
458978
460127
|
});
|
|
458979
460128
|
GetPromptRequestSchema = RequestSchema.extend({
|
|
458980
|
-
method:
|
|
460129
|
+
method: literal2("prompts/get"),
|
|
458981
460130
|
params: GetPromptRequestParamsSchema
|
|
458982
460131
|
});
|
|
458983
460132
|
TextContentSchema = object({
|
|
458984
|
-
type:
|
|
460133
|
+
type: literal2("text"),
|
|
458985
460134
|
text: string3(),
|
|
458986
460135
|
annotations: AnnotationsSchema.optional(),
|
|
458987
460136
|
_meta: record(string3(), unknown()).optional()
|
|
458988
460137
|
});
|
|
458989
460138
|
ImageContentSchema = object({
|
|
458990
|
-
type:
|
|
460139
|
+
type: literal2("image"),
|
|
458991
460140
|
data: Base64Schema,
|
|
458992
460141
|
mimeType: string3(),
|
|
458993
460142
|
annotations: AnnotationsSchema.optional(),
|
|
458994
460143
|
_meta: record(string3(), unknown()).optional()
|
|
458995
460144
|
});
|
|
458996
460145
|
AudioContentSchema = object({
|
|
458997
|
-
type:
|
|
460146
|
+
type: literal2("audio"),
|
|
458998
460147
|
data: Base64Schema,
|
|
458999
460148
|
mimeType: string3(),
|
|
459000
460149
|
annotations: AnnotationsSchema.optional(),
|
|
459001
460150
|
_meta: record(string3(), unknown()).optional()
|
|
459002
460151
|
});
|
|
459003
460152
|
ToolUseContentSchema = object({
|
|
459004
|
-
type:
|
|
460153
|
+
type: literal2("tool_use"),
|
|
459005
460154
|
name: string3(),
|
|
459006
460155
|
id: string3(),
|
|
459007
460156
|
input: record(string3(), unknown()),
|
|
459008
460157
|
_meta: record(string3(), unknown()).optional()
|
|
459009
460158
|
});
|
|
459010
460159
|
EmbeddedResourceSchema = object({
|
|
459011
|
-
type:
|
|
460160
|
+
type: literal2("resource"),
|
|
459012
460161
|
resource: union([TextResourceContentsSchema, BlobResourceContentsSchema]),
|
|
459013
460162
|
annotations: AnnotationsSchema.optional(),
|
|
459014
460163
|
_meta: record(string3(), unknown()).optional()
|
|
459015
460164
|
});
|
|
459016
460165
|
ResourceLinkSchema = ResourceSchema.extend({
|
|
459017
|
-
type:
|
|
460166
|
+
type: literal2("resource_link")
|
|
459018
460167
|
});
|
|
459019
460168
|
ContentBlockSchema = union([
|
|
459020
460169
|
TextContentSchema,
|
|
@@ -459032,7 +460181,7 @@ var init_types5 = __esm(() => {
|
|
|
459032
460181
|
messages: array(PromptMessageSchema)
|
|
459033
460182
|
});
|
|
459034
460183
|
PromptListChangedNotificationSchema = NotificationSchema.extend({
|
|
459035
|
-
method:
|
|
460184
|
+
method: literal2("notifications/prompts/list_changed"),
|
|
459036
460185
|
params: NotificationsParamsSchema.optional()
|
|
459037
460186
|
});
|
|
459038
460187
|
ToolAnnotationsSchema = object({
|
|
@@ -459050,12 +460199,12 @@ var init_types5 = __esm(() => {
|
|
|
459050
460199
|
...IconsSchema.shape,
|
|
459051
460200
|
description: string3().optional(),
|
|
459052
460201
|
inputSchema: object({
|
|
459053
|
-
type:
|
|
460202
|
+
type: literal2("object"),
|
|
459054
460203
|
properties: record(string3(), AssertObjectSchema).optional(),
|
|
459055
460204
|
required: array(string3()).optional()
|
|
459056
460205
|
}).catchall(unknown()),
|
|
459057
460206
|
outputSchema: object({
|
|
459058
|
-
type:
|
|
460207
|
+
type: literal2("object"),
|
|
459059
460208
|
properties: record(string3(), AssertObjectSchema).optional(),
|
|
459060
460209
|
required: array(string3()).optional()
|
|
459061
460210
|
}).catchall(unknown()).optional(),
|
|
@@ -459064,7 +460213,7 @@ var init_types5 = __esm(() => {
|
|
|
459064
460213
|
_meta: record(string3(), unknown()).optional()
|
|
459065
460214
|
});
|
|
459066
460215
|
ListToolsRequestSchema = PaginatedRequestSchema.extend({
|
|
459067
|
-
method:
|
|
460216
|
+
method: literal2("tools/list")
|
|
459068
460217
|
});
|
|
459069
460218
|
ListToolsResultSchema = PaginatedResultSchema.extend({
|
|
459070
460219
|
tools: array(ToolSchema)
|
|
@@ -459082,11 +460231,11 @@ var init_types5 = __esm(() => {
|
|
|
459082
460231
|
arguments: record(string3(), unknown()).optional()
|
|
459083
460232
|
});
|
|
459084
460233
|
CallToolRequestSchema = RequestSchema.extend({
|
|
459085
|
-
method:
|
|
460234
|
+
method: literal2("tools/call"),
|
|
459086
460235
|
params: CallToolRequestParamsSchema
|
|
459087
460236
|
});
|
|
459088
460237
|
ToolListChangedNotificationSchema = NotificationSchema.extend({
|
|
459089
|
-
method:
|
|
460238
|
+
method: literal2("notifications/tools/list_changed"),
|
|
459090
460239
|
params: NotificationsParamsSchema.optional()
|
|
459091
460240
|
});
|
|
459092
460241
|
ListChangedOptionsBaseSchema = object({
|
|
@@ -459098,7 +460247,7 @@ var init_types5 = __esm(() => {
|
|
|
459098
460247
|
level: LoggingLevelSchema
|
|
459099
460248
|
});
|
|
459100
460249
|
SetLevelRequestSchema = RequestSchema.extend({
|
|
459101
|
-
method:
|
|
460250
|
+
method: literal2("logging/setLevel"),
|
|
459102
460251
|
params: SetLevelRequestParamsSchema
|
|
459103
460252
|
});
|
|
459104
460253
|
LoggingMessageNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
@@ -459107,7 +460256,7 @@ var init_types5 = __esm(() => {
|
|
|
459107
460256
|
data: unknown()
|
|
459108
460257
|
});
|
|
459109
460258
|
LoggingMessageNotificationSchema = NotificationSchema.extend({
|
|
459110
|
-
method:
|
|
460259
|
+
method: literal2("notifications/message"),
|
|
459111
460260
|
params: LoggingMessageNotificationParamsSchema
|
|
459112
460261
|
});
|
|
459113
460262
|
ModelHintSchema = object({
|
|
@@ -459123,7 +460272,7 @@ var init_types5 = __esm(() => {
|
|
|
459123
460272
|
mode: _enum(["auto", "required", "none"]).optional()
|
|
459124
460273
|
});
|
|
459125
460274
|
ToolResultContentSchema = object({
|
|
459126
|
-
type:
|
|
460275
|
+
type: literal2("tool_result"),
|
|
459127
460276
|
toolUseId: string3().describe("The unique identifier for the corresponding tool call."),
|
|
459128
460277
|
content: array(ContentBlockSchema).default([]),
|
|
459129
460278
|
structuredContent: object({}).loose().optional(),
|
|
@@ -459156,7 +460305,7 @@ var init_types5 = __esm(() => {
|
|
|
459156
460305
|
toolChoice: ToolChoiceSchema.optional()
|
|
459157
460306
|
});
|
|
459158
460307
|
CreateMessageRequestSchema = RequestSchema.extend({
|
|
459159
|
-
method:
|
|
460308
|
+
method: literal2("sampling/createMessage"),
|
|
459160
460309
|
params: CreateMessageRequestParamsSchema
|
|
459161
460310
|
});
|
|
459162
460311
|
CreateMessageResultSchema = ResultSchema.extend({
|
|
@@ -459172,13 +460321,13 @@ var init_types5 = __esm(() => {
|
|
|
459172
460321
|
content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)])
|
|
459173
460322
|
});
|
|
459174
460323
|
BooleanSchemaSchema = object({
|
|
459175
|
-
type:
|
|
460324
|
+
type: literal2("boolean"),
|
|
459176
460325
|
title: string3().optional(),
|
|
459177
460326
|
description: string3().optional(),
|
|
459178
460327
|
default: boolean3().optional()
|
|
459179
460328
|
});
|
|
459180
460329
|
StringSchemaSchema = object({
|
|
459181
|
-
type:
|
|
460330
|
+
type: literal2("string"),
|
|
459182
460331
|
title: string3().optional(),
|
|
459183
460332
|
description: string3().optional(),
|
|
459184
460333
|
minLength: number3().optional(),
|
|
@@ -459195,14 +460344,14 @@ var init_types5 = __esm(() => {
|
|
|
459195
460344
|
default: number3().optional()
|
|
459196
460345
|
});
|
|
459197
460346
|
UntitledSingleSelectEnumSchemaSchema = object({
|
|
459198
|
-
type:
|
|
460347
|
+
type: literal2("string"),
|
|
459199
460348
|
title: string3().optional(),
|
|
459200
460349
|
description: string3().optional(),
|
|
459201
460350
|
enum: array(string3()),
|
|
459202
460351
|
default: string3().optional()
|
|
459203
460352
|
});
|
|
459204
460353
|
TitledSingleSelectEnumSchemaSchema = object({
|
|
459205
|
-
type:
|
|
460354
|
+
type: literal2("string"),
|
|
459206
460355
|
title: string3().optional(),
|
|
459207
460356
|
description: string3().optional(),
|
|
459208
460357
|
oneOf: array(object({
|
|
@@ -459212,7 +460361,7 @@ var init_types5 = __esm(() => {
|
|
|
459212
460361
|
default: string3().optional()
|
|
459213
460362
|
});
|
|
459214
460363
|
LegacyTitledEnumSchemaSchema = object({
|
|
459215
|
-
type:
|
|
460364
|
+
type: literal2("string"),
|
|
459216
460365
|
title: string3().optional(),
|
|
459217
460366
|
description: string3().optional(),
|
|
459218
460367
|
enum: array(string3()),
|
|
@@ -459221,19 +460370,19 @@ var init_types5 = __esm(() => {
|
|
|
459221
460370
|
});
|
|
459222
460371
|
SingleSelectEnumSchemaSchema = union([UntitledSingleSelectEnumSchemaSchema, TitledSingleSelectEnumSchemaSchema]);
|
|
459223
460372
|
UntitledMultiSelectEnumSchemaSchema = object({
|
|
459224
|
-
type:
|
|
460373
|
+
type: literal2("array"),
|
|
459225
460374
|
title: string3().optional(),
|
|
459226
460375
|
description: string3().optional(),
|
|
459227
460376
|
minItems: number3().optional(),
|
|
459228
460377
|
maxItems: number3().optional(),
|
|
459229
460378
|
items: object({
|
|
459230
|
-
type:
|
|
460379
|
+
type: literal2("string"),
|
|
459231
460380
|
enum: array(string3())
|
|
459232
460381
|
}),
|
|
459233
460382
|
default: array(string3()).optional()
|
|
459234
460383
|
});
|
|
459235
460384
|
TitledMultiSelectEnumSchemaSchema = object({
|
|
459236
|
-
type:
|
|
460385
|
+
type: literal2("array"),
|
|
459237
460386
|
title: string3().optional(),
|
|
459238
460387
|
description: string3().optional(),
|
|
459239
460388
|
minItems: number3().optional(),
|
|
@@ -459250,30 +460399,30 @@ var init_types5 = __esm(() => {
|
|
|
459250
460399
|
EnumSchemaSchema = union([LegacyTitledEnumSchemaSchema, SingleSelectEnumSchemaSchema, MultiSelectEnumSchemaSchema]);
|
|
459251
460400
|
PrimitiveSchemaDefinitionSchema = union([EnumSchemaSchema, BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema]);
|
|
459252
460401
|
ElicitRequestFormParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
459253
|
-
mode:
|
|
460402
|
+
mode: literal2("form").optional(),
|
|
459254
460403
|
message: string3(),
|
|
459255
460404
|
requestedSchema: object({
|
|
459256
|
-
type:
|
|
460405
|
+
type: literal2("object"),
|
|
459257
460406
|
properties: record(string3(), PrimitiveSchemaDefinitionSchema),
|
|
459258
460407
|
required: array(string3()).optional()
|
|
459259
460408
|
})
|
|
459260
460409
|
});
|
|
459261
460410
|
ElicitRequestURLParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
459262
|
-
mode:
|
|
460411
|
+
mode: literal2("url"),
|
|
459263
460412
|
message: string3(),
|
|
459264
460413
|
elicitationId: string3(),
|
|
459265
460414
|
url: string3().url()
|
|
459266
460415
|
});
|
|
459267
460416
|
ElicitRequestParamsSchema = union([ElicitRequestFormParamsSchema, ElicitRequestURLParamsSchema]);
|
|
459268
460417
|
ElicitRequestSchema = RequestSchema.extend({
|
|
459269
|
-
method:
|
|
460418
|
+
method: literal2("elicitation/create"),
|
|
459270
460419
|
params: ElicitRequestParamsSchema
|
|
459271
460420
|
});
|
|
459272
460421
|
ElicitationCompleteNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
459273
460422
|
elicitationId: string3()
|
|
459274
460423
|
});
|
|
459275
460424
|
ElicitationCompleteNotificationSchema = NotificationSchema.extend({
|
|
459276
|
-
method:
|
|
460425
|
+
method: literal2("notifications/elicitation/complete"),
|
|
459277
460426
|
params: ElicitationCompleteNotificationParamsSchema
|
|
459278
460427
|
});
|
|
459279
460428
|
ElicitResultSchema = ResultSchema.extend({
|
|
@@ -459281,11 +460430,11 @@ var init_types5 = __esm(() => {
|
|
|
459281
460430
|
content: preprocess((val) => val === null ? undefined : val, record(string3(), union([string3(), number3(), boolean3(), array(string3())])).optional())
|
|
459282
460431
|
});
|
|
459283
460432
|
ResourceTemplateReferenceSchema = object({
|
|
459284
|
-
type:
|
|
460433
|
+
type: literal2("ref/resource"),
|
|
459285
460434
|
uri: string3()
|
|
459286
460435
|
});
|
|
459287
460436
|
PromptReferenceSchema = object({
|
|
459288
|
-
type:
|
|
460437
|
+
type: literal2("ref/prompt"),
|
|
459289
460438
|
name: string3()
|
|
459290
460439
|
});
|
|
459291
460440
|
CompleteRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
@@ -459299,7 +460448,7 @@ var init_types5 = __esm(() => {
|
|
|
459299
460448
|
}).optional()
|
|
459300
460449
|
});
|
|
459301
460450
|
CompleteRequestSchema = RequestSchema.extend({
|
|
459302
|
-
method:
|
|
460451
|
+
method: literal2("completion/complete"),
|
|
459303
460452
|
params: CompleteRequestParamsSchema
|
|
459304
460453
|
});
|
|
459305
460454
|
CompleteResultSchema = ResultSchema.extend({
|
|
@@ -459315,14 +460464,14 @@ var init_types5 = __esm(() => {
|
|
|
459315
460464
|
_meta: record(string3(), unknown()).optional()
|
|
459316
460465
|
});
|
|
459317
460466
|
ListRootsRequestSchema = RequestSchema.extend({
|
|
459318
|
-
method:
|
|
460467
|
+
method: literal2("roots/list"),
|
|
459319
460468
|
params: BaseRequestParamsSchema.optional()
|
|
459320
460469
|
});
|
|
459321
460470
|
ListRootsResultSchema = ResultSchema.extend({
|
|
459322
460471
|
roots: array(RootSchema)
|
|
459323
460472
|
});
|
|
459324
460473
|
RootsListChangedNotificationSchema = NotificationSchema.extend({
|
|
459325
|
-
method:
|
|
460474
|
+
method: literal2("notifications/roots/list_changed"),
|
|
459326
460475
|
params: NotificationsParamsSchema.optional()
|
|
459327
460476
|
});
|
|
459328
460477
|
ClientRequestSchema = union([
|