@query-farm/vgi 0.21.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cache-control.d.ts +26 -0
- package/dist/catalog/composite.d.ts +2 -0
- package/dist/catalog/interface.d.ts +11 -0
- package/dist/client-entry.js +5 -3
- package/dist/client-entry.js.map +5 -5
- package/dist/functions/registry.d.ts +31 -0
- package/dist/functions/scalar.d.ts +7 -3
- package/dist/generated/vgi-client.d.ts +16 -0
- package/dist/index.core.d.ts +1 -1
- package/dist/index.js +135 -25
- package/dist/index.js.map +17 -17
- package/dist/protocol/handlers/function.d.ts +8 -0
- package/dist/protocol/handlers/shared.d.ts +4 -0
- package/dist/protocol/types.d.ts +8 -0
- package/dist/serve-entry.js +50 -22
- package/dist/serve-entry.js.map +10 -10
- package/dist/worker-cf-entry.js +130 -23
- package/dist/worker-cf-entry.js.map +15 -15
- package/dist/worker.d.ts +9 -0
- package/package.json +3 -3
- package/src/cache-control.ts +27 -0
- package/src/catalog/composite.ts +9 -0
- package/src/catalog/interface.ts +15 -0
- package/src/catalog/read-only.ts +13 -0
- package/src/functions/registry.ts +106 -1
- package/src/functions/scalar.ts +10 -5
- package/src/generated/vgi-client.ts +17 -1
- package/src/index.core.ts +1 -0
- package/src/protocol/dispatch.ts +1 -0
- package/src/protocol/handlers/aggregate.ts +18 -6
- package/src/protocol/handlers/function.ts +29 -8
- package/src/protocol/handlers/shared.ts +25 -1
- package/src/protocol/handlers/table-buffering.ts +10 -2
- package/src/protocol/serializers/bind.ts +7 -0
- package/src/protocol/types.ts +8 -0
- package/src/worker.ts +15 -1
|
@@ -43,11 +43,19 @@ export function registerTableBufferingMethods(
|
|
|
43
43
|
registry: FunctionRegistry,
|
|
44
44
|
signingKey?: Uint8Array,
|
|
45
45
|
): void {
|
|
46
|
-
|
|
46
|
+
// `schemaName` scopes resolution to the schema the caller named. The
|
|
47
|
+
// buffering process/combine RPCs carry it (protocol 1.2.0), so a name
|
|
48
|
+
// declared in two schemas resolves to the one the request names rather than
|
|
49
|
+
// colliding on the flat by-name index. `null` keeps the cross-schema lookup.
|
|
50
|
+
function resolveBuffering(
|
|
51
|
+
name: string,
|
|
52
|
+
schemaName?: string | null,
|
|
53
|
+
): TableBufferingVgiFunction {
|
|
47
54
|
const func = registry.get(name, {
|
|
48
55
|
arguments: new Arguments(),
|
|
49
56
|
inputSchema: null,
|
|
50
57
|
isScalar: false,
|
|
58
|
+
schemaName: schemaName ?? null,
|
|
51
59
|
}) as any;
|
|
52
60
|
if (!func || func.kind !== "table_buffering") {
|
|
53
61
|
throw new Error(`Function '${name}' is not a table_buffering function`);
|
|
@@ -75,7 +83,7 @@ export function registerTableBufferingMethods(
|
|
|
75
83
|
: rawAttach;
|
|
76
84
|
const transactionId = inner.transaction_id ? toUint8Array(inner.transaction_id) : null;
|
|
77
85
|
|
|
78
|
-
const func = resolveBuffering(functionName);
|
|
86
|
+
const func = resolveBuffering(functionName, inner.schema_name ?? null);
|
|
79
87
|
const bound = new BoundStorage(defaultStorage, executionId);
|
|
80
88
|
const payload = await bound.stateGet(
|
|
81
89
|
FrameworkNS.BUFFERING_INIT,
|
|
@@ -30,6 +30,10 @@ const BIND_REQUEST_SCHEMA = schema([
|
|
|
30
30
|
// Both null when the scan has no AT clause. See BindRequest.at_unit.
|
|
31
31
|
field("at_unit", utf8(), true),
|
|
32
32
|
field("at_value", utf8(), true),
|
|
33
|
+
// Catalog schema owning the function. A worker may register one name in
|
|
34
|
+
// several schemas, so the bare name is not a unique key — resolution is by
|
|
35
|
+
// (schema_name, function_name). Null for callers with no catalog context.
|
|
36
|
+
field("schema_name", utf8(), true),
|
|
33
37
|
]);
|
|
34
38
|
|
|
35
39
|
// COPY ... FROM context — a nullable nested struct<format, file_path,
|
|
@@ -76,6 +80,7 @@ export function serializeBindRequest(req: BindRequest): VgiBatch {
|
|
|
76
80
|
resolved_secrets_provided: req.resolved_secrets_provided ?? false,
|
|
77
81
|
at_unit: req.at_unit ?? null,
|
|
78
82
|
at_value: req.at_value ?? null,
|
|
83
|
+
schema_name: req.schema_name ?? null,
|
|
79
84
|
};
|
|
80
85
|
// Append the copy_from / copy_to struct columns only for COPY scans/sinks, so
|
|
81
86
|
// non-COPY binds serialize to the exact legacy shape (fields matched by name
|
|
@@ -172,6 +177,8 @@ export function deserializeBindRequest(
|
|
|
172
177
|
// Empty string -> null (matches the C++ BuildBindRequest convention).
|
|
173
178
|
at_unit: params.at_unit ? String(params.at_unit) : null,
|
|
174
179
|
at_value: params.at_value ? String(params.at_value) : null,
|
|
180
|
+
// Empty string -> null, same convention as at_unit/at_value.
|
|
181
|
+
schema_name: params.schema_name ? String(params.schema_name) : null,
|
|
175
182
|
// COPY ... FROM context — absent for ordinary scans (params.copy_from
|
|
176
183
|
// undefined -> null). The struct column decodes to a plain object.
|
|
177
184
|
copy_from: parseCopyFromContext(params.copy_from),
|
package/src/protocol/types.ts
CHANGED
|
@@ -88,6 +88,14 @@ export interface BindRequest {
|
|
|
88
88
|
*/
|
|
89
89
|
at_unit?: string | null;
|
|
90
90
|
at_value?: string | null;
|
|
91
|
+
/**
|
|
92
|
+
* Catalog schema that declares the function being bound. A worker may
|
|
93
|
+
* register the same name in more than one schema, so the bare name does not
|
|
94
|
+
* identify an implementation — resolution is by `(schema_name,
|
|
95
|
+
* function_name)`. Null for callers with no catalog context (COPY handler
|
|
96
|
+
* binds). Mirrors vgi-python's `BindRequest.schema_name`.
|
|
97
|
+
*/
|
|
98
|
+
schema_name?: string | null;
|
|
91
99
|
}
|
|
92
100
|
|
|
93
101
|
export interface BindResponse {
|
package/src/worker.ts
CHANGED
|
@@ -65,6 +65,14 @@ export interface WorkerConfig {
|
|
|
65
65
|
/** Factory that receives the built ReadOnlyCatalogInterface and returns a custom catalog. */
|
|
66
66
|
catalogInterfaceFactory?: (base: ReadOnlyCatalogInterface) => CatalogInterface;
|
|
67
67
|
catalogName?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Registry to dispatch through. Pass the same instance used to build a
|
|
70
|
+
* pre-constructed `catalogInterface` — catalogs record which schema (and
|
|
71
|
+
* catalog) declares each function on the registry they are given, and
|
|
72
|
+
* schema-qualified resolution only works if that is the registry the worker
|
|
73
|
+
* dispatches on. Omit to have the worker create its own.
|
|
74
|
+
*/
|
|
75
|
+
registry?: FunctionRegistry;
|
|
68
76
|
}
|
|
69
77
|
|
|
70
78
|
export class Worker {
|
|
@@ -73,7 +81,10 @@ export class Worker {
|
|
|
73
81
|
private _catalogName?: string;
|
|
74
82
|
|
|
75
83
|
constructor(config: WorkerConfig) {
|
|
76
|
-
|
|
84
|
+
// Reuse the caller's registry when given: a catalogInterface built
|
|
85
|
+
// elsewhere recorded its per-schema function ownership there, and that
|
|
86
|
+
// index is what makes a schema-qualified bind resolve correctly.
|
|
87
|
+
this._registry = config.registry ?? new FunctionRegistry();
|
|
77
88
|
this._catalogName = config.catalogName;
|
|
78
89
|
|
|
79
90
|
// Register explicit functions
|
|
@@ -89,6 +100,9 @@ export class Worker {
|
|
|
89
100
|
if (schema.functions) {
|
|
90
101
|
for (const func of schema.functions) {
|
|
91
102
|
this._registry.register(func);
|
|
103
|
+
// Also index by owning schema + catalog so a schema-qualified bind
|
|
104
|
+
// resolves when one name is declared in more than one schema.
|
|
105
|
+
this._registry.registerInSchema(func, schema.name, config.catalog.name);
|
|
92
106
|
}
|
|
93
107
|
}
|
|
94
108
|
}
|