@query-farm/vgi 0.22.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@query-farm/vgi",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "TypeScript framework for extending DuckDB with user-defined functions via the Vector Gateway Interface (VGI) over Arrow IPC.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Query Farm LLC (https://query.farm)",
@@ -41,8 +41,20 @@ import {
41
41
  } from "./shared.js";
42
42
 
43
43
  export function registerAggregateMethods(protocol: Protocol, registry: FunctionRegistry): void {
44
- function resolveAggregate(name: string): AggregateFunctionConfig<any, any> {
45
- const func = registry.get(name, { arguments: new Arguments(), inputSchema: null, isScalar: false }) as any;
44
+ // `schemaName` scopes resolution to the schema the caller named. Every
45
+ // aggregate RPC carries it (protocol 1.2.0), so an aggregate name declared in
46
+ // two schemas dispatches to the one the request names rather than colliding
47
+ // on the flat by-name index. `null` (no schema) keeps the cross-schema lookup.
48
+ function resolveAggregate(
49
+ name: string,
50
+ schemaName?: string | null,
51
+ ): AggregateFunctionConfig<any, any> {
52
+ const func = registry.get(name, {
53
+ arguments: new Arguments(),
54
+ inputSchema: null,
55
+ isScalar: false,
56
+ schemaName: schemaName ?? null,
57
+ }) as any;
46
58
  if (!func || func.kind !== "aggregate") {
47
59
  throw new Error(`Function '${name}' is not an aggregate function`);
48
60
  }
@@ -58,7 +70,7 @@ export function registerAggregateMethods(protocol: Protocol, registry: FunctionR
58
70
  handler: async (params) => {
59
71
  const innerParams = unwrapRequest(params.request);
60
72
  const functionName: string = innerParams.function_name;
61
- const cfg = resolveAggregate(functionName);
73
+ const cfg = resolveAggregate(functionName, innerParams.schema_name ?? null);
62
74
  const argBytes = toUint8Array(innerParams.arguments);
63
75
  const args = deserializeArguments(argBytes);
64
76
  const inputSchema = innerParams.input_schema
@@ -109,7 +121,7 @@ export function registerAggregateMethods(protocol: Protocol, registry: FunctionR
109
121
  const innerParams = unwrapRequest(params.request);
110
122
  const functionName: string = innerParams.function_name;
111
123
  const executionId = toUint8Array(innerParams.execution_id);
112
- const cfg = resolveAggregate(functionName);
124
+ const cfg = resolveAggregate(functionName, innerParams.schema_name ?? null);
113
125
  const batch = readSingleBatch(toUint8Array(innerParams.input_batch));
114
126
  if (!batch || batch.numRows === 0) return wrapResult({}, makeSchema([]));
115
127
 
@@ -176,7 +188,7 @@ export function registerAggregateMethods(protocol: Protocol, registry: FunctionR
176
188
  const innerParams = unwrapRequest(params.request);
177
189
  const functionName: string = innerParams.function_name;
178
190
  const executionId = toUint8Array(innerParams.execution_id);
179
- const cfg = resolveAggregate(functionName);
191
+ const cfg = resolveAggregate(functionName, innerParams.schema_name ?? null);
180
192
  const batch = readSingleBatch(toUint8Array(innerParams.merge_batch));
181
193
  if (!batch || batch.numRows === 0) return wrapResult({}, makeSchema([]));
182
194
 
@@ -225,7 +237,7 @@ export function registerAggregateMethods(protocol: Protocol, registry: FunctionR
225
237
  const innerParams = unwrapRequest(params.request);
226
238
  const functionName: string = innerParams.function_name;
227
239
  const executionId = toUint8Array(innerParams.execution_id);
228
- const cfg = resolveAggregate(functionName);
240
+ const cfg = resolveAggregate(functionName, innerParams.schema_name ?? null);
229
241
  const outputSchema = deserializeSchema(toUint8Array(innerParams.output_schema));
230
242
  const gidBatch = readSingleBatch(toUint8Array(innerParams.group_ids_batch));
231
243
  const groupIds: bigint[] = [];
@@ -43,11 +43,19 @@ export function registerTableBufferingMethods(
43
43
  registry: FunctionRegistry,
44
44
  signingKey?: Uint8Array,
45
45
  ): void {
46
- function resolveBuffering(name: string): TableBufferingVgiFunction {
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,