@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
|
@@ -12805,7 +12805,7 @@ function errorMapping(error) {
|
|
|
12805
12805
|
function errorReason(error) {
|
|
12806
12806
|
return resolve(errorMapping(error).reason, error);
|
|
12807
12807
|
}
|
|
12808
|
-
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;
|
|
12808
|
+
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;
|
|
12809
12809
|
var init_errors2 = __esm(() => {
|
|
12810
12810
|
init_constants();
|
|
12811
12811
|
init_logger();
|
|
@@ -13090,6 +13090,15 @@ var init_errors2 = __esm(() => {
|
|
|
13090
13090
|
super(message);
|
|
13091
13091
|
}
|
|
13092
13092
|
};
|
|
13093
|
+
ContainerNotFoundError = class ContainerNotFoundError extends Error {
|
|
13094
|
+
get kind() {
|
|
13095
|
+
return "container_not_found";
|
|
13096
|
+
}
|
|
13097
|
+
constructor(message) {
|
|
13098
|
+
super(message);
|
|
13099
|
+
this.name = "ContainerNotFoundError";
|
|
13100
|
+
}
|
|
13101
|
+
};
|
|
13093
13102
|
StorageDestinationNotFoundError = class StorageDestinationNotFoundError extends Error {
|
|
13094
13103
|
get kind() {
|
|
13095
13104
|
return "storage_destination_not_found";
|
|
@@ -13489,6 +13498,7 @@ var init_errors2 = __esm(() => {
|
|
|
13489
13498
|
result_truncated: ResultTruncatedError,
|
|
13490
13499
|
result_shape: ResultShapeError,
|
|
13491
13500
|
destination_not_found: DestinationNotFoundError,
|
|
13501
|
+
container_not_found: ContainerNotFoundError,
|
|
13492
13502
|
storage_destination_not_found: StorageDestinationNotFoundError,
|
|
13493
13503
|
storage_catalog_not_found: StorageCatalogNotFoundError,
|
|
13494
13504
|
connection_auth: ConnectionAuthError,
|
|
@@ -13694,6 +13704,7 @@ var init_errors2 = __esm(() => {
|
|
|
13694
13704
|
},
|
|
13695
13705
|
storage_catalog_not_found: { status: 404, mcp: { advice: "internal" } },
|
|
13696
13706
|
destination_not_found: { status: 422, mcp: { advice: "internal" } },
|
|
13707
|
+
container_not_found: { status: 422, mcp: { advice: "internal" } },
|
|
13697
13708
|
connection_auth: {
|
|
13698
13709
|
status: 424,
|
|
13699
13710
|
message: GENERIC_AUTH_MESSAGE,
|
|
@@ -29819,7 +29830,8 @@ var init_dialect = __esm(() => {
|
|
|
29819
29830
|
catalogHidesTables: false,
|
|
29820
29831
|
stringCollation: undefined,
|
|
29821
29832
|
ungroupableTypes: undefined,
|
|
29822
|
-
binary64Types: undefined
|
|
29833
|
+
binary64Types: undefined,
|
|
29834
|
+
containerCatalog: undefined
|
|
29823
29835
|
});
|
|
29824
29836
|
CAPABILITIES = {
|
|
29825
29837
|
duckdb: Object.freeze({
|
|
@@ -29838,10 +29850,12 @@ var init_dialect = __esm(() => {
|
|
|
29838
29850
|
utcSessions: true,
|
|
29839
29851
|
leafBudget: 120,
|
|
29840
29852
|
stringCollation: "instance",
|
|
29841
|
-
binary64Types: ["DOUBLE", "FLOAT8"]
|
|
29853
|
+
binary64Types: ["DOUBLE", "FLOAT8"],
|
|
29854
|
+
containerCatalog: "duckdb_schemas"
|
|
29842
29855
|
}),
|
|
29843
29856
|
postgres: Object.freeze({
|
|
29844
29857
|
...NONE,
|
|
29858
|
+
containerCatalog: "pg_namespace",
|
|
29845
29859
|
stringCollation: "column",
|
|
29846
29860
|
passthroughNumericAsDouble: true,
|
|
29847
29861
|
incrementalSourceRange: true,
|
|
@@ -29887,6 +29901,7 @@ var init_dialect = __esm(() => {
|
|
|
29887
29901
|
onlyBigIntegerType: "INT64",
|
|
29888
29902
|
leafBudget: 120,
|
|
29889
29903
|
stringCollation: "dataset",
|
|
29904
|
+
containerCatalog: "dataset",
|
|
29890
29905
|
ungroupableTypes: {
|
|
29891
29906
|
malloy: ["json", "array", "record"],
|
|
29892
29907
|
native: ["geography"]
|
|
@@ -29894,6 +29909,7 @@ var init_dialect = __esm(() => {
|
|
|
29894
29909
|
}),
|
|
29895
29910
|
snowflake: Object.freeze({
|
|
29896
29911
|
...NONE,
|
|
29912
|
+
containerCatalog: "schemata",
|
|
29897
29913
|
decodedTablePath: true,
|
|
29898
29914
|
catalogHidesTables: true,
|
|
29899
29915
|
incrementalSourceRange: true,
|
|
@@ -33735,7 +33751,46 @@ function namesServedCopyAlias(text) {
|
|
|
33735
33751
|
function withoutServedCopyAliases(text) {
|
|
33736
33752
|
return text.replace(new RegExp(`'?__publisher_storage_${TOKEN}_\\d+'?`, "g"), "the storage destination");
|
|
33737
33753
|
}
|
|
33738
|
-
function
|
|
33754
|
+
function destinationOfAlias(name) {
|
|
33755
|
+
return destinationsByAlias.get(name);
|
|
33756
|
+
}
|
|
33757
|
+
function servedConnectionLabel(name) {
|
|
33758
|
+
const destination = destinationsByAlias.get(name);
|
|
33759
|
+
return destination !== undefined ? `storage destination '${destination}'` : `connection '${name}'`;
|
|
33760
|
+
}
|
|
33761
|
+
function underAlias(connection, alias) {
|
|
33762
|
+
let views = aliasedViews.get(connection);
|
|
33763
|
+
if (!views) {
|
|
33764
|
+
views = new Map;
|
|
33765
|
+
aliasedViews.set(connection, views);
|
|
33766
|
+
}
|
|
33767
|
+
const known = views.get(alias);
|
|
33768
|
+
if (known)
|
|
33769
|
+
return known;
|
|
33770
|
+
const view = new Proxy(connection, {
|
|
33771
|
+
get(target, prop) {
|
|
33772
|
+
if (prop === "name")
|
|
33773
|
+
return alias;
|
|
33774
|
+
if (prop === "fetchSchemaForTables") {
|
|
33775
|
+
return async (...args) => {
|
|
33776
|
+
const fetched = await target.fetchSchemaForTables(...args);
|
|
33777
|
+
return {
|
|
33778
|
+
...fetched,
|
|
33779
|
+
schemas: Object.fromEntries(Object.entries(fetched.schemas).map(([key, def]) => [
|
|
33780
|
+
key,
|
|
33781
|
+
{ ...def, connection: alias }
|
|
33782
|
+
]))
|
|
33783
|
+
};
|
|
33784
|
+
};
|
|
33785
|
+
}
|
|
33786
|
+
const value = Reflect.get(target, prop, target);
|
|
33787
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
33788
|
+
}
|
|
33789
|
+
});
|
|
33790
|
+
views.set(alias, view);
|
|
33791
|
+
return view;
|
|
33792
|
+
}
|
|
33793
|
+
function servedCopyConfig(packageConfig, destinations, allowed, tablesUnderAlias = new Set) {
|
|
33739
33794
|
const base = toMalloyConfig(packageConfig);
|
|
33740
33795
|
const config = new MalloyConfig2({ connections: {} });
|
|
33741
33796
|
config.wrapConnections(() => ({
|
|
@@ -33746,7 +33801,8 @@ function servedCopyConfig(packageConfig, destinations, allowed) {
|
|
|
33746
33801
|
if (!allowed.has(destination)) {
|
|
33747
33802
|
throw new Error(`A storage destination is not available to this served copy`);
|
|
33748
33803
|
}
|
|
33749
|
-
|
|
33804
|
+
const connection = await destinations.connections.lookupConnection(destination);
|
|
33805
|
+
return tablesUnderAlias.has(destination) ? underAlias(connection, name) : connection;
|
|
33750
33806
|
}
|
|
33751
33807
|
}
|
|
33752
33808
|
return base.connections.lookupConnection(name);
|
|
@@ -33754,16 +33810,35 @@ function servedCopyConfig(packageConfig, destinations, allowed) {
|
|
|
33754
33810
|
}));
|
|
33755
33811
|
return config;
|
|
33756
33812
|
}
|
|
33757
|
-
var TOKEN, aliases, destinationsByAlias;
|
|
33813
|
+
var TOKEN, aliases, destinationsByAlias, aliasedViews;
|
|
33758
33814
|
var init_served_copy_config = __esm(() => {
|
|
33759
33815
|
init_model_runtime();
|
|
33760
33816
|
TOKEN = randomBytes(12).toString("hex");
|
|
33761
33817
|
aliases = new Map;
|
|
33762
33818
|
destinationsByAlias = new Map;
|
|
33819
|
+
aliasedViews = new WeakMap;
|
|
33763
33820
|
});
|
|
33764
33821
|
|
|
33765
33822
|
// src/service/materialization/text/cross_connection_text.ts
|
|
33766
33823
|
import { MalloyError as MalloyError3 } from "@malloydata/malloy";
|
|
33824
|
+
function refusedJoinConnections(message) {
|
|
33825
|
+
const named = /which is on connection '([^']*)', into a source on connection '([^']*)'/.exec(message ?? "");
|
|
33826
|
+
return named ? { joined: named[1], into: named[2] } : undefined;
|
|
33827
|
+
}
|
|
33828
|
+
function refusedJoinPairs(error) {
|
|
33829
|
+
if (!isCrossConnectionRefusal(error))
|
|
33830
|
+
return;
|
|
33831
|
+
const pairs = [];
|
|
33832
|
+
for (const p of errorProblems(error) ?? []) {
|
|
33833
|
+
if (p.code !== JOIN_CONNECTION_MISMATCH)
|
|
33834
|
+
continue;
|
|
33835
|
+
const pair = refusedJoinConnections(p.message);
|
|
33836
|
+
if (!pair)
|
|
33837
|
+
return;
|
|
33838
|
+
pairs.push(pair);
|
|
33839
|
+
}
|
|
33840
|
+
return pairs;
|
|
33841
|
+
}
|
|
33767
33842
|
function isJoinConnectionMismatch(code) {
|
|
33768
33843
|
return code === JOIN_CONNECTION_MISMATCH;
|
|
33769
33844
|
}
|
|
@@ -33880,10 +33955,12 @@ async function leaveOut(args, escalated) {
|
|
|
33880
33955
|
continue;
|
|
33881
33956
|
}
|
|
33882
33957
|
cuts.push(cut);
|
|
33958
|
+
const connections = refused ? refusedJoinConnections(p.message) : undefined;
|
|
33883
33959
|
leftOut.push({
|
|
33884
33960
|
url,
|
|
33885
33961
|
...cut.left,
|
|
33886
33962
|
crossConnection: refused,
|
|
33963
|
+
...connections ? { connections } : {},
|
|
33887
33964
|
...cut !== own && own?.left.keyword.startsWith("join_") ? { join: own.left.name } : {}
|
|
33888
33965
|
});
|
|
33889
33966
|
}
|
|
@@ -37348,6 +37425,436 @@ var init_query_walks = __esm(() => {
|
|
|
37348
37425
|
walks = new Map;
|
|
37349
37426
|
});
|
|
37350
37427
|
|
|
37428
|
+
// src/service/materialization/domain/same_catalog_build.ts
|
|
37429
|
+
function isSameCatalog(source, destination) {
|
|
37430
|
+
const a = source?.type === "ducklake" ? source.ducklakeConnection : undefined;
|
|
37431
|
+
const b = destination?.type === "ducklake" ? destination.ducklakeConnection : undefined;
|
|
37432
|
+
if (!a || !b)
|
|
37433
|
+
return false;
|
|
37434
|
+
const pa = a.catalog?.postgresConnection;
|
|
37435
|
+
const pb = b.catalog?.postgresConnection;
|
|
37436
|
+
if (!pa || !pb)
|
|
37437
|
+
return false;
|
|
37438
|
+
const path = (url) => (url ?? "").replace(/\/+$/, "");
|
|
37439
|
+
const pathA = path(a.storage?.bucketUrl);
|
|
37440
|
+
const pathB = path(b.storage?.bucketUrl);
|
|
37441
|
+
return !!pa.host && pa.host === pb.host && (pa.port ?? 5432) === (pb.port ?? 5432) && !!pa.databaseName && pa.databaseName === pb.databaseName && (a.catalog.metadataSchema ?? "") === (b.catalog.metadataSchema ?? "") && (pathA === "" || pathB === "" || pathA === pathB);
|
|
37442
|
+
}
|
|
37443
|
+
function carriesAuthorSql(def) {
|
|
37444
|
+
return authorSqlCause(def) !== undefined;
|
|
37445
|
+
}
|
|
37446
|
+
function authorSqlCause(def) {
|
|
37447
|
+
const seen = new Set;
|
|
37448
|
+
const walk = (node, depth, frames) => {
|
|
37449
|
+
if (depth > MAX_DEPTH3)
|
|
37450
|
+
return { found: UNREADABLE2, frames };
|
|
37451
|
+
if (node === null || typeof node !== "object")
|
|
37452
|
+
return;
|
|
37453
|
+
if (seen.has(node))
|
|
37454
|
+
return;
|
|
37455
|
+
seen.add(node);
|
|
37456
|
+
if (Array.isArray(node)) {
|
|
37457
|
+
for (const child of node) {
|
|
37458
|
+
const hit = walk(child, depth + 1, frames);
|
|
37459
|
+
if (hit)
|
|
37460
|
+
return hit;
|
|
37461
|
+
}
|
|
37462
|
+
return;
|
|
37463
|
+
}
|
|
37464
|
+
const record = node;
|
|
37465
|
+
if (typeof record.join === "string") {
|
|
37466
|
+
frames = [
|
|
37467
|
+
...frames,
|
|
37468
|
+
{
|
|
37469
|
+
kind: "join",
|
|
37470
|
+
as: String(record.as ?? record.name ?? ""),
|
|
37471
|
+
source: sourceNameOf(record)
|
|
37472
|
+
}
|
|
37473
|
+
];
|
|
37474
|
+
}
|
|
37475
|
+
if (record.type === "sql_select") {
|
|
37476
|
+
return { found: { kind: "sql_source" }, frames };
|
|
37477
|
+
}
|
|
37478
|
+
if (record.node === "genericSQLExpr") {
|
|
37479
|
+
return { found: { kind: "sql_expression" }, frames };
|
|
37480
|
+
}
|
|
37481
|
+
if (record.type === "table" && typeof record.tablePath === "string" && !CATALOG_TABLE_PATH.test(record.tablePath)) {
|
|
37482
|
+
return {
|
|
37483
|
+
found: { kind: "file_table", path: record.tablePath },
|
|
37484
|
+
frames
|
|
37485
|
+
};
|
|
37486
|
+
}
|
|
37487
|
+
for (const [key, child] of Object.entries(record)) {
|
|
37488
|
+
if (record.node === "function_call" && key === "overload")
|
|
37489
|
+
continue;
|
|
37490
|
+
const hit = key === "fields" && Array.isArray(child) ? walkFields(child, depth + 1, frames) : walk(child, depth + 1, key === "structRef" && child !== null && typeof child === "object" ? [
|
|
37491
|
+
...frames,
|
|
37492
|
+
{
|
|
37493
|
+
kind: "reads",
|
|
37494
|
+
source: sourceNameOf(child)
|
|
37495
|
+
}
|
|
37496
|
+
] : frames);
|
|
37497
|
+
if (hit)
|
|
37498
|
+
return hit;
|
|
37499
|
+
}
|
|
37500
|
+
return;
|
|
37501
|
+
};
|
|
37502
|
+
const walkFields = (fields, depth, frames) => {
|
|
37503
|
+
if (depth > MAX_DEPTH3)
|
|
37504
|
+
return { found: UNREADABLE2, frames };
|
|
37505
|
+
if (seen.has(fields))
|
|
37506
|
+
return;
|
|
37507
|
+
seen.add(fields);
|
|
37508
|
+
for (const field of fields) {
|
|
37509
|
+
const f = field;
|
|
37510
|
+
const named = f !== null && typeof f === "object" && typeof f.name === "string" && typeof f.join !== "string";
|
|
37511
|
+
const hit = walk(field, depth + 1, named ? [...frames, { kind: "field", name: String(f.name) }] : frames);
|
|
37512
|
+
if (hit)
|
|
37513
|
+
return hit;
|
|
37514
|
+
}
|
|
37515
|
+
return;
|
|
37516
|
+
};
|
|
37517
|
+
try {
|
|
37518
|
+
if (def === null || typeof def !== "object")
|
|
37519
|
+
return describe([], UNREADABLE2);
|
|
37520
|
+
const hit = walk(def, 0, []);
|
|
37521
|
+
return hit ? describe(hit.frames, hit.found) : undefined;
|
|
37522
|
+
} catch {
|
|
37523
|
+
return describe([], UNREADABLE2);
|
|
37524
|
+
}
|
|
37525
|
+
}
|
|
37526
|
+
function sourceNameOf(record) {
|
|
37527
|
+
const id = typeof record.sourceID === "string" ? record.sourceID : "";
|
|
37528
|
+
const name = typeof record.name === "string" ? record.name : "";
|
|
37529
|
+
return id.split("@")[0] || (name.startsWith("sql://") ? "" : name);
|
|
37530
|
+
}
|
|
37531
|
+
function describe(frames, found) {
|
|
37532
|
+
if (found.kind === "unreadable") {
|
|
37533
|
+
return "its definition could not be read to check for SQL its author wrote";
|
|
37534
|
+
}
|
|
37535
|
+
frames = frames.filter((frame, i) => frame.kind !== "reads" || i === frames.length - 1 && found.kind !== "sql_expression");
|
|
37536
|
+
const parts = [];
|
|
37537
|
+
let lead = true;
|
|
37538
|
+
for (const frame of frames) {
|
|
37539
|
+
const possessive = lead ? "its" : "whose";
|
|
37540
|
+
const subject = lead ? "it" : "which";
|
|
37541
|
+
lead = false;
|
|
37542
|
+
if (frame.kind === "join") {
|
|
37543
|
+
parts.push(`${possessive} join '${frame.as}'` + (frame.source ? ` reads source '${frame.source}'` : ""));
|
|
37544
|
+
} else if (frame.kind === "reads") {
|
|
37545
|
+
parts.push(frame.source ? `${subject} reads source '${frame.source}'` : `${subject} reads a source`);
|
|
37546
|
+
} else {
|
|
37547
|
+
parts.push(`${possessive} field '${frame.name}'`);
|
|
37548
|
+
}
|
|
37549
|
+
}
|
|
37550
|
+
const last = frames[frames.length - 1];
|
|
37551
|
+
const subject = frames.length === 0 ? "it" : ", which";
|
|
37552
|
+
const what = found.kind === "sql_source" ? `${subject} is an .sql() source` : found.kind === "file_table" ? `${subject} reads '${found.path.replace(/^'|'$/g, "")}' as a table` : last?.kind === "field" ? " uses a sql_* expression" : `${subject} uses a sql_* expression`;
|
|
37553
|
+
return (parts.join(", ") + what).replace(/^ /, "");
|
|
37554
|
+
}
|
|
37555
|
+
var CATALOG_TABLE_PATH, MAX_DEPTH3 = 200, UNREADABLE2;
|
|
37556
|
+
var init_same_catalog_build = __esm(() => {
|
|
37557
|
+
CATALOG_TABLE_PATH = /^[A-Za-z_][A-Za-z0-9_$]*(\.[A-Za-z_][A-Za-z0-9_$]*)*$/;
|
|
37558
|
+
UNREADABLE2 = { kind: "unreadable" };
|
|
37559
|
+
});
|
|
37560
|
+
|
|
37561
|
+
// src/service/materialization/serve/same_catalog_reads.ts
|
|
37562
|
+
function destinationTablePath(path, move) {
|
|
37563
|
+
const parts = path.split(".");
|
|
37564
|
+
if (!PLAIN.test(move.destination) || !parts.every((p) => PLAIN.test(p))) {
|
|
37565
|
+
return;
|
|
37566
|
+
}
|
|
37567
|
+
const self2 = move.connection.toLowerCase();
|
|
37568
|
+
const readable = (s) => move.schemas.has(s.toLowerCase());
|
|
37569
|
+
const at = (schema, table) => `${move.destination}.${schema}.${table}`;
|
|
37570
|
+
if (parts.length === 1)
|
|
37571
|
+
return at("main", parts[0]);
|
|
37572
|
+
if (parts.length === 2) {
|
|
37573
|
+
const [first, table] = parts;
|
|
37574
|
+
if (first.toLowerCase() === self2) {
|
|
37575
|
+
return readable(first) ? undefined : at("main", table);
|
|
37576
|
+
}
|
|
37577
|
+
return readable(first) ? at(first, table) : undefined;
|
|
37578
|
+
}
|
|
37579
|
+
if (parts.length === 3) {
|
|
37580
|
+
const [catalog, schema, table] = parts;
|
|
37581
|
+
return catalog.toLowerCase() === self2 && readable(schema) ? at(schema, table) : undefined;
|
|
37582
|
+
}
|
|
37583
|
+
return;
|
|
37584
|
+
}
|
|
37585
|
+
function literalValue(token) {
|
|
37586
|
+
const m = /^(['"])([^'"\\]*)\1$/.exec(token?.text ?? "");
|
|
37587
|
+
return m ? m[2] : undefined;
|
|
37588
|
+
}
|
|
37589
|
+
function namesConnection(token, name) {
|
|
37590
|
+
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;
|
|
37591
|
+
}
|
|
37592
|
+
function readThroughDestination(text, move) {
|
|
37593
|
+
const tokens = lexAll(text);
|
|
37594
|
+
if (!tokens)
|
|
37595
|
+
return;
|
|
37596
|
+
const edits = [];
|
|
37597
|
+
const paths = [];
|
|
37598
|
+
for (let k = 0;k < tokens.length; k++) {
|
|
37599
|
+
const t = tokens[k];
|
|
37600
|
+
if (!namesConnection(t, move.connection))
|
|
37601
|
+
continue;
|
|
37602
|
+
if (tokens[k - 1]?.text === ".")
|
|
37603
|
+
continue;
|
|
37604
|
+
if (tokens[k + 1]?.text !== ".")
|
|
37605
|
+
continue;
|
|
37606
|
+
const method = tokens[k + 2];
|
|
37607
|
+
if (method?.kind !== "word")
|
|
37608
|
+
continue;
|
|
37609
|
+
if (method.text !== "table")
|
|
37610
|
+
return;
|
|
37611
|
+
const value = literalValue(tokens[k + 4]);
|
|
37612
|
+
if (tokens[k + 3]?.text !== "(" || value === undefined || tokens[k + 5]?.text !== ")") {
|
|
37613
|
+
return;
|
|
37614
|
+
}
|
|
37615
|
+
const moved = destinationTablePath(value, move);
|
|
37616
|
+
if (moved === undefined)
|
|
37617
|
+
return;
|
|
37618
|
+
paths.push(value);
|
|
37619
|
+
edits.push({
|
|
37620
|
+
start: t.start,
|
|
37621
|
+
end: tokens[k + 5].end,
|
|
37622
|
+
text: `${identifier(move.alias)}.table(${stringLiteral(moved)})`
|
|
37623
|
+
});
|
|
37624
|
+
k += 5;
|
|
37625
|
+
}
|
|
37626
|
+
let out = text;
|
|
37627
|
+
for (const e of edits.reverse()) {
|
|
37628
|
+
out = out.slice(0, e.start) + e.text + out.slice(e.end);
|
|
37629
|
+
}
|
|
37630
|
+
return { text: out, paths };
|
|
37631
|
+
}
|
|
37632
|
+
async function sameCatalogMoves(error, ports) {
|
|
37633
|
+
const pairs = refusedJoinPairs(error);
|
|
37634
|
+
if (!pairs?.length)
|
|
37635
|
+
return;
|
|
37636
|
+
const moves = new Map;
|
|
37637
|
+
for (const { joined, into } of pairs) {
|
|
37638
|
+
const intoDestination = destinationOfAlias(into);
|
|
37639
|
+
const joinedDestination = destinationOfAlias(joined);
|
|
37640
|
+
const [connection, alias, destination] = intoDestination !== undefined && joinedDestination === undefined ? [joined, into, intoDestination] : joinedDestination !== undefined && intoDestination === undefined ? [into, joined, joinedDestination] : [];
|
|
37641
|
+
if (!connection || !alias || !destination)
|
|
37642
|
+
return;
|
|
37643
|
+
const known = moves.get(connection);
|
|
37644
|
+
if (known) {
|
|
37645
|
+
if (known.alias !== alias)
|
|
37646
|
+
return;
|
|
37647
|
+
continue;
|
|
37648
|
+
}
|
|
37649
|
+
const schemas = await ports.scope(connection, alias);
|
|
37650
|
+
if (!schemas)
|
|
37651
|
+
return;
|
|
37652
|
+
moves.set(connection, { connection, alias, destination, schemas });
|
|
37653
|
+
}
|
|
37654
|
+
return [...moves.values()];
|
|
37655
|
+
}
|
|
37656
|
+
function movedAuthorSqlCause(modelDef, connections, rerooted) {
|
|
37657
|
+
const { contents } = authorModelReachContext(modelDef);
|
|
37658
|
+
for (const [name, def] of Object.entries(contents)) {
|
|
37659
|
+
const d = def;
|
|
37660
|
+
if (typeof d.connection !== "string" || !connections.has(d.connection)) {
|
|
37661
|
+
continue;
|
|
37662
|
+
}
|
|
37663
|
+
if (typeof d.sourceID === "string" && rerooted.has(d.sourceID)) {
|
|
37664
|
+
for (const field of Array.isArray(d.fields) ? d.fields : []) {
|
|
37665
|
+
const f = field;
|
|
37666
|
+
if (f.join === undefined)
|
|
37667
|
+
continue;
|
|
37668
|
+
const cause = authorSqlCause(field);
|
|
37669
|
+
if (cause)
|
|
37670
|
+
return `the join '${String(f.name)}' of '${name}': ${cause}`;
|
|
37671
|
+
}
|
|
37672
|
+
continue;
|
|
37673
|
+
}
|
|
37674
|
+
const cause = authorSqlCause(def);
|
|
37675
|
+
if (cause)
|
|
37676
|
+
return `the source '${name}': ${cause}`;
|
|
37677
|
+
}
|
|
37678
|
+
return;
|
|
37679
|
+
}
|
|
37680
|
+
function declaringFiles(modelDef, connections) {
|
|
37681
|
+
const { contents } = authorModelReachContext(modelDef);
|
|
37682
|
+
const urls = new Set;
|
|
37683
|
+
for (const def of Object.values(contents)) {
|
|
37684
|
+
const d = def;
|
|
37685
|
+
if (typeof d.connection === "string" && connections.has(d.connection) && typeof d.location?.url === "string") {
|
|
37686
|
+
urls.add(d.location.url);
|
|
37687
|
+
}
|
|
37688
|
+
}
|
|
37689
|
+
return [...urls];
|
|
37690
|
+
}
|
|
37691
|
+
async function readSameCatalogThroughDestination(args) {
|
|
37692
|
+
const moves = await sameCatalogMoves(args.error, args.ports);
|
|
37693
|
+
if (!moves) {
|
|
37694
|
+
return {
|
|
37695
|
+
declined: "a refused join is not into a managed connection's own catalog"
|
|
37696
|
+
};
|
|
37697
|
+
}
|
|
37698
|
+
const names = new Set(moves.map((m) => m.connection));
|
|
37699
|
+
const sql = movedAuthorSqlCause(args.modelDef, names, args.rerooted);
|
|
37700
|
+
if (sql)
|
|
37701
|
+
return { declined: `${sql}, which carries author SQL` };
|
|
37702
|
+
const urls = new Set([
|
|
37703
|
+
...args.files.keys(),
|
|
37704
|
+
...declaringFiles(args.modelDef, names)
|
|
37705
|
+
]);
|
|
37706
|
+
const out = new Map(args.files);
|
|
37707
|
+
for (const move of moves) {
|
|
37708
|
+
const paths = [];
|
|
37709
|
+
for (const url of urls) {
|
|
37710
|
+
const text = out.get(url) ?? args.readText(url);
|
|
37711
|
+
if (text === undefined)
|
|
37712
|
+
return { declined: "a file it cannot read" };
|
|
37713
|
+
const read = readThroughDestination(text, move);
|
|
37714
|
+
if (!read) {
|
|
37715
|
+
return {
|
|
37716
|
+
declined: `connection '${move.connection}' is named other than in a plain .table() it can place`
|
|
37717
|
+
};
|
|
37718
|
+
}
|
|
37719
|
+
if (read.paths.length === 0)
|
|
37720
|
+
continue;
|
|
37721
|
+
paths.push(...read.paths);
|
|
37722
|
+
out.set(url, read.text);
|
|
37723
|
+
}
|
|
37724
|
+
for (const path of paths) {
|
|
37725
|
+
const refused = await args.ports.pathRefusal(path, move.connection, move.schemas);
|
|
37726
|
+
if (refused !== undefined) {
|
|
37727
|
+
return {
|
|
37728
|
+
declined: `table '${path}' is outside the connection's scope`
|
|
37729
|
+
};
|
|
37730
|
+
}
|
|
37731
|
+
}
|
|
37732
|
+
const tables = [...new Set(paths)].map((path) => {
|
|
37733
|
+
const [catalog, schema, table] = destinationTablePath(path, move).split(".");
|
|
37734
|
+
return [catalog, schema, table];
|
|
37735
|
+
});
|
|
37736
|
+
if (!await args.ports.baseTables(move.alias, tables)) {
|
|
37737
|
+
return { declined: "a table it reads is not a base table" };
|
|
37738
|
+
}
|
|
37739
|
+
}
|
|
37740
|
+
return {
|
|
37741
|
+
files: out,
|
|
37742
|
+
destinations: new Set(moves.map((m) => m.destination))
|
|
37743
|
+
};
|
|
37744
|
+
}
|
|
37745
|
+
var PLAIN;
|
|
37746
|
+
var init_same_catalog_reads = __esm(() => {
|
|
37747
|
+
init_malloy_lexer_core();
|
|
37748
|
+
init_malloy_text();
|
|
37749
|
+
init_same_catalog_build();
|
|
37750
|
+
init_author_model();
|
|
37751
|
+
init_cross_connection_text();
|
|
37752
|
+
init_served_copy_config();
|
|
37753
|
+
PLAIN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
37754
|
+
});
|
|
37755
|
+
|
|
37756
|
+
// src/service/connection_type.ts
|
|
37757
|
+
function normalizeReadableSchemas(list) {
|
|
37758
|
+
const names = [
|
|
37759
|
+
...new Set(Array.isArray(list) ? list.filter((name) => typeof name === "string") : [])
|
|
37760
|
+
].filter((name) => name !== "main").sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
37761
|
+
return names.length > 0 ? names : undefined;
|
|
37762
|
+
}
|
|
37763
|
+
function managedSchemas(readableSchemas) {
|
|
37764
|
+
return new Set([
|
|
37765
|
+
"main",
|
|
37766
|
+
...normalizeReadableSchemas(readableSchemas) ?? []
|
|
37767
|
+
]);
|
|
37768
|
+
}
|
|
37769
|
+
function managedOverrideOf(connection) {
|
|
37770
|
+
const name = connection.name;
|
|
37771
|
+
return typeof name === "string" && managedOverrides.some((layer) => layer.has(name));
|
|
37772
|
+
}
|
|
37773
|
+
function overrideOf(connection) {
|
|
37774
|
+
const name = connection.name;
|
|
37775
|
+
if (typeof name !== "string")
|
|
37776
|
+
return;
|
|
37777
|
+
for (let i = overrides.length - 1;i >= 0; i--) {
|
|
37778
|
+
const type = overrides[i].get(name);
|
|
37779
|
+
if (type !== undefined)
|
|
37780
|
+
return type;
|
|
37781
|
+
}
|
|
37782
|
+
return;
|
|
37783
|
+
}
|
|
37784
|
+
function recordConnectionType(connection, type, options = {}) {
|
|
37785
|
+
const recordedType = overrideOf(connection) ?? type;
|
|
37786
|
+
if (recordedType)
|
|
37787
|
+
recorded.set(connection, recordedType);
|
|
37788
|
+
if (options.config)
|
|
37789
|
+
configs.set(connection, options.config);
|
|
37790
|
+
if (options.managed === true || managedOverrideOf(connection)) {
|
|
37791
|
+
managed.set(connection, options.schemas ?? MAIN_ONLY);
|
|
37792
|
+
}
|
|
37793
|
+
return connection;
|
|
37794
|
+
}
|
|
37795
|
+
function connectionConfigOf(connection) {
|
|
37796
|
+
return connection ? configs.get(connection) : undefined;
|
|
37797
|
+
}
|
|
37798
|
+
function isManagedConnection(connection) {
|
|
37799
|
+
return !!connection && managed.has(connection);
|
|
37800
|
+
}
|
|
37801
|
+
function managedSchemasOf(connection) {
|
|
37802
|
+
return connection ? managed.get(connection) : undefined;
|
|
37803
|
+
}
|
|
37804
|
+
function resolveManagedConnections(connections) {
|
|
37805
|
+
return [...connections].filter(([, connection]) => managed.has(connection)).map(([name]) => name).sort();
|
|
37806
|
+
}
|
|
37807
|
+
function connectionTypeOf(connection) {
|
|
37808
|
+
return connection ? recorded.get(connection) : undefined;
|
|
37809
|
+
}
|
|
37810
|
+
function resolveConnectionTypes(connections) {
|
|
37811
|
+
const types = {};
|
|
37812
|
+
for (const [name, connection] of connections) {
|
|
37813
|
+
const type = connectionTypeOf(connection);
|
|
37814
|
+
if (type !== undefined)
|
|
37815
|
+
types[name] = type;
|
|
37816
|
+
}
|
|
37817
|
+
return types;
|
|
37818
|
+
}
|
|
37819
|
+
var recorded, managed, configs, MAIN_ONLY, overrides, managedOverrides;
|
|
37820
|
+
var init_connection_type = __esm(() => {
|
|
37821
|
+
recorded = new WeakMap;
|
|
37822
|
+
managed = new WeakMap;
|
|
37823
|
+
configs = new WeakMap;
|
|
37824
|
+
MAIN_ONLY = managedSchemas();
|
|
37825
|
+
overrides = [];
|
|
37826
|
+
managedOverrides = [];
|
|
37827
|
+
});
|
|
37828
|
+
|
|
37829
|
+
// src/service/same_catalog_destination.ts
|
|
37830
|
+
async function sameCatalogScope(config, connection, alias) {
|
|
37831
|
+
const [source, destination] = await Promise.all([
|
|
37832
|
+
config.connections.lookupConnection(connection).catch(() => {
|
|
37833
|
+
return;
|
|
37834
|
+
}),
|
|
37835
|
+
config.connections.lookupConnection(alias).catch(() => {
|
|
37836
|
+
return;
|
|
37837
|
+
})
|
|
37838
|
+
]);
|
|
37839
|
+
const schemas = managedSchemasOf(source);
|
|
37840
|
+
return schemas && isSameCatalog(connectionConfigOf(source), connectionConfigOf(destination)) ? schemas : undefined;
|
|
37841
|
+
}
|
|
37842
|
+
async function allBaseTables(config, alias, tables) {
|
|
37843
|
+
const destination = await config.connections.lookupConnection(alias);
|
|
37844
|
+
for (const [catalog, schema, table] of tables) {
|
|
37845
|
+
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}')`);
|
|
37846
|
+
const rows = result.rows;
|
|
37847
|
+
if (rows.length !== 1 || rows[0].table_type !== "BASE TABLE") {
|
|
37848
|
+
return false;
|
|
37849
|
+
}
|
|
37850
|
+
}
|
|
37851
|
+
return true;
|
|
37852
|
+
}
|
|
37853
|
+
var init_same_catalog_destination = __esm(() => {
|
|
37854
|
+
init_connection_type();
|
|
37855
|
+
init_same_catalog_build();
|
|
37856
|
+
});
|
|
37857
|
+
|
|
37351
37858
|
// src/service/materialization/serve/result_reads.ts
|
|
37352
37859
|
function nonStringType2(t) {
|
|
37353
37860
|
return typeof t === "string" && t !== "string";
|
|
@@ -38196,27 +38703,54 @@ import {
|
|
|
38196
38703
|
function servedConnectionOf(b) {
|
|
38197
38704
|
return isDatabase(b) ? b.destinationName : servedCopyAlias(b.destinationName);
|
|
38198
38705
|
}
|
|
38199
|
-
function
|
|
38706
|
+
function leftOutJoinDetail(joins) {
|
|
38707
|
+
const named = joins.map((j) => {
|
|
38708
|
+
const join = j.join ?? j.name;
|
|
38709
|
+
const source = j.declaration ?? (j.join !== undefined ? j.name : undefined);
|
|
38710
|
+
const where = source ? ` of \`${source}\`` : "";
|
|
38711
|
+
const across = j.connections ? ` (${servedConnectionLabel(j.connections.joined)} into ` + `${servedConnectionLabel(j.connections.into)})` : "";
|
|
38712
|
+
return `\`${join}\`${where}${across}`;
|
|
38713
|
+
});
|
|
38714
|
+
const subject = named.length === 0 ? "a join" : `the join${named.length === 1 ? "" : "s"} ${named.join(", ")}`;
|
|
38715
|
+
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.";
|
|
38716
|
+
}
|
|
38717
|
+
function leftOutJoinsRead(compiled, error, queryString) {
|
|
38200
38718
|
if (!compiled.leftOut?.length)
|
|
38201
|
-
return
|
|
38202
|
-
|
|
38719
|
+
return;
|
|
38720
|
+
const read = missingNamesRead(new Set(compiled.leftOut.map((l) => l.name)), error, queryString);
|
|
38721
|
+
if (read === undefined)
|
|
38722
|
+
return;
|
|
38723
|
+
const joins = compiled.leftOut.filter((l) => l.crossConnection);
|
|
38724
|
+
const direct = joins.filter((l) => read.has(l.name));
|
|
38725
|
+
return direct.length > 0 ? direct : joins;
|
|
38203
38726
|
}
|
|
38204
38727
|
function readsMissingName(names, error, queryString) {
|
|
38728
|
+
return missingNamesRead(names, error, queryString) !== undefined;
|
|
38729
|
+
}
|
|
38730
|
+
function missingNamesRead(names, error, queryString) {
|
|
38205
38731
|
if (!(error instanceof MalloyError4))
|
|
38206
|
-
return
|
|
38207
|
-
|
|
38208
|
-
|
|
38209
|
-
|
|
38210
|
-
|
|
38732
|
+
return;
|
|
38733
|
+
const read = new Set;
|
|
38734
|
+
let any = false;
|
|
38735
|
+
for (const p of error.problems) {
|
|
38736
|
+
if (p.code === undefined || !MISSING_FIELD_CODES.has(p.code))
|
|
38737
|
+
continue;
|
|
38211
38738
|
const start = p.at?.range?.start;
|
|
38212
38739
|
const offset = start ? offsetOf(queryString, start) : -1;
|
|
38213
|
-
|
|
38214
|
-
|
|
38215
|
-
|
|
38216
|
-
|
|
38217
|
-
|
|
38218
|
-
|
|
38219
|
-
|
|
38740
|
+
const path = offset < 0 ? undefined : /^[`A-Za-z0-9_.]+/.exec(queryString.slice(offset))?.[0];
|
|
38741
|
+
if (!path) {
|
|
38742
|
+
any = true;
|
|
38743
|
+
continue;
|
|
38744
|
+
}
|
|
38745
|
+
for (const part of path.split(".")) {
|
|
38746
|
+
const name = part.replace(/^`|`$/g, "");
|
|
38747
|
+
if (names.has(name)) {
|
|
38748
|
+
read.add(name);
|
|
38749
|
+
any = true;
|
|
38750
|
+
}
|
|
38751
|
+
}
|
|
38752
|
+
}
|
|
38753
|
+
return any ? read : undefined;
|
|
38220
38754
|
}
|
|
38221
38755
|
function rerootFailureKey(packagePath, modelPath, bindings, overlay) {
|
|
38222
38756
|
const hash = createHash2("sha256");
|
|
@@ -38386,8 +38920,10 @@ class ServedCopyServe {
|
|
|
38386
38920
|
try {
|
|
38387
38921
|
return await work();
|
|
38388
38922
|
} catch (error) {
|
|
38389
|
-
|
|
38390
|
-
|
|
38923
|
+
const leftOutJoins = leftOutJoinsRead(compiled, error, queryString);
|
|
38924
|
+
if (leftOutJoins) {
|
|
38925
|
+
const detail = leftOutJoinDetail(leftOutJoins);
|
|
38926
|
+
decline(`the query reads a join the served copy leaves out across connections: ${detail}`, "served_copy_cross_connection", detail);
|
|
38391
38927
|
}
|
|
38392
38928
|
const zoned = new Set([...compiled.zonedLeftOut?.values() ?? []].flatMap((n) => [
|
|
38393
38929
|
...n
|
|
@@ -39134,9 +39670,11 @@ class ServedCopyServe {
|
|
|
39134
39670
|
}));
|
|
39135
39671
|
const overlay = new Map(copy.files);
|
|
39136
39672
|
const packagePath = this.packagePath;
|
|
39137
|
-
const
|
|
39673
|
+
const packageConfig = this.packageConfig;
|
|
39674
|
+
const config = servedCopyConfig(packageConfig, destinations(), new Set(rerooted.filter((b) => !isDatabase(b)).map((b) => b.destinationName)));
|
|
39138
39675
|
const load = this.passLoader(packagePath, config);
|
|
39139
|
-
const
|
|
39676
|
+
const underAlias = this.underAliasLoader(packagePath, packageConfig, destinations, rerooted);
|
|
39677
|
+
const loaded = await this.loadCopy(state, copy, overlay, load, lift, config, underAlias);
|
|
39140
39678
|
if (loaded === "retry")
|
|
39141
39679
|
continue;
|
|
39142
39680
|
if (loaded === "failed") {
|
|
@@ -39151,6 +39689,7 @@ class ServedCopyServe {
|
|
|
39151
39689
|
};
|
|
39152
39690
|
}
|
|
39153
39691
|
const { materializer, servedDef, servedRuntime, leftOut, files } = loaded;
|
|
39692
|
+
const compiledConfig = loaded.config ?? config;
|
|
39154
39693
|
problems.push(...state.inlinedKept.filter((p) => state.candidates.some((c) => c.reroot.sourceName === p.sourceName)));
|
|
39155
39694
|
state.inlinedKept = [];
|
|
39156
39695
|
problems.push(...state.pairsDropped);
|
|
@@ -39170,7 +39709,7 @@ class ServedCopyServe {
|
|
|
39170
39709
|
materializer,
|
|
39171
39710
|
leftOut,
|
|
39172
39711
|
files,
|
|
39173
|
-
config,
|
|
39712
|
+
config: compiledConfig,
|
|
39174
39713
|
rerooted,
|
|
39175
39714
|
aliased,
|
|
39176
39715
|
throughBase
|
|
@@ -39186,6 +39725,12 @@ class ServedCopyServe {
|
|
|
39186
39725
|
problems
|
|
39187
39726
|
};
|
|
39188
39727
|
}
|
|
39728
|
+
underAliasLoader(packagePath, packageConfig, destinations, rerooted) {
|
|
39729
|
+
return (names) => {
|
|
39730
|
+
const config = servedCopyConfig(packageConfig, destinations(), new Set(rerooted.filter((b) => !isDatabase(b)).map((b) => b.destinationName)), names);
|
|
39731
|
+
return { config, load: this.passLoader(packagePath, config) };
|
|
39732
|
+
};
|
|
39733
|
+
}
|
|
39189
39734
|
passLoader(packagePath, config) {
|
|
39190
39735
|
const modelPath = this.host.modelPath();
|
|
39191
39736
|
const compiler = packageFiles(packagePath, modelPath, config);
|
|
@@ -39243,7 +39788,7 @@ class ServedCopyServe {
|
|
|
39243
39788
|
}
|
|
39244
39789
|
byKey.set(key, { error, until: asOf + REROOT_FAILURE_TTL_MS });
|
|
39245
39790
|
}
|
|
39246
|
-
async loadCopy(state, copy, overlay, load, lift) {
|
|
39791
|
+
async loadCopy(state, copy, overlay, load, lift, config, underAlias) {
|
|
39247
39792
|
const { withoutKept, problems } = state;
|
|
39248
39793
|
let materializer;
|
|
39249
39794
|
let servedDef;
|
|
@@ -39276,6 +39821,9 @@ class ServedCopyServe {
|
|
|
39276
39821
|
return "retry";
|
|
39277
39822
|
}
|
|
39278
39823
|
const byURL = new Map([...copy.files].map(([url, text]) => [url, text]));
|
|
39824
|
+
const merged = await this.readSameCatalogThroughDestination(state, err, byURL, lift, config, underAlias);
|
|
39825
|
+
if (merged)
|
|
39826
|
+
return merged;
|
|
39279
39827
|
const kept = await leaveOutCrossConnectionJoins({
|
|
39280
39828
|
firstError: err,
|
|
39281
39829
|
overlay: byURL,
|
|
@@ -39341,6 +39889,44 @@ class ServedCopyServe {
|
|
|
39341
39889
|
}
|
|
39342
39890
|
return { materializer, servedDef, servedRuntime, leftOut, files };
|
|
39343
39891
|
}
|
|
39892
|
+
async readSameCatalogThroughDestination(state, err, files, lift, config, underAlias) {
|
|
39893
|
+
const moved = await readSameCatalogThroughDestination({
|
|
39894
|
+
error: err,
|
|
39895
|
+
files,
|
|
39896
|
+
readText: (u) => lift.fileText(u),
|
|
39897
|
+
modelDef: this.host.modelDef(),
|
|
39898
|
+
rerooted: new Set(state.candidates.map((c) => c.reroot.sourceID)),
|
|
39899
|
+
ports: {
|
|
39900
|
+
scope: (connection, alias) => sameCatalogScope(config, connection, alias),
|
|
39901
|
+
pathRefusal: (path, connection, schemas) => this.host.managedTablePathRefusal ? this.host.managedTablePathRefusal(path, connection, schemas) : Promise.resolve("no managed scope check is available"),
|
|
39902
|
+
baseTables: (alias, tables) => allBaseTables(config, alias, tables)
|
|
39903
|
+
}
|
|
39904
|
+
}).catch(() => ({ declined: "a read of its connections failed" }));
|
|
39905
|
+
if ("declined" in moved) {
|
|
39906
|
+
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 });
|
|
39907
|
+
return;
|
|
39908
|
+
}
|
|
39909
|
+
const keyed = keyedOverlay(moved.files);
|
|
39910
|
+
const { config: aliased, load } = underAlias(moved.destinations);
|
|
39911
|
+
try {
|
|
39912
|
+
const loaded = await load(keyed);
|
|
39913
|
+
logger.debug("A served copy reads a joined source on its destination's catalog through the destination", { modelPath: this.host.modelPath() });
|
|
39914
|
+
return {
|
|
39915
|
+
materializer: loaded.materializer,
|
|
39916
|
+
servedDef: loaded.def,
|
|
39917
|
+
servedRuntime: loaded.runtime,
|
|
39918
|
+
leftOut: [],
|
|
39919
|
+
files: keyed,
|
|
39920
|
+
config: aliased
|
|
39921
|
+
};
|
|
39922
|
+
} catch (again) {
|
|
39923
|
+
logger.debug("A served copy's same-catalog read does not compile; its joins are left out", {
|
|
39924
|
+
modelPath: this.host.modelPath(),
|
|
39925
|
+
codes: errorProblems(again)?.map((p) => p.code)
|
|
39926
|
+
});
|
|
39927
|
+
return;
|
|
39928
|
+
}
|
|
39929
|
+
}
|
|
39344
39930
|
contain(state, copy, error, files, mode, remembered = false) {
|
|
39345
39931
|
const { withoutKept, problems } = state;
|
|
39346
39932
|
const failing = new Map(failingReroots(error, files, copy.spans, mode).map((f) => [
|
|
@@ -39406,7 +39992,9 @@ class ServedCopyServe {
|
|
|
39406
39992
|
if (!l.crossConnection)
|
|
39407
39993
|
continue;
|
|
39408
39994
|
const sourceName = l.declaration ?? l.name;
|
|
39995
|
+
const sourceID = l.join === undefined ? candidates.find((c) => c.reroot.sourceName === sourceName && c.reroot.url === l.url)?.reroot.sourceID : undefined;
|
|
39409
39996
|
problems.push({
|
|
39997
|
+
...sourceID !== undefined ? { storedSourceID: sourceID } : {},
|
|
39410
39998
|
sourceName,
|
|
39411
39999
|
reason: "cross_connection_join",
|
|
39412
40000
|
join: l.join ?? l.name,
|
|
@@ -40601,7 +41189,7 @@ function zonedTruncations(columns, def, fieldsByName, chainZone, restatesStageZo
|
|
|
40601
41189
|
restated: []
|
|
40602
41190
|
};
|
|
40603
41191
|
}
|
|
40604
|
-
var NOTHING_PINNED, NO_DESTINATIONS = () => new MalloyConfig3({ 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.",
|
|
41192
|
+
var NOTHING_PINNED, NO_DESTINATIONS = () => new MalloyConfig3({ 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;
|
|
40605
41193
|
var init_served_copy_serve = __esm(() => {
|
|
40606
41194
|
init_ducklake_catalog_unavailable();
|
|
40607
41195
|
init_served_copy_lanes();
|
|
@@ -40637,6 +41225,8 @@ var init_served_copy_serve = __esm(() => {
|
|
|
40637
41225
|
init_utils();
|
|
40638
41226
|
init_served_copy_checks();
|
|
40639
41227
|
init_query_walks();
|
|
41228
|
+
init_same_catalog_reads();
|
|
41229
|
+
init_same_catalog_destination();
|
|
40640
41230
|
init_chain_string_reads();
|
|
40641
41231
|
NOTHING_PINNED = pin(EMPTY_SNAPSHOT, new Date(0));
|
|
40642
41232
|
MISSING_FIELD_CODES = new Set([
|
|
@@ -41275,7 +41865,7 @@ function computeSourceContentSha(packagePath, contentPaths, extra, contentShas)
|
|
|
41275
41865
|
try {
|
|
41276
41866
|
hash.update(fs5.readFileSync(confinedPackagePathSync(packagePath, pathToFileURL6(absolute))));
|
|
41277
41867
|
} catch {
|
|
41278
|
-
hash.update(
|
|
41868
|
+
hash.update(UNREADABLE3);
|
|
41279
41869
|
}
|
|
41280
41870
|
}
|
|
41281
41871
|
hash.update("\x00");
|
|
@@ -41302,7 +41892,7 @@ function canonicalSha(value) {
|
|
|
41302
41892
|
function mintServedRevision() {
|
|
41303
41893
|
return randomUUID();
|
|
41304
41894
|
}
|
|
41305
|
-
var
|
|
41895
|
+
var UNREADABLE3 = "\x00<unreadable>\x00", MANIFEST_AGENTS_MAX_BYTES;
|
|
41306
41896
|
var init_package_revision = __esm(() => {
|
|
41307
41897
|
init_utils();
|
|
41308
41898
|
MANIFEST_AGENTS_MAX_BYTES = 1024 * 1024;
|
|
@@ -42495,6 +43085,7 @@ function getEntitiesFromExplore(explore, docString, relativePath, parentPath, so
|
|
|
42495
43085
|
nameOverride = `${joinPath}.${field.name}`;
|
|
42496
43086
|
}
|
|
42497
43087
|
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);
|
|
43088
|
+
inheritJoinedDoc(codeEntity, field, explore);
|
|
42498
43089
|
const fingerprint = dimIndexFingerprints.get(makeDimIndexLookupKey(sourceName, field.name));
|
|
42499
43090
|
if (fingerprint) {
|
|
42500
43091
|
codeEntity.dim_index_fingerprint = {
|
|
@@ -42506,6 +43097,39 @@ function getEntitiesFromExplore(explore, docString, relativePath, parentPath, so
|
|
|
42506
43097
|
}
|
|
42507
43098
|
return entities;
|
|
42508
43099
|
}
|
|
43100
|
+
function inheritJoinedDoc(entity, field, explore) {
|
|
43101
|
+
if (entity.description !== undefined || field.isExploreField())
|
|
43102
|
+
return;
|
|
43103
|
+
const defs = explore.structDef.fields;
|
|
43104
|
+
const pathOf = (name) => {
|
|
43105
|
+
const e = defs?.find((f) => (f.as ?? f.name) === name)?.e;
|
|
43106
|
+
return e?.node === "field" && Array.isArray(e.path) && e.path.every((p) => typeof p === "string") ? e.path : undefined;
|
|
43107
|
+
};
|
|
43108
|
+
let path = pathOf(field.name);
|
|
43109
|
+
for (let depth = 0;path?.length === 1; depth++) {
|
|
43110
|
+
const link = explore.getFieldByNameIfExists(path[0]);
|
|
43111
|
+
if (depth >= MAX_ALIAS_CHAIN || !link || link.isExploreField() || getAccessModifier(link) !== "public" /* Public */ || getDescriptionFromTags(getTags(link)) !== undefined) {
|
|
43112
|
+
return;
|
|
43113
|
+
}
|
|
43114
|
+
path = pathOf(link.name);
|
|
43115
|
+
}
|
|
43116
|
+
if (path?.length !== 2)
|
|
43117
|
+
return;
|
|
43118
|
+
const [joinName, fieldName] = path;
|
|
43119
|
+
const join = explore.getFieldByNameIfExists(joinName);
|
|
43120
|
+
if (!join?.isExploreField() || getAccessModifier(join) !== "public" /* Public */) {
|
|
43121
|
+
return;
|
|
43122
|
+
}
|
|
43123
|
+
const joined = join.getFieldByNameIfExists(fieldName);
|
|
43124
|
+
if (!joined || joined.isExploreField() || getAccessModifier(joined) !== "public" /* Public */) {
|
|
43125
|
+
return;
|
|
43126
|
+
}
|
|
43127
|
+
const doc = getDescriptionFromTags(getTags(joined));
|
|
43128
|
+
if (doc === undefined)
|
|
43129
|
+
return;
|
|
43130
|
+
entity.description = doc;
|
|
43131
|
+
entity.doc_inherited_from = `${joinName}.${fieldName}`;
|
|
43132
|
+
}
|
|
42509
43133
|
function planJoinAuthorizeMetadata(explore, docString, relativePath, parentPath, parentAuthorize, sourceToModelPath, topLevelExploreNames, boundary, modelGivens, modelAuthorize, alwaysSeenSourceKeys, guarded, sourceDefsByName) {
|
|
42510
43134
|
const plan = [];
|
|
42511
43135
|
const sourceName = composeSourceName(parentPath, explore.name);
|
|
@@ -42606,7 +43230,7 @@ function resolveJoinMetadata(plan, nonQueryableSourceNames, rootIsQueryable, see
|
|
|
42606
43230
|
resolveJoinMetadata(descend.children, nonQueryableSourceNames, rootIsQueryable, seenSourceKeys, out);
|
|
42607
43231
|
}
|
|
42608
43232
|
}
|
|
42609
|
-
var extractDocsFromExplore = (explore) => {
|
|
43233
|
+
var MAX_ALIAS_CHAIN = 8, extractDocsFromExplore = (explore) => {
|
|
42610
43234
|
const parts = getDirectTaglines(explore).map((text) => parseDocAnnotation(text)).filter((doc) => !!doc && doc.length > 0);
|
|
42611
43235
|
return parts.length > 0 ? parts.join(`
|
|
42612
43236
|
`) : null;
|
|
@@ -43181,26 +43805,26 @@ function fcjSettingsOf(retrieval) {
|
|
|
43181
43805
|
function fail(message) {
|
|
43182
43806
|
throw new PackageManifestError(message);
|
|
43183
43807
|
}
|
|
43184
|
-
function
|
|
43808
|
+
function describe2(value) {
|
|
43185
43809
|
return JSON.stringify(value) ?? "nothing";
|
|
43186
43810
|
}
|
|
43187
43811
|
function resolvePromptPath(packageRoot, rel, promptKey = "judge") {
|
|
43188
43812
|
const key = `retrieval.prompts.${promptKey}`;
|
|
43189
43813
|
const fix = `Fix: use a path inside the package, e.g. "prompts/${promptKey}.md".`;
|
|
43190
43814
|
if (rel.includes("\x00") || path10.isAbsolute(rel) || /^[A-Za-z]:[\\/]/.test(rel) || rel.startsWith("\\")) {
|
|
43191
|
-
fail(`Invalid publisher.json ${key}: ${
|
|
43815
|
+
fail(`Invalid publisher.json ${key}: ${describe2(rel)} is an absolute path. ${fix}`);
|
|
43192
43816
|
}
|
|
43193
43817
|
const root = path10.resolve(packageRoot);
|
|
43194
43818
|
const resolved = path10.resolve(root, rel);
|
|
43195
43819
|
const within = path10.relative(root, resolved);
|
|
43196
43820
|
if (within === "" || stepsOutside(within)) {
|
|
43197
|
-
fail(`Invalid publisher.json ${key}: ${
|
|
43821
|
+
fail(`Invalid publisher.json ${key}: ${describe2(rel)} resolves outside the package directory. ${fix}`);
|
|
43198
43822
|
}
|
|
43199
43823
|
return resolved;
|
|
43200
43824
|
}
|
|
43201
43825
|
function objectBlock(raw, key, valid, fix) {
|
|
43202
43826
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
43203
|
-
fail(`Invalid publisher.json ${key}: expected an object, got ${
|
|
43827
|
+
fail(`Invalid publisher.json ${key}: expected an object, got ${describe2(raw)}. Fix: ${fix}`);
|
|
43204
43828
|
}
|
|
43205
43829
|
const obj = raw;
|
|
43206
43830
|
const unknown = Object.keys(obj).filter((k) => !valid.includes(k));
|
|
@@ -43214,7 +43838,7 @@ function parseEnabled(value, key) {
|
|
|
43214
43838
|
return "auto";
|
|
43215
43839
|
if (value === "auto" || value === true || value === false)
|
|
43216
43840
|
return value;
|
|
43217
|
-
return fail(`Invalid publisher.json ${key}: expected "auto", true or false, got ${
|
|
43841
|
+
return fail(`Invalid publisher.json ${key}: expected "auto", true or false, got ${describe2(value)}. ` + `Fix: "enabled": "auto" (on when the server has an LLM), true (require one) or false.`);
|
|
43218
43842
|
}
|
|
43219
43843
|
function parseSourceSummary(raw) {
|
|
43220
43844
|
const obj = objectBlock(raw, "retrieval.sourceSummary", SOURCE_SUMMARY_KEYS, `"sourceSummary": { "enabled": "auto" }`);
|
|
@@ -43226,42 +43850,42 @@ function fcjNumber(obj, key, check) {
|
|
|
43226
43850
|
const value = obj[key] ?? DEFAULT_FCJ_SETTINGS[key];
|
|
43227
43851
|
const ok = typeof value === "number" && Number.isFinite(value) && value >= check.min && value <= check.max && (!check.integer || Number.isSafeInteger(value));
|
|
43228
43852
|
if (!ok) {
|
|
43229
|
-
fail(`Invalid publisher.json retrieval.fcj.${key}: expected ${check.integer ? "an integer" : "a number"} from ${check.min} to ${check.max}, got ${
|
|
43853
|
+
fail(`Invalid publisher.json retrieval.fcj.${key}: expected ${check.integer ? "an integer" : "a number"} from ${check.min} to ${check.max}, got ${describe2(obj[key])}. ` + `Fix: "${key}": ${JSON.stringify(DEFAULT_FCJ_SETTINGS[key])}`);
|
|
43230
43854
|
}
|
|
43231
43855
|
return value;
|
|
43232
43856
|
}
|
|
43233
43857
|
function fcjBoolean(obj, key) {
|
|
43234
43858
|
const value = obj[key] ?? DEFAULT_FCJ_SETTINGS[key];
|
|
43235
43859
|
if (typeof value !== "boolean") {
|
|
43236
|
-
fail(`Invalid publisher.json retrieval.fcj.${key}: expected true or false, got ${
|
|
43860
|
+
fail(`Invalid publisher.json retrieval.fcj.${key}: expected true or false, got ${describe2(obj[key])}. ` + `Fix: "${key}": ${JSON.stringify(DEFAULT_FCJ_SETTINGS[key])}`);
|
|
43237
43861
|
}
|
|
43238
43862
|
return value;
|
|
43239
43863
|
}
|
|
43240
43864
|
function fcjConnect(obj) {
|
|
43241
43865
|
const value = obj.connect ?? DEFAULT_FCJ_SETTINGS.connect;
|
|
43242
43866
|
if (!FCJ_CONNECT_MODES.includes(value)) {
|
|
43243
|
-
fail(`Invalid publisher.json retrieval.fcj.connect: expected one of ${FCJ_CONNECT_MODES.join(", ")}, got ${
|
|
43867
|
+
fail(`Invalid publisher.json retrieval.fcj.connect: expected one of ${FCJ_CONNECT_MODES.join(", ")}, got ${describe2(obj.connect)}. ` + `Fix: "connect": "clusters" (source groups) or "list" (the find stage's top listTopK per target).`);
|
|
43244
43868
|
}
|
|
43245
43869
|
return value;
|
|
43246
43870
|
}
|
|
43247
43871
|
function fcjQuestionsPrompt(obj) {
|
|
43248
43872
|
const value = obj.questionsPrompt ?? DEFAULT_FCJ_SETTINGS.questionsPrompt;
|
|
43249
43873
|
if (!QUESTIONS_PROMPTS.includes(value)) {
|
|
43250
|
-
fail(`Invalid publisher.json retrieval.fcj.questionsPrompt: expected one of ${QUESTIONS_PROMPTS.join(", ")}, got ${
|
|
43874
|
+
fail(`Invalid publisher.json retrieval.fcj.questionsPrompt: expected one of ${QUESTIONS_PROMPTS.join(", ")}, got ${describe2(obj.questionsPrompt)}. ` + `Fix: "questionsPrompt": "questions" (what a person asks), "phrases" (what an agent types as a search target) or "values" (questions that filter by the field's values).`);
|
|
43251
43875
|
}
|
|
43252
43876
|
return value;
|
|
43253
43877
|
}
|
|
43254
43878
|
function fcjAlsoLikely(obj) {
|
|
43255
43879
|
const value = obj.alsoLikely ?? DEFAULT_FCJ_SETTINGS.alsoLikely;
|
|
43256
43880
|
if (!FCJ_ALSO_LIKELY.includes(value)) {
|
|
43257
|
-
fail(`Invalid publisher.json retrieval.fcj.alsoLikely: expected "auto", true or false, got ${
|
|
43881
|
+
fail(`Invalid publisher.json retrieval.fcj.alsoLikely: expected "auto", true or false, got ${describe2(obj.alsoLikely)}. ` + `Fix: "alsoLikely": "auto" (on with connect "list", off with "clusters").`);
|
|
43258
43882
|
}
|
|
43259
43883
|
return value;
|
|
43260
43884
|
}
|
|
43261
43885
|
function fcjJoinedCopies(obj) {
|
|
43262
43886
|
const value = obj.joinedCopies ?? DEFAULT_FCJ_SETTINGS.joinedCopies;
|
|
43263
43887
|
if (!FCJ_JOINED_COPIES.includes(value)) {
|
|
43264
|
-
fail(`Invalid publisher.json retrieval.fcj.joinedCopies: expected one of ${FCJ_JOINED_COPIES.join(", ")}, got ${
|
|
43888
|
+
fail(`Invalid publisher.json retrieval.fcj.joinedCopies: expected one of ${FCJ_JOINED_COPIES.join(", ")}, got ${describe2(obj.joinedCopies)}. ` + `Fix: "joinedCopies": "indexed" (joined copies are searchable rows) or "routes" (each field is searched on its own source and shown with its routes).`);
|
|
43265
43889
|
}
|
|
43266
43890
|
return value;
|
|
43267
43891
|
}
|
|
@@ -43272,7 +43896,7 @@ function fcjJudgeLlm(obj) {
|
|
|
43272
43896
|
const example = `"judgeLlm": { "model": "claude-haiku-5-5" }`;
|
|
43273
43897
|
const o = objectBlock(raw, "retrieval.fcj.judgeLlm", ["model"], example);
|
|
43274
43898
|
if (typeof o.model !== "string" || o.model.trim() === "") {
|
|
43275
|
-
fail(`Invalid publisher.json retrieval.fcj.judgeLlm.model: expected a non-empty string, got ${
|
|
43899
|
+
fail(`Invalid publisher.json retrieval.fcj.judgeLlm.model: expected a non-empty string, got ${describe2(o.model)}. ` + `The provider, host and key are the server's retrieval.llm settings. Fix: ${example}`);
|
|
43276
43900
|
}
|
|
43277
43901
|
return { model: o.model.trim() };
|
|
43278
43902
|
}
|
|
@@ -43321,7 +43945,7 @@ function parsePackageRetrieval(raw) {
|
|
|
43321
43945
|
return { promptPaths: {} };
|
|
43322
43946
|
}
|
|
43323
43947
|
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
43324
|
-
fail(`Invalid publisher.json retrieval: expected an object, got ${
|
|
43948
|
+
fail(`Invalid publisher.json retrieval: expected an object, got ${describe2(raw)}. ` + `Fix: "retrieval": { "fcj": { "perTarget": 30 } }`);
|
|
43325
43949
|
}
|
|
43326
43950
|
const obj = raw;
|
|
43327
43951
|
const unknown = Object.keys(obj).filter((k) => !RETRIEVAL_KEYS.includes(k) && !(k in IGNORED_RETRIEVAL_KEYS));
|
|
@@ -43333,7 +43957,7 @@ function parsePackageRetrieval(raw) {
|
|
|
43333
43957
|
const promptPaths = {};
|
|
43334
43958
|
if (obj.prompts !== undefined && obj.prompts !== null) {
|
|
43335
43959
|
if (typeof obj.prompts !== "object" || Array.isArray(obj.prompts)) {
|
|
43336
|
-
fail(`Invalid publisher.json retrieval.prompts: expected an object, got ${
|
|
43960
|
+
fail(`Invalid publisher.json retrieval.prompts: expected an object, got ${describe2(obj.prompts)}. ` + `Fix: "prompts": { "judge": "prompts/judge.md" }`);
|
|
43337
43961
|
}
|
|
43338
43962
|
const prompts = obj.prompts;
|
|
43339
43963
|
const badPrompt = Object.keys(prompts).filter((k) => !PROMPT_KEYS.includes(k) && !(k in IGNORED_PROMPT_KEYS));
|
|
@@ -43345,7 +43969,7 @@ function parsePackageRetrieval(raw) {
|
|
|
43345
43969
|
if (value === undefined || value === null)
|
|
43346
43970
|
continue;
|
|
43347
43971
|
if (typeof value !== "string" || value.trim() === "") {
|
|
43348
|
-
fail(`Invalid publisher.json retrieval.prompts.${key}: expected a file path inside the package, got ${
|
|
43972
|
+
fail(`Invalid publisher.json retrieval.prompts.${key}: expected a file path inside the package, got ${describe2(value)}. ` + `Fix: "${key}": "prompts/${key}.md"`);
|
|
43349
43973
|
}
|
|
43350
43974
|
promptPaths[key] = value;
|
|
43351
43975
|
}
|
|
@@ -43391,16 +44015,16 @@ async function readPromptFile(packageRoot, key, rel) {
|
|
|
43391
44015
|
} catch (error) {
|
|
43392
44016
|
if (!(error instanceof ImportOutsidePackageError))
|
|
43393
44017
|
throw error;
|
|
43394
|
-
return fail(`Invalid publisher.json ${at}: ${
|
|
44018
|
+
return fail(`Invalid publisher.json ${at}: ${describe2(rel)} resolves outside the package directory through a link. ` + `Fix: copy the file into the package.`);
|
|
43395
44019
|
}
|
|
43396
44020
|
text = await fs8.promises.readFile(realFile, "utf8");
|
|
43397
44021
|
} catch (error) {
|
|
43398
44022
|
if (error instanceof PackageManifestError)
|
|
43399
44023
|
throw error;
|
|
43400
|
-
return fail(`Invalid publisher.json ${at}: cannot read ${
|
|
44024
|
+
return fail(`Invalid publisher.json ${at}: cannot read ${describe2(rel)} (${callerVisibleText(error.message, packageRoot)}). ` + `Fix: create the file inside the package or remove the key.`);
|
|
43401
44025
|
}
|
|
43402
44026
|
if (text.trim() === "") {
|
|
43403
|
-
fail(`Invalid publisher.json ${at}: ${
|
|
44027
|
+
fail(`Invalid publisher.json ${at}: ${describe2(rel)} is empty. ` + `Fix: write the prompt, or remove the key to use the built-in one.`);
|
|
43404
44028
|
}
|
|
43405
44029
|
return {
|
|
43406
44030
|
path: rel,
|
|
@@ -43605,73 +44229,6 @@ var init_render_tag_targets = __esm(() => {
|
|
|
43605
44229
|
init_malloy_text();
|
|
43606
44230
|
});
|
|
43607
44231
|
|
|
43608
|
-
// src/service/connection_type.ts
|
|
43609
|
-
function normalizeReadableSchemas(list) {
|
|
43610
|
-
const names = [
|
|
43611
|
-
...new Set(Array.isArray(list) ? list.filter((name) => typeof name === "string") : [])
|
|
43612
|
-
].filter((name) => name !== "main").sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
43613
|
-
return names.length > 0 ? names : undefined;
|
|
43614
|
-
}
|
|
43615
|
-
function managedSchemas(readableSchemas) {
|
|
43616
|
-
return new Set([
|
|
43617
|
-
"main",
|
|
43618
|
-
...normalizeReadableSchemas(readableSchemas) ?? []
|
|
43619
|
-
]);
|
|
43620
|
-
}
|
|
43621
|
-
function managedOverrideOf(connection) {
|
|
43622
|
-
const name = connection.name;
|
|
43623
|
-
return typeof name === "string" && managedOverrides.some((layer) => layer.has(name));
|
|
43624
|
-
}
|
|
43625
|
-
function overrideOf(connection) {
|
|
43626
|
-
const name = connection.name;
|
|
43627
|
-
if (typeof name !== "string")
|
|
43628
|
-
return;
|
|
43629
|
-
for (let i = overrides.length - 1;i >= 0; i--) {
|
|
43630
|
-
const type = overrides[i].get(name);
|
|
43631
|
-
if (type !== undefined)
|
|
43632
|
-
return type;
|
|
43633
|
-
}
|
|
43634
|
-
return;
|
|
43635
|
-
}
|
|
43636
|
-
function recordConnectionType(connection, type, options = {}) {
|
|
43637
|
-
const recordedType = overrideOf(connection) ?? type;
|
|
43638
|
-
if (recordedType)
|
|
43639
|
-
recorded.set(connection, recordedType);
|
|
43640
|
-
if (options.managed === true || managedOverrideOf(connection)) {
|
|
43641
|
-
managed.set(connection, options.schemas ?? MAIN_ONLY);
|
|
43642
|
-
}
|
|
43643
|
-
return connection;
|
|
43644
|
-
}
|
|
43645
|
-
function isManagedConnection(connection) {
|
|
43646
|
-
return !!connection && managed.has(connection);
|
|
43647
|
-
}
|
|
43648
|
-
function managedSchemasOf(connection) {
|
|
43649
|
-
return connection ? managed.get(connection) : undefined;
|
|
43650
|
-
}
|
|
43651
|
-
function resolveManagedConnections(connections) {
|
|
43652
|
-
return [...connections].filter(([, connection]) => managed.has(connection)).map(([name]) => name).sort();
|
|
43653
|
-
}
|
|
43654
|
-
function connectionTypeOf(connection) {
|
|
43655
|
-
return connection ? recorded.get(connection) : undefined;
|
|
43656
|
-
}
|
|
43657
|
-
function resolveConnectionTypes(connections) {
|
|
43658
|
-
const types = {};
|
|
43659
|
-
for (const [name, connection] of connections) {
|
|
43660
|
-
const type = connectionTypeOf(connection);
|
|
43661
|
-
if (type !== undefined)
|
|
43662
|
-
types[name] = type;
|
|
43663
|
-
}
|
|
43664
|
-
return types;
|
|
43665
|
-
}
|
|
43666
|
-
var recorded, managed, MAIN_ONLY, overrides, managedOverrides;
|
|
43667
|
-
var init_connection_type = __esm(() => {
|
|
43668
|
-
recorded = new WeakMap;
|
|
43669
|
-
managed = new WeakMap;
|
|
43670
|
-
MAIN_ONLY = managedSchemas();
|
|
43671
|
-
overrides = [];
|
|
43672
|
-
managedOverrides = [];
|
|
43673
|
-
});
|
|
43674
|
-
|
|
43675
44232
|
// src/service/materialization/plan/refusal_key.ts
|
|
43676
44233
|
function tierOf(storage) {
|
|
43677
44234
|
return storage !== undefined ? "storage" : "database";
|
|
@@ -44187,6 +44744,21 @@ var init_persist_annotation_validation = __esm(() => {
|
|
|
44187
44744
|
SAFE_NAME_PATH = /^[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)*$/;
|
|
44188
44745
|
});
|
|
44189
44746
|
|
|
44747
|
+
// src/service/materialization/domain/rollup_grain.ts
|
|
44748
|
+
function pathColumnName(join, field) {
|
|
44749
|
+
return `${join}__${field}`;
|
|
44750
|
+
}
|
|
44751
|
+
function grainPathOf(grain) {
|
|
44752
|
+
const at = grain.indexOf(".");
|
|
44753
|
+
if (at < 0)
|
|
44754
|
+
return;
|
|
44755
|
+
return { join: grain.slice(0, at), field: grain.slice(at + 1) };
|
|
44756
|
+
}
|
|
44757
|
+
function grainColumnOf(grain) {
|
|
44758
|
+
const path = grainPathOf(grain);
|
|
44759
|
+
return path ? pathColumnName(path.join, path.field) : grain;
|
|
44760
|
+
}
|
|
44761
|
+
|
|
44190
44762
|
// src/service/materialization/text/read_text.ts
|
|
44191
44763
|
import * as path11 from "path";
|
|
44192
44764
|
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
@@ -44284,7 +44856,10 @@ function persistLine(plan) {
|
|
|
44284
44856
|
return "#@ persist";
|
|
44285
44857
|
}
|
|
44286
44858
|
function emitRollupBuildSource(plan) {
|
|
44287
|
-
const grain = plan.grainDimensions.map((g) =>
|
|
44859
|
+
const grain = plan.grainDimensions.map((g) => {
|
|
44860
|
+
const path = grainPathOf(g);
|
|
44861
|
+
return path ? ` ${identifier(grainColumnOf(g))} is ${identifier(path.join)}.${identifier(path.field)}` : ` ${identifier(g)}`;
|
|
44862
|
+
}).join(`
|
|
44288
44863
|
`);
|
|
44289
44864
|
const partials = plan.rollupMeasures.flatMap((m) => m.partials).map((p) => ` ${identifier(p.column)} is ${emitMeasureExpr(p.leaf.expr)}`).join(`
|
|
44290
44865
|
`);
|
|
@@ -45467,7 +46042,7 @@ var init_types2 = __esm(() => {
|
|
|
45467
46042
|
});
|
|
45468
46043
|
|
|
45469
46044
|
// src/retrieval/config.ts
|
|
45470
|
-
function
|
|
46045
|
+
function describe3(value) {
|
|
45471
46046
|
return value === undefined ? "nothing" : JSON.stringify(value);
|
|
45472
46047
|
}
|
|
45473
46048
|
function positiveInt(value, key, fix) {
|
|
@@ -45475,7 +46050,7 @@ function positiveInt(value, key, fix) {
|
|
|
45475
46050
|
return;
|
|
45476
46051
|
const parsed = typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value.trim()) : value;
|
|
45477
46052
|
if (typeof parsed !== "number" || !Number.isSafeInteger(parsed) || parsed <= 0) {
|
|
45478
|
-
throw new Error(`Invalid ${key}: expected a positive integer, got ${
|
|
46053
|
+
throw new Error(`Invalid ${key}: expected a positive integer, got ${describe3(value)}. Fix: ${fix}`);
|
|
45479
46054
|
}
|
|
45480
46055
|
return parsed;
|
|
45481
46056
|
}
|
|
@@ -45483,7 +46058,7 @@ function nonEmptyString(value, key, fix) {
|
|
|
45483
46058
|
if (value === undefined || value === null)
|
|
45484
46059
|
return;
|
|
45485
46060
|
if (typeof value !== "string" || value.trim() === "") {
|
|
45486
|
-
throw new Error(`Invalid ${key}: expected a non-empty string, got ${
|
|
46061
|
+
throw new Error(`Invalid ${key}: expected a non-empty string, got ${describe3(value)}. Fix: ${fix}`);
|
|
45487
46062
|
}
|
|
45488
46063
|
return value.trim();
|
|
45489
46064
|
}
|
|
@@ -45491,7 +46066,7 @@ function plainString(value, key, fix) {
|
|
|
45491
46066
|
if (value === undefined || value === null)
|
|
45492
46067
|
return;
|
|
45493
46068
|
if (typeof value !== "string") {
|
|
45494
|
-
throw new Error(`Invalid ${key}: expected a string, got ${
|
|
46069
|
+
throw new Error(`Invalid ${key}: expected a string, got ${describe3(value)}. Fix: ${fix}`);
|
|
45495
46070
|
}
|
|
45496
46071
|
return value;
|
|
45497
46072
|
}
|
|
@@ -45502,13 +46077,13 @@ function url(value, key, fix) {
|
|
|
45502
46077
|
try {
|
|
45503
46078
|
new URL(text);
|
|
45504
46079
|
} catch {
|
|
45505
|
-
throw new Error(`Invalid ${key}: expected a URL, got ${
|
|
46080
|
+
throw new Error(`Invalid ${key}: expected a URL, got ${describe3(value)}. Fix: ${fix}`);
|
|
45506
46081
|
}
|
|
45507
46082
|
return text.replace(/\/+$/, "");
|
|
45508
46083
|
}
|
|
45509
46084
|
function block(raw, key, valid, fix) {
|
|
45510
46085
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
45511
|
-
throw new Error(`Invalid ${key}: expected an object, got ${
|
|
46086
|
+
throw new Error(`Invalid ${key}: expected an object, got ${describe3(raw)}. Fix: ${fix}`);
|
|
45512
46087
|
}
|
|
45513
46088
|
const obj = raw;
|
|
45514
46089
|
const unknown = Object.keys(obj).filter((k) => !valid.includes(k));
|
|
@@ -45521,7 +46096,7 @@ function providerName(value, key, allowed, fix) {
|
|
|
45521
46096
|
if (value === undefined || value === null)
|
|
45522
46097
|
return;
|
|
45523
46098
|
if (typeof value !== "string" || !allowed.includes(value)) {
|
|
45524
|
-
throw new Error(`Invalid ${key}: expected one of ${allowed.join(", ")}, got ${
|
|
46099
|
+
throw new Error(`Invalid ${key}: expected one of ${allowed.join(", ")}, got ${describe3(value)}. Fix: ${fix}`);
|
|
45525
46100
|
}
|
|
45526
46101
|
return value;
|
|
45527
46102
|
}
|
|
@@ -45622,20 +46197,20 @@ function parseValueGivens(raw) {
|
|
|
45622
46197
|
const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
45623
46198
|
const isValue = (v) => typeof v === "string" || typeof v === "boolean" || typeof v === "number" && Number.isFinite(v);
|
|
45624
46199
|
if (!isObject(raw)) {
|
|
45625
|
-
throw new Error(`Invalid retrieval.dimensionValues.givens: expected an object of packages, got ${
|
|
46200
|
+
throw new Error(`Invalid retrieval.dimensionValues.givens: expected an object of packages, got ${describe3(raw)}. Fix: ${GIVENS_FIX}`);
|
|
45626
46201
|
}
|
|
45627
46202
|
const out = {};
|
|
45628
46203
|
for (const [pkg, givens] of Object.entries(raw)) {
|
|
45629
46204
|
const at = `retrieval.dimensionValues.givens.${pkg}`;
|
|
45630
46205
|
if (!isObject(givens)) {
|
|
45631
|
-
throw new Error(`Invalid ${at}: expected an object of givens, got ${
|
|
46206
|
+
throw new Error(`Invalid ${at}: expected an object of givens, got ${describe3(givens)}. Fix: ${GIVENS_FIX}`);
|
|
45632
46207
|
}
|
|
45633
46208
|
const parsed = {};
|
|
45634
46209
|
let combinations = 1;
|
|
45635
46210
|
for (const [name, value] of Object.entries(givens)) {
|
|
45636
46211
|
const list = Array.isArray(value) ? value : [value];
|
|
45637
46212
|
if (list.length === 0 || !list.every(isValue)) {
|
|
45638
|
-
throw new Error(`Invalid ${at}.${name}: expected a string, number or boolean, or a non-empty list of them, got ${
|
|
46213
|
+
throw new Error(`Invalid ${at}.${name}: expected a string, number or boolean, or a non-empty list of them, got ${describe3(value)}. Fix: ${GIVENS_FIX}`);
|
|
45639
46214
|
}
|
|
45640
46215
|
parsed[name] = [...new Set(list)];
|
|
45641
46216
|
combinations *= parsed[name].length;
|
|
@@ -45652,7 +46227,7 @@ function parseDimensionValues(raw) {
|
|
|
45652
46227
|
const out = {};
|
|
45653
46228
|
if (fields.enabled !== undefined && fields.enabled !== null) {
|
|
45654
46229
|
if (typeof fields.enabled !== "boolean") {
|
|
45655
|
-
throw new Error(`Invalid retrieval.dimensionValues.enabled: expected a boolean, got ${
|
|
46230
|
+
throw new Error(`Invalid retrieval.dimensionValues.enabled: expected a boolean, got ${describe3(fields.enabled)}. Fix: "enabled": false`);
|
|
45656
46231
|
}
|
|
45657
46232
|
out.enabled = fields.enabled;
|
|
45658
46233
|
}
|
|
@@ -46419,7 +46994,7 @@ function isObj2(value) {
|
|
|
46419
46994
|
function holdsRawSqlExpression(def) {
|
|
46420
46995
|
const seen = new Set;
|
|
46421
46996
|
const walk = (node, depth) => {
|
|
46422
|
-
if (depth >
|
|
46997
|
+
if (depth > MAX_DEPTH4)
|
|
46423
46998
|
return true;
|
|
46424
46999
|
if (node === null || typeof node !== "object")
|
|
46425
47000
|
return false;
|
|
@@ -46461,7 +47036,7 @@ function resolveJoinPath(roots, path) {
|
|
|
46461
47036
|
throw new Unknown(`join path ${path.join(".")} did not resolve`);
|
|
46462
47037
|
}
|
|
46463
47038
|
function relationReads(def, out, depth) {
|
|
46464
|
-
if (depth >
|
|
47039
|
+
if (depth > MAX_DEPTH4 || !isObj2(def))
|
|
46465
47040
|
throw new Unknown("unreadable");
|
|
46466
47041
|
switch (def.type) {
|
|
46467
47042
|
case "table":
|
|
@@ -46527,7 +47102,7 @@ function queryTableReads(entry, pipeline) {
|
|
|
46527
47102
|
}
|
|
46528
47103
|
});
|
|
46529
47104
|
}
|
|
46530
|
-
var
|
|
47105
|
+
var MAX_DEPTH4 = 200, Unknown;
|
|
46531
47106
|
var init_source_reads = __esm(() => {
|
|
46532
47107
|
Unknown = class Unknown extends Error {
|
|
46533
47108
|
};
|
|
@@ -49181,16 +49756,7 @@ function declarationRefusal(decl, facts, ctx) {
|
|
|
49181
49756
|
return "skip";
|
|
49182
49757
|
return unservable("hidden_field", decl, "the measure is not public, and a rollup would publish it");
|
|
49183
49758
|
}
|
|
49184
|
-
const grainProblem = decl.grain
|
|
49185
|
-
const f = byName.get(g);
|
|
49186
|
-
if (g.includes(".")) {
|
|
49187
|
-
return `the grain names \`${g}\`, a path; declare a dimension on the source that reads it, and name that`;
|
|
49188
|
-
}
|
|
49189
|
-
if (!f || !isDimension(f)) {
|
|
49190
|
-
return `the grain names \`${g}\`, which is not a dimension of the source`;
|
|
49191
|
-
}
|
|
49192
|
-
return;
|
|
49193
|
-
}).find((p) => p !== undefined);
|
|
49759
|
+
const grainProblem = grainProblemOf(decl.grain, facts);
|
|
49194
49760
|
if (grainProblem) {
|
|
49195
49761
|
if (decl.v1)
|
|
49196
49762
|
return "skip";
|
|
@@ -49202,7 +49768,7 @@ function declarationRefusal(decl, facts, ctx) {
|
|
|
49202
49768
|
measure: decl.measure
|
|
49203
49769
|
};
|
|
49204
49770
|
}
|
|
49205
|
-
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];
|
|
49771
|
+
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];
|
|
49206
49772
|
if (timeRead) {
|
|
49207
49773
|
return unservable("current_time", decl, `${timeRead}, which a rollup would fix at build time while a live query reads it again at every read`);
|
|
49208
49774
|
}
|
|
@@ -49221,7 +49787,12 @@ function declarationRefusal(decl, facts, ctx) {
|
|
|
49221
49787
|
if (hiddenGrain) {
|
|
49222
49788
|
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`);
|
|
49223
49789
|
}
|
|
49224
|
-
const unreadableGrain = decl.storage === undefined ? undefined : unreadableStoredGrain(decl.grain,
|
|
49790
|
+
const unreadableGrain = decl.storage === undefined ? undefined : unreadableStoredGrain(decl.grain, (g) => {
|
|
49791
|
+
if (!g.includes("."))
|
|
49792
|
+
return byName.get(g);
|
|
49793
|
+
const path = pathGrainOf(g, facts);
|
|
49794
|
+
return "problem" in path ? undefined : path.joined;
|
|
49795
|
+
}, facts.dialect);
|
|
49225
49796
|
if (unreadableGrain) {
|
|
49226
49797
|
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`);
|
|
49227
49798
|
}
|
|
@@ -49250,11 +49821,142 @@ function declarationRefusal(decl, facts, ctx) {
|
|
|
49250
49821
|
}
|
|
49251
49822
|
return;
|
|
49252
49823
|
}
|
|
49253
|
-
function
|
|
49824
|
+
function grainProblemOf(grain, facts) {
|
|
49825
|
+
const { byName } = facts;
|
|
49826
|
+
const columns = new Map;
|
|
49827
|
+
return grain.map((g) => {
|
|
49828
|
+
const f = byName.get(g);
|
|
49829
|
+
if (g.includes(".")) {
|
|
49830
|
+
const path = pathGrainOf(g, facts);
|
|
49831
|
+
if ("problem" in path)
|
|
49832
|
+
return path.problem;
|
|
49833
|
+
const column = grainColumnOf(g);
|
|
49834
|
+
if (byName.has(column) || columns.has(column)) {
|
|
49835
|
+
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)}\``}`;
|
|
49836
|
+
}
|
|
49837
|
+
columns.set(column, g);
|
|
49838
|
+
return;
|
|
49839
|
+
}
|
|
49840
|
+
if (!f || !isDimension(f)) {
|
|
49841
|
+
return `the grain names \`${g}\`, which is not a dimension of the source`;
|
|
49842
|
+
}
|
|
49843
|
+
columns.set(g, g);
|
|
49844
|
+
return;
|
|
49845
|
+
}).find((p) => p !== undefined);
|
|
49846
|
+
}
|
|
49847
|
+
function pathGrainOf(grain, facts) {
|
|
49848
|
+
const [head, second, ...rest] = grain.split(".");
|
|
49849
|
+
const join = facts.joins.get(head);
|
|
49850
|
+
const joinField = facts.byName.get(head);
|
|
49851
|
+
if (!join || !joinField) {
|
|
49852
|
+
return {
|
|
49853
|
+
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`
|
|
49854
|
+
};
|
|
49855
|
+
}
|
|
49856
|
+
const joinedFields = new Map((joinField.fields ?? []).map((f) => [fieldNameOf2(f), f]));
|
|
49857
|
+
const joined = joinedFields.get(second);
|
|
49858
|
+
if (rest.length > 0) {
|
|
49859
|
+
return {
|
|
49860
|
+
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>\``
|
|
49861
|
+
};
|
|
49862
|
+
}
|
|
49863
|
+
if (join.relationship === "cross") {
|
|
49864
|
+
return {
|
|
49865
|
+
problem: `the grain names \`${grain}\`, through \`${head}\`, a join_cross; a path grain reads a join_one or a join_many`
|
|
49866
|
+
};
|
|
49867
|
+
}
|
|
49868
|
+
if (!joined || !isDimension(joined)) {
|
|
49869
|
+
return {
|
|
49870
|
+
problem: `the grain names \`${grain}\`, but \`${second}\` is not a dimension of \`${head}\`'s source`
|
|
49871
|
+
};
|
|
49872
|
+
}
|
|
49873
|
+
if (isHidden(joinField) || isHidden(joined)) {
|
|
49874
|
+
return {
|
|
49875
|
+
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`
|
|
49876
|
+
};
|
|
49877
|
+
}
|
|
49878
|
+
return {
|
|
49879
|
+
join: head,
|
|
49880
|
+
field: second,
|
|
49881
|
+
joined,
|
|
49882
|
+
relationship: join.relationship
|
|
49883
|
+
};
|
|
49884
|
+
}
|
|
49885
|
+
function pathColumnsOf(grain, facts) {
|
|
49886
|
+
const out = [];
|
|
49887
|
+
const add = (entry, column, join, joined) => {
|
|
49888
|
+
const field = fieldNameOf2(joined);
|
|
49889
|
+
const timeframe = joined.timeframe;
|
|
49890
|
+
out.push({
|
|
49891
|
+
grain: entry,
|
|
49892
|
+
column,
|
|
49893
|
+
join,
|
|
49894
|
+
field,
|
|
49895
|
+
...typeof timeframe === "string" ? { timeframe } : {},
|
|
49896
|
+
...fieldNotes(joined).length > 0 ? { annotated: true } : {}
|
|
49897
|
+
});
|
|
49898
|
+
};
|
|
49899
|
+
for (const g of grain) {
|
|
49900
|
+
if (g.includes(".")) {
|
|
49901
|
+
const path = pathGrainOf(g, facts);
|
|
49902
|
+
if (!("problem" in path))
|
|
49903
|
+
add(g, grainColumnOf(g), path.join, path.joined);
|
|
49904
|
+
continue;
|
|
49905
|
+
}
|
|
49906
|
+
const read = exactPathRead(facts.byName.get(g)?.e);
|
|
49907
|
+
if (!read)
|
|
49908
|
+
continue;
|
|
49909
|
+
const path = pathGrainOf(read.join("."), facts);
|
|
49910
|
+
if ("problem" in path)
|
|
49911
|
+
continue;
|
|
49912
|
+
add(g, g, path.join, path.joined);
|
|
49913
|
+
}
|
|
49914
|
+
return out;
|
|
49915
|
+
}
|
|
49916
|
+
function pathReadsCurrentTime(g, facts) {
|
|
49917
|
+
const path = grainPathOf(g);
|
|
49918
|
+
if (!path || !facts.joins.has(path.join))
|
|
49919
|
+
return false;
|
|
49920
|
+
const joinField = facts.byName.get(path.join);
|
|
49921
|
+
return currentTimeFields(joinField?.fields).has(path.field);
|
|
49922
|
+
}
|
|
49923
|
+
function joinOneGrainOf(grain, facts) {
|
|
49924
|
+
const byJoin = new Map;
|
|
49925
|
+
const add = (join, entry) => {
|
|
49926
|
+
if (facts.joins.get(join)?.relationship !== "one")
|
|
49927
|
+
return;
|
|
49928
|
+
const entries = byJoin.get(join) ?? [];
|
|
49929
|
+
if (!entries.includes(entry))
|
|
49930
|
+
entries.push(entry);
|
|
49931
|
+
byJoin.set(join, entries);
|
|
49932
|
+
};
|
|
49933
|
+
for (const g of grain) {
|
|
49934
|
+
const path = grainPathOf(g);
|
|
49935
|
+
if (path) {
|
|
49936
|
+
add(path.join, g);
|
|
49937
|
+
continue;
|
|
49938
|
+
}
|
|
49939
|
+
for (const j of facts.joinUsage.get(g)?.joins ?? [])
|
|
49940
|
+
add(j, g);
|
|
49941
|
+
}
|
|
49942
|
+
if (byJoin.size === 0)
|
|
49943
|
+
return {};
|
|
49944
|
+
return {
|
|
49945
|
+
joinOneGrain: [...byJoin].sort(([a], [b]) => byCodepoint2(a, b)).map(([join, entries]) => ({ join, grain: entries }))
|
|
49946
|
+
};
|
|
49947
|
+
}
|
|
49948
|
+
function exactPathRead(e) {
|
|
49949
|
+
const n = e;
|
|
49950
|
+
if (n?.node !== "field" || !Array.isArray(n.path) || n.path.length !== 2 || !n.path.every((p) => typeof p === "string")) {
|
|
49951
|
+
return;
|
|
49952
|
+
}
|
|
49953
|
+
return n.path;
|
|
49954
|
+
}
|
|
49955
|
+
function unreadableStoredGrain(grain, fieldOf, dialect) {
|
|
49254
49956
|
if (dialect !== STORAGE_DIALECT)
|
|
49255
49957
|
return;
|
|
49256
49958
|
for (const name of grain) {
|
|
49257
|
-
const f =
|
|
49959
|
+
const f = fieldOf(name);
|
|
49258
49960
|
if (f?.type !== "sql native" || typeof f.rawType !== "string")
|
|
49259
49961
|
continue;
|
|
49260
49962
|
const storedType = f.rawType.toUpperCase();
|
|
@@ -49342,6 +50044,7 @@ function rollupPlanOf({ decl, measures }, node, facts, ctx) {
|
|
|
49342
50044
|
inherited.set(`${at.range.start.line}:${at.range.start.character}`, at);
|
|
49343
50045
|
}
|
|
49344
50046
|
}
|
|
50047
|
+
const pathColumns = pathColumnsOf(decl.grain, facts);
|
|
49345
50048
|
const liftedAncestors = [...inherited.values()].sort((a, b) => a.range.start.line - b.range.start.line || a.range.start.character - b.range.start.character);
|
|
49346
50049
|
return {
|
|
49347
50050
|
variant: true,
|
|
@@ -49367,7 +50070,12 @@ function rollupPlanOf({ decl, measures }, node, facts, ctx) {
|
|
|
49367
50070
|
...liftedAncestors.length > 0 ? { liftedAncestors } : {},
|
|
49368
50071
|
..."terms" in facts.given && facts.given.terms.length > 0 ? { readTimeTerms: facts.given.terms } : {},
|
|
49369
50072
|
...(privateGrain.length > 0 || ("terms" in facts.given) && facts.given.terms.length > 0) && facts.declaration ? { declaration: facts.declaration } : {},
|
|
50073
|
+
...pathColumns.length > 0 ? { pathColumns } : {},
|
|
50074
|
+
...joinOneGrainOf(decl.grain, facts),
|
|
49370
50075
|
fanOutDimensions: decl.grain.filter((g) => {
|
|
50076
|
+
const path = grainPathOf(g);
|
|
50077
|
+
if (path)
|
|
50078
|
+
return joins.get(path.join)?.relationship !== "one";
|
|
49371
50079
|
const usage = joinUsage.get(g);
|
|
49372
50080
|
if (usage === undefined)
|
|
49373
50081
|
return joinUsage.has(g);
|
|
@@ -49538,8 +50246,9 @@ function storedDestinationsOf(map, struct) {
|
|
|
49538
50246
|
}
|
|
49539
50247
|
function rollupKeyCheckQuery(plan) {
|
|
49540
50248
|
const [key, ...rest] = plan.grainDimensions;
|
|
49541
|
-
if (key === undefined || rest.length > 0)
|
|
50249
|
+
if (key === undefined || rest.length > 0 || grainPathOf(key)) {
|
|
49542
50250
|
return;
|
|
50251
|
+
}
|
|
49543
50252
|
return `run: ${keyCheckPipeline("rollup_key", rollupBaseAlias(plan.baseDeclaredName), key)}`;
|
|
49544
50253
|
}
|
|
49545
50254
|
function parentKeyNeedsOf(map) {
|
|
@@ -49681,139 +50390,6 @@ var init_source_connection_type = __esm(() => {
|
|
|
49681
50390
|
];
|
|
49682
50391
|
});
|
|
49683
50392
|
|
|
49684
|
-
// src/service/materialization/domain/same_catalog_build.ts
|
|
49685
|
-
function isSameCatalog(source, destination) {
|
|
49686
|
-
const a = source?.type === "ducklake" ? source.ducklakeConnection : undefined;
|
|
49687
|
-
const b = destination?.type === "ducklake" ? destination.ducklakeConnection : undefined;
|
|
49688
|
-
if (!a || !b)
|
|
49689
|
-
return false;
|
|
49690
|
-
const pa = a.catalog?.postgresConnection;
|
|
49691
|
-
const pb = b.catalog?.postgresConnection;
|
|
49692
|
-
if (!pa || !pb)
|
|
49693
|
-
return false;
|
|
49694
|
-
const path = (url) => (url ?? "").replace(/\/+$/, "");
|
|
49695
|
-
const pathA = path(a.storage?.bucketUrl);
|
|
49696
|
-
const pathB = path(b.storage?.bucketUrl);
|
|
49697
|
-
return !!pa.host && pa.host === pb.host && (pa.port ?? 5432) === (pb.port ?? 5432) && !!pa.databaseName && pa.databaseName === pb.databaseName && (a.catalog.metadataSchema ?? "") === (b.catalog.metadataSchema ?? "") && (pathA === "" || pathB === "" || pathA === pathB);
|
|
49698
|
-
}
|
|
49699
|
-
function carriesAuthorSql(def) {
|
|
49700
|
-
return authorSqlCause(def) !== undefined;
|
|
49701
|
-
}
|
|
49702
|
-
function authorSqlCause(def) {
|
|
49703
|
-
const seen = new Set;
|
|
49704
|
-
const walk = (node, depth, frames) => {
|
|
49705
|
-
if (depth > MAX_DEPTH4)
|
|
49706
|
-
return { found: UNREADABLE3, frames };
|
|
49707
|
-
if (node === null || typeof node !== "object")
|
|
49708
|
-
return;
|
|
49709
|
-
if (seen.has(node))
|
|
49710
|
-
return;
|
|
49711
|
-
seen.add(node);
|
|
49712
|
-
if (Array.isArray(node)) {
|
|
49713
|
-
for (const child of node) {
|
|
49714
|
-
const hit = walk(child, depth + 1, frames);
|
|
49715
|
-
if (hit)
|
|
49716
|
-
return hit;
|
|
49717
|
-
}
|
|
49718
|
-
return;
|
|
49719
|
-
}
|
|
49720
|
-
const record = node;
|
|
49721
|
-
if (typeof record.join === "string") {
|
|
49722
|
-
frames = [
|
|
49723
|
-
...frames,
|
|
49724
|
-
{
|
|
49725
|
-
kind: "join",
|
|
49726
|
-
as: String(record.as ?? record.name ?? ""),
|
|
49727
|
-
source: sourceNameOf(record)
|
|
49728
|
-
}
|
|
49729
|
-
];
|
|
49730
|
-
}
|
|
49731
|
-
if (record.type === "sql_select") {
|
|
49732
|
-
return { found: { kind: "sql_source" }, frames };
|
|
49733
|
-
}
|
|
49734
|
-
if (record.node === "genericSQLExpr") {
|
|
49735
|
-
return { found: { kind: "sql_expression" }, frames };
|
|
49736
|
-
}
|
|
49737
|
-
if (record.type === "table" && typeof record.tablePath === "string" && !CATALOG_TABLE_PATH.test(record.tablePath)) {
|
|
49738
|
-
return {
|
|
49739
|
-
found: { kind: "file_table", path: record.tablePath },
|
|
49740
|
-
frames
|
|
49741
|
-
};
|
|
49742
|
-
}
|
|
49743
|
-
for (const [key, child] of Object.entries(record)) {
|
|
49744
|
-
if (record.node === "function_call" && key === "overload")
|
|
49745
|
-
continue;
|
|
49746
|
-
const hit = key === "fields" && Array.isArray(child) ? walkFields(child, depth + 1, frames) : walk(child, depth + 1, key === "structRef" && child !== null && typeof child === "object" ? [
|
|
49747
|
-
...frames,
|
|
49748
|
-
{
|
|
49749
|
-
kind: "reads",
|
|
49750
|
-
source: sourceNameOf(child)
|
|
49751
|
-
}
|
|
49752
|
-
] : frames);
|
|
49753
|
-
if (hit)
|
|
49754
|
-
return hit;
|
|
49755
|
-
}
|
|
49756
|
-
return;
|
|
49757
|
-
};
|
|
49758
|
-
const walkFields = (fields, depth, frames) => {
|
|
49759
|
-
if (depth > MAX_DEPTH4)
|
|
49760
|
-
return { found: UNREADABLE3, frames };
|
|
49761
|
-
if (seen.has(fields))
|
|
49762
|
-
return;
|
|
49763
|
-
seen.add(fields);
|
|
49764
|
-
for (const field of fields) {
|
|
49765
|
-
const f = field;
|
|
49766
|
-
const named = f !== null && typeof f === "object" && typeof f.name === "string" && typeof f.join !== "string";
|
|
49767
|
-
const hit = walk(field, depth + 1, named ? [...frames, { kind: "field", name: String(f.name) }] : frames);
|
|
49768
|
-
if (hit)
|
|
49769
|
-
return hit;
|
|
49770
|
-
}
|
|
49771
|
-
return;
|
|
49772
|
-
};
|
|
49773
|
-
try {
|
|
49774
|
-
if (def === null || typeof def !== "object")
|
|
49775
|
-
return describe3([], UNREADABLE3);
|
|
49776
|
-
const hit = walk(def, 0, []);
|
|
49777
|
-
return hit ? describe3(hit.frames, hit.found) : undefined;
|
|
49778
|
-
} catch {
|
|
49779
|
-
return describe3([], UNREADABLE3);
|
|
49780
|
-
}
|
|
49781
|
-
}
|
|
49782
|
-
function sourceNameOf(record) {
|
|
49783
|
-
const id = typeof record.sourceID === "string" ? record.sourceID : "";
|
|
49784
|
-
const name = typeof record.name === "string" ? record.name : "";
|
|
49785
|
-
return id.split("@")[0] || (name.startsWith("sql://") ? "" : name);
|
|
49786
|
-
}
|
|
49787
|
-
function describe3(frames, found) {
|
|
49788
|
-
if (found.kind === "unreadable") {
|
|
49789
|
-
return "its definition could not be read to check for SQL its author wrote";
|
|
49790
|
-
}
|
|
49791
|
-
frames = frames.filter((frame, i) => frame.kind !== "reads" || i === frames.length - 1 && found.kind !== "sql_expression");
|
|
49792
|
-
const parts = [];
|
|
49793
|
-
let lead = true;
|
|
49794
|
-
for (const frame of frames) {
|
|
49795
|
-
const possessive = lead ? "its" : "whose";
|
|
49796
|
-
const subject = lead ? "it" : "which";
|
|
49797
|
-
lead = false;
|
|
49798
|
-
if (frame.kind === "join") {
|
|
49799
|
-
parts.push(`${possessive} join '${frame.as}'` + (frame.source ? ` reads source '${frame.source}'` : ""));
|
|
49800
|
-
} else if (frame.kind === "reads") {
|
|
49801
|
-
parts.push(frame.source ? `${subject} reads source '${frame.source}'` : `${subject} reads a source`);
|
|
49802
|
-
} else {
|
|
49803
|
-
parts.push(`${possessive} field '${frame.name}'`);
|
|
49804
|
-
}
|
|
49805
|
-
}
|
|
49806
|
-
const last = frames[frames.length - 1];
|
|
49807
|
-
const subject = frames.length === 0 ? "it" : ", which";
|
|
49808
|
-
const what = found.kind === "sql_source" ? `${subject} is an .sql() source` : found.kind === "file_table" ? `${subject} reads '${found.path.replace(/^'|'$/g, "")}' as a table` : last?.kind === "field" ? " uses a sql_* expression" : `${subject} uses a sql_* expression`;
|
|
49809
|
-
return (parts.join(", ") + what).replace(/^ /, "");
|
|
49810
|
-
}
|
|
49811
|
-
var CATALOG_TABLE_PATH, MAX_DEPTH4 = 200, UNREADABLE3;
|
|
49812
|
-
var init_same_catalog_build = __esm(() => {
|
|
49813
|
-
CATALOG_TABLE_PATH = /^[A-Za-z_][A-Za-z0-9_$]*(\.[A-Za-z_][A-Za-z0-9_$]*)*$/;
|
|
49814
|
-
UNREADABLE3 = { kind: "unreadable" };
|
|
49815
|
-
});
|
|
49816
|
-
|
|
49817
50393
|
// src/service/materialization/plan/materialization_eligibility.ts
|
|
49818
50394
|
function assertMaterializationEligible(persistSource, annotationFields, options = {}) {
|
|
49819
50395
|
const sourceName = persistSource.name;
|
|
@@ -56522,6 +57098,28 @@ var init_access_closure = __esm(() => {
|
|
|
56522
57098
|
]);
|
|
56523
57099
|
});
|
|
56524
57100
|
|
|
57101
|
+
// src/service/materialization/domain/target_containers.ts
|
|
57102
|
+
function targetContainerKey(target) {
|
|
57103
|
+
return JSON.stringify([target.connectionName, target.container]);
|
|
57104
|
+
}
|
|
57105
|
+
function containerOfTableName(name) {
|
|
57106
|
+
const dot = name.lastIndexOf(".");
|
|
57107
|
+
return dot > 0 ? name.slice(0, dot) : undefined;
|
|
57108
|
+
}
|
|
57109
|
+
function missingContainerReason(target, dialect, reading) {
|
|
57110
|
+
const kind = capabilitiesOf(dialect).containerCatalog === "dataset" ? "dataset" : "schema";
|
|
57111
|
+
const where = `its name= places its table in ${kind} "${target.container}"`;
|
|
57112
|
+
if ("otherLocation" in reading) {
|
|
57113
|
+
const { location, expected } = reading.otherLocation;
|
|
57114
|
+
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`;
|
|
57115
|
+
}
|
|
57116
|
+
const project = reading.project ? ` (project "${reading.project}")` : "";
|
|
57117
|
+
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`;
|
|
57118
|
+
}
|
|
57119
|
+
var init_target_containers = __esm(() => {
|
|
57120
|
+
init_dialect();
|
|
57121
|
+
});
|
|
57122
|
+
|
|
56525
57123
|
// src/service/materialization/domain/package_plan.ts
|
|
56526
57124
|
function countRefusal(counts, reason) {
|
|
56527
57125
|
counts[reason] = (counts[reason] ?? 0) + 1;
|
|
@@ -57051,18 +57649,19 @@ function inDestinationStringReads(args, stored, planned, upstreams) {
|
|
|
57051
57649
|
const run = planned.kind === "query" ? `run: ${quotedIdentifier(planned.queryName)}` : `run: ${quotedIdentifier(planned.sourceName)} -> ${quotedIdentifier(planned.viewName)}`;
|
|
57052
57650
|
return planStringReads(args.stringReads, args.materializer, { run, stored: stored.upstreams.map((u) => u.sourceID) }, planned.storage, upstreams);
|
|
57053
57651
|
}
|
|
57054
|
-
async function chainedStringReads(source, modelDef, materializer, ports, judged) {
|
|
57652
|
+
async function chainedStringReads(source, modelDef, materializer, ports, judged, planned) {
|
|
57055
57653
|
const destination = declaredStorage(source)?.trim();
|
|
57056
57654
|
if (!destination)
|
|
57057
57655
|
return;
|
|
57058
57656
|
const map = SourceMap.of(modelDef);
|
|
57059
57657
|
const def = map.node(source.sourceID)?.def;
|
|
57060
|
-
if (def?.type !== "query_source"
|
|
57658
|
+
if (def?.type !== "query_source")
|
|
57061
57659
|
return;
|
|
57062
|
-
}
|
|
57063
57660
|
const stored = reachedUpstreams(def, modelDef, map).filter((u) => u.storage === destination && u.sourceID !== source.sourceID).map((u) => u.sourceID);
|
|
57064
57661
|
if (stored.length === 0)
|
|
57065
57662
|
return;
|
|
57663
|
+
if (sharesStoredBuild(source, stored, planned))
|
|
57664
|
+
return;
|
|
57066
57665
|
const reads = await planStringReads(ports, materializer, { downstream: source.name, stored }, destination, { modelDef, judged });
|
|
57067
57666
|
if (!("refused" in reads) || !reads.unstored)
|
|
57068
57667
|
return reads;
|
|
@@ -57073,6 +57672,19 @@ async function chainedStringReads(source, modelDef, materializer, ports, judged)
|
|
|
57073
57672
|
unstored: true
|
|
57074
57673
|
} : reads;
|
|
57075
57674
|
}
|
|
57675
|
+
function sharesStoredBuild(source, stored, planned) {
|
|
57676
|
+
const keyOf = (s) => {
|
|
57677
|
+
if (!s)
|
|
57678
|
+
return;
|
|
57679
|
+
try {
|
|
57680
|
+
return compilerBuildId(s);
|
|
57681
|
+
} catch {
|
|
57682
|
+
return;
|
|
57683
|
+
}
|
|
57684
|
+
};
|
|
57685
|
+
const own = keyOf(source);
|
|
57686
|
+
return own !== undefined && stored.some((id) => keyOf(planned.get(id)) === own);
|
|
57687
|
+
}
|
|
57076
57688
|
async function collectGeneratedPersistedViews(parts, args) {
|
|
57077
57689
|
const authorDef = modelDefOf(args.malloyModel);
|
|
57078
57690
|
const { generated, refused, refusedQueries, omitted, failure } = await tryCompilePersistedViewCompanion({
|
|
@@ -57419,6 +58031,7 @@ function reportPersistLineFindings(parts, targets, planned, args) {
|
|
|
57419
58031
|
async function planV1PersistSources(parts, planned, args) {
|
|
57420
58032
|
const { modelPath, packagePath, materializer, malloyModel } = args;
|
|
57421
58033
|
let classificationCtx;
|
|
58034
|
+
const plannedByID = new Map(planned.map((s) => [s.sourceID, s]));
|
|
57422
58035
|
for (const source of planned) {
|
|
57423
58036
|
const sourceID = source.sourceID;
|
|
57424
58037
|
try {
|
|
@@ -57448,7 +58061,7 @@ async function planV1PersistSources(parts, planned, args) {
|
|
|
57448
58061
|
modelDef: modelDefOf(malloyModel),
|
|
57449
58062
|
deps: gateDepsFor(malloyModel, modelPath)
|
|
57450
58063
|
};
|
|
57451
|
-
const stringReads = declaringModelPath(sourceIDFileURL(sourceID), packagePath, modelPath) === modelPath ? await chainedStringReads(source, classificationCtx.modelDef, materializer, args.stringReads, parts.stringCapabilityReads) : parts.tables[sourceID]?.stringReads;
|
|
58064
|
+
const stringReads = declaringModelPath(sourceIDFileURL(sourceID), packagePath, modelPath) === modelPath ? await chainedStringReads(source, classificationCtx.modelDef, materializer, args.stringReads, parts.stringCapabilityReads, plannedByID) : parts.tables[sourceID]?.stringReads;
|
|
57452
58065
|
const destination = declaredStorage(source)?.trim();
|
|
57453
58066
|
const map = SourceMap.of(classificationCtx.modelDef);
|
|
57454
58067
|
const query = map.node(sourceID)?.def?.query;
|
|
@@ -57625,7 +58238,7 @@ function finishBuildPlan(parts, ctx) {
|
|
|
57625
58238
|
addresses: planAddresses({ ...plan, tableFolds })
|
|
57626
58239
|
};
|
|
57627
58240
|
const refused = refuseCollidingMaterialize(refuseRewrittenNames(full));
|
|
57628
|
-
const known = refuseUpstreamUnread(refused);
|
|
58241
|
+
const known = refuseMissingContainers(refuseUpstreamUnread(refused), ctx.targetContainers);
|
|
57629
58242
|
return refuseOverMissingUpstreams(refuseUncomparableStrings(refuseAcrossPlacements(ctx.keepIncrementalUnbuildable ? known : refuseIncrementalUnbuildable(known))), full);
|
|
57630
58243
|
}
|
|
57631
58244
|
function refuseAcrossPlacements(compiled) {
|
|
@@ -57745,21 +58358,45 @@ function refuseOverMissingUpstreams(compiled, full = compiled) {
|
|
|
57745
58358
|
return dropped.size === 0 ? compiled : withoutSources(compiled, findings, dropped);
|
|
57746
58359
|
}
|
|
57747
58360
|
async function finishPackagePlan(parts, ctx) {
|
|
57748
|
-
const {
|
|
58361
|
+
const {
|
|
58362
|
+
getMalloyConnection,
|
|
58363
|
+
readUpstreamSchemas,
|
|
58364
|
+
readTargetContainers,
|
|
58365
|
+
...finish
|
|
58366
|
+
} = ctx;
|
|
57749
58367
|
const connections = await resolvePackageConnections({ getMalloyConnection }, parts.builds.map((b) => b.connectionName));
|
|
57750
58368
|
const digestSkipped = [];
|
|
57751
58369
|
const connectionDigests = await resolveConnectionDigests(connections, parts.builds, (name) => digestSkipped.push(name));
|
|
57752
58370
|
const upstreamSchemas = readUpstreamSchemas ? await readUpstreamSchemas(planUpstreamTables(parts.tables)) : undefined;
|
|
58371
|
+
const containers = planTargetContainers(parts.tables);
|
|
58372
|
+
const targetContainers = readTargetContainers && containers.length > 0 ? await readTargetContainers(containers) : undefined;
|
|
57753
58373
|
return {
|
|
57754
58374
|
compiled: finishBuildPlan(parts, {
|
|
57755
58375
|
...finish,
|
|
57756
58376
|
connectionDigests,
|
|
57757
58377
|
...upstreamSchemas ? { upstreamSchemas } : {},
|
|
58378
|
+
...targetContainers ? { targetContainers } : {},
|
|
57758
58379
|
connections
|
|
57759
58380
|
}),
|
|
57760
58381
|
digestSkipped
|
|
57761
58382
|
};
|
|
57762
58383
|
}
|
|
58384
|
+
function targetContainerOf(source) {
|
|
58385
|
+
if (declaredStorage(source) !== undefined)
|
|
58386
|
+
return;
|
|
58387
|
+
const name = deriveAnnotationFields(source).name;
|
|
58388
|
+
const container = name ? containerOfTableName(name) : undefined;
|
|
58389
|
+
return container ? { connectionName: source.connectionName, container } : undefined;
|
|
58390
|
+
}
|
|
58391
|
+
function planTargetContainers(tables) {
|
|
58392
|
+
const out = new Map;
|
|
58393
|
+
for (const { source } of Object.values(tables)) {
|
|
58394
|
+
const target = targetContainerOf(source);
|
|
58395
|
+
if (target)
|
|
58396
|
+
out.set(targetContainerKey(target), target);
|
|
58397
|
+
}
|
|
58398
|
+
return [...out.entries()].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([, t]) => t);
|
|
58399
|
+
}
|
|
57763
58400
|
function planUpstreamTables(tables) {
|
|
57764
58401
|
const out = new Map;
|
|
57765
58402
|
for (const { source } of Object.values(tables)) {
|
|
@@ -57926,6 +58563,26 @@ function refuseUpstreamUnread(compiled) {
|
|
|
57926
58563
|
}
|
|
57927
58564
|
return withoutSources(compiled, findings, dropped);
|
|
57928
58565
|
}
|
|
58566
|
+
function refuseMissingContainers(compiled, readings) {
|
|
58567
|
+
if (!readings)
|
|
58568
|
+
return compiled;
|
|
58569
|
+
const shared = sharedTables(compiled);
|
|
58570
|
+
const findings = [];
|
|
58571
|
+
const dropped = new Set;
|
|
58572
|
+
for (const [sourceID, { source }] of Object.entries(compiled.tables)) {
|
|
58573
|
+
if (shared.has(sourceID))
|
|
58574
|
+
continue;
|
|
58575
|
+
const target = targetContainerOf(source);
|
|
58576
|
+
if (!target)
|
|
58577
|
+
continue;
|
|
58578
|
+
const reading = readings[targetContainerKey(target)];
|
|
58579
|
+
if (!reading || "found" in reading || "unread" in reading)
|
|
58580
|
+
continue;
|
|
58581
|
+
dropped.add(sourceID);
|
|
58582
|
+
findings.push(notBuiltFinding(compiled, sourceID, "container_not_found", missingContainerReason(target, source.dialectName, reading)));
|
|
58583
|
+
}
|
|
58584
|
+
return withoutSources(compiled, findings, dropped);
|
|
58585
|
+
}
|
|
57929
58586
|
function notBuiltFinding(compiled, sourceID, reason, why) {
|
|
57930
58587
|
const table = compiled.tables[sourceID];
|
|
57931
58588
|
const source = table.source;
|
|
@@ -58130,6 +58787,7 @@ var init_build_plan = __esm(() => {
|
|
|
58130
58787
|
init_persist_source_fields();
|
|
58131
58788
|
init_quoting();
|
|
58132
58789
|
init_addressing();
|
|
58790
|
+
init_target_containers();
|
|
58133
58791
|
init_eligibility_collect();
|
|
58134
58792
|
init_plan_layers();
|
|
58135
58793
|
init_addressing();
|
|
@@ -58146,7 +58804,7 @@ var init_build_plan = __esm(() => {
|
|
|
58146
58804
|
});
|
|
58147
58805
|
|
|
58148
58806
|
// src/package_load/protocol.ts
|
|
58149
|
-
var PACKAGE_LOAD_PROTOCOL_VERSION =
|
|
58807
|
+
var PACKAGE_LOAD_PROTOCOL_VERSION = 9;
|
|
58150
58808
|
|
|
58151
58809
|
// src/package_load/package_load_worker.ts
|
|
58152
58810
|
init_served_copy_serve();
|
|
@@ -58399,7 +59057,7 @@ function callMain(send) {
|
|
|
58399
59057
|
}
|
|
58400
59058
|
var schemaWait = new RpcWaitAccountant;
|
|
58401
59059
|
function dispatchMainResponse(message) {
|
|
58402
|
-
if (message.type === "schema-for-tables-response" || message.type === "schema-for-sql-response" || message.type === "upstream-schemas-response" || message.type === "read-url-response" || message.type === "connection-metadata-response") {
|
|
59060
|
+
if (message.type === "schema-for-tables-response" || message.type === "schema-for-sql-response" || message.type === "upstream-schemas-response" || message.type === "target-containers-response" || message.type === "read-url-response" || message.type === "connection-metadata-response") {
|
|
58403
59061
|
const pending = pendingRpc.get(message.requestId);
|
|
58404
59062
|
if (!pending)
|
|
58405
59063
|
return;
|
|
@@ -59175,6 +59833,15 @@ async function finishWorkerBuildPlan(malloyConfig, modelPaths, load, materializa
|
|
|
59175
59833
|
tables
|
|
59176
59834
|
};
|
|
59177
59835
|
port.postMessage(req);
|
|
59836
|
+
})).readings,
|
|
59837
|
+
readTargetContainers: async (containers) => (await callMain((requestId) => {
|
|
59838
|
+
const req = {
|
|
59839
|
+
type: "target-containers",
|
|
59840
|
+
requestId,
|
|
59841
|
+
jobId,
|
|
59842
|
+
containers
|
|
59843
|
+
};
|
|
59844
|
+
port.postMessage(req);
|
|
59178
59845
|
})).readings
|
|
59179
59846
|
});
|
|
59180
59847
|
digestSkipped = finished.digestSkipped;
|