@query-farm/vgi 0.48.1 → 0.48.2
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/README.md +24 -1
- package/dist/catalog/descriptors.d.ts +14 -0
- package/dist/catalog/read-only.d.ts +4 -5
- package/dist/functions/registry.d.ts +1 -0
- package/dist/functions/scalar.d.ts +16 -5
- package/dist/functions/types.d.ts +6 -2
- package/dist/index.core.d.ts +1 -1
- package/dist/index.js +47 -23
- package/dist/index.js.map +11 -11
- package/dist/serve-entry.js +6 -4
- package/dist/serve-entry.js.map +4 -4
- package/dist/worker-cf-entry.js +45 -22
- package/dist/worker-cf-entry.js.map +11 -11
- package/package.json +1 -1
- package/src/catalog/descriptors.ts +14 -0
- package/src/catalog/read-only.ts +18 -13
- package/src/functions/registry.ts +6 -3
- package/src/functions/scalar.ts +30 -8
- package/src/functions/table-buffering.ts +3 -0
- package/src/functions/table-in-out.ts +29 -9
- package/src/functions/table.ts +9 -6
- package/src/functions/types.ts +13 -3
- package/src/index.core.ts +1 -1
- package/src/protocol/handlers/function.ts +16 -3
package/dist/worker-cf-entry.js
CHANGED
|
@@ -10400,13 +10400,14 @@ function functionHandlers(config) {
|
|
|
10400
10400
|
} else {
|
|
10401
10401
|
const carried = parseCarriedInitRequest(state.initRequestPacked);
|
|
10402
10402
|
const request = carried.request;
|
|
10403
|
+
request.bind_call.attach_opaque_data = await stripAttach(request.bind_call.attach_opaque_data, undefined);
|
|
10403
10404
|
await resolveSplitPayloads(request, { bind_call: carried.bindCallIpc }, {
|
|
10404
10405
|
auth: currentRequestAuth(),
|
|
10405
10406
|
signingKey,
|
|
10406
10407
|
catalogInterface,
|
|
10407
10408
|
checkAnchor: false
|
|
10408
10409
|
});
|
|
10409
|
-
const func = registry.get(state.functionName,
|
|
10410
|
+
const func = registry.get(state.functionName, overloadContext(request.bind_call, catalogInterface));
|
|
10410
10411
|
const executionId = state.executionId;
|
|
10411
10412
|
const opaqueData = state.opaqueData ?? null;
|
|
10412
10413
|
const initResponse = {
|
|
@@ -10415,10 +10416,11 @@ function functionHandlers(config) {
|
|
|
10415
10416
|
opaque_data: opaqueData
|
|
10416
10417
|
};
|
|
10417
10418
|
handlers = func.createStreamHandlers(request, initResponse, state.filterHistory ?? null);
|
|
10419
|
+
const restored = state.userState != null ? { state: state.userState } : undefined;
|
|
10418
10420
|
if (handlers.producerInit) {
|
|
10419
|
-
handlerState = handlers.producerInit();
|
|
10421
|
+
handlerState = handlers.producerInit(restored);
|
|
10420
10422
|
} else if (handlers.exchangeInit) {
|
|
10421
|
-
handlerState = handlers.exchangeInit();
|
|
10423
|
+
handlerState = handlers.exchangeInit(restored);
|
|
10422
10424
|
}
|
|
10423
10425
|
if (state.userState != null && handlerState?.state !== undefined) {
|
|
10424
10426
|
handlerState.state = state.userState;
|
|
@@ -14436,8 +14438,15 @@ function defineScalarFunction(config) {
|
|
|
14436
14438
|
outputSchema,
|
|
14437
14439
|
inputSchema: inputSchema ?? undefined,
|
|
14438
14440
|
exchangeInit: () => ({}),
|
|
14439
|
-
exchangeFn: (state, input, out) => {
|
|
14440
|
-
|
|
14441
|
+
exchangeFn: async (state, input, out) => {
|
|
14442
|
+
let result = config.compute(input, constArgs, {
|
|
14443
|
+
settings,
|
|
14444
|
+
secrets,
|
|
14445
|
+
auth: out.auth,
|
|
14446
|
+
bindCall: request.bind_call
|
|
14447
|
+
});
|
|
14448
|
+
if (result != null && typeof result.then === "function")
|
|
14449
|
+
result = await result;
|
|
14441
14450
|
let outputBatch;
|
|
14442
14451
|
if (isBatch(result)) {
|
|
14443
14452
|
outputBatch = result;
|
|
@@ -14676,11 +14685,10 @@ function defineTableFunction(config) {
|
|
|
14676
14685
|
if (request.phase != null) {
|
|
14677
14686
|
throw new Error(`${config.name}: is a plain table function (it takes no input row ` + `stream) but was called with an init phase set -- call it via ` + `table_function(), not table_in_out_function().`);
|
|
14678
14687
|
}
|
|
14679
|
-
const state = config.initialState ? config.initialState(processParams) : null;
|
|
14680
14688
|
return {
|
|
14681
14689
|
outputSchema,
|
|
14682
|
-
producerInit: () => ({
|
|
14683
|
-
state,
|
|
14690
|
+
producerInit: (restored) => ({
|
|
14691
|
+
state: restored ? restored.state : config.initialState ? config.initialState(processParams) : null,
|
|
14684
14692
|
processParams,
|
|
14685
14693
|
filterHistory: carriedFilterHistory
|
|
14686
14694
|
}),
|
|
@@ -14797,7 +14805,8 @@ function defineTableInOutFunction(config) {
|
|
|
14797
14805
|
name: "data",
|
|
14798
14806
|
position: posIdx++,
|
|
14799
14807
|
arrowType: nullType2(),
|
|
14800
|
-
isTableInput: true
|
|
14808
|
+
isTableInput: true,
|
|
14809
|
+
...config.argDocs?.data !== undefined ? { doc: config.argDocs.data } : {}
|
|
14801
14810
|
});
|
|
14802
14811
|
if (config.namedArgs) {
|
|
14803
14812
|
for (const [name, type] of Object.entries(config.namedArgs)) {
|
|
@@ -14931,7 +14940,7 @@ function defineTableInOutFunction(config) {
|
|
|
14931
14940
|
for (const bytes of stored) {
|
|
14932
14941
|
finalizeStates.push(deserializeUserState(bytes));
|
|
14933
14942
|
}
|
|
14934
|
-
if (finalizeStates.length === 0) {
|
|
14943
|
+
if (finalizeStates.length === 0 && config.finalize) {
|
|
14935
14944
|
finalizeStates.push(config.initialState ? config.initialState(processParams) : null);
|
|
14936
14945
|
}
|
|
14937
14946
|
const batches = config.finalize ? await config.finalize(processParams, finalizeStates) : [];
|
|
@@ -14954,7 +14963,7 @@ function defineTableInOutFunction(config) {
|
|
|
14954
14963
|
if (request.bind_call.input_schema == null) {
|
|
14955
14964
|
throw new Error(`${config.name}: is a table-in-out function (it requires an input row ` + `stream) but no input schema was supplied -- call it via ` + `table_in_out_function(input=...), not table_function().`);
|
|
14956
14965
|
}
|
|
14957
|
-
const
|
|
14966
|
+
const freshState = () => config.initialState ? config.initialState(processParams) : null;
|
|
14958
14967
|
const processFn = config.process ?? ((_params, _state, batch, out) => {
|
|
14959
14968
|
out.emit(projIds ? projectBatch(projIds, batch) : batch);
|
|
14960
14969
|
});
|
|
@@ -14962,7 +14971,12 @@ function defineTableInOutFunction(config) {
|
|
|
14962
14971
|
outputSchema,
|
|
14963
14972
|
inputSchema: request.bind_call.input_schema,
|
|
14964
14973
|
continuesOutput: true,
|
|
14965
|
-
exchangeInit: () => ({
|
|
14974
|
+
exchangeInit: (restored) => ({
|
|
14975
|
+
state: restored ? restored.state : freshState(),
|
|
14976
|
+
processParams,
|
|
14977
|
+
filterHistory: carriedFilterHistory,
|
|
14978
|
+
morePending: false
|
|
14979
|
+
}),
|
|
14966
14980
|
exchangeFn: async (eState, input, out) => {
|
|
14967
14981
|
await continuationTurn(config.name, eState, input, out, config.resume != null, async (tick) => {
|
|
14968
14982
|
applyRevalidationValidators(eState.processParams, input);
|
|
@@ -15216,12 +15230,17 @@ function defineRowTransformFunction(config) {
|
|
|
15216
15230
|
if (request.bind_call.input_schema == null) {
|
|
15217
15231
|
throw new Error(`${config.name}: is a table-in-out function (its positional args are ` + `per-row input columns) but no input schema was supplied -- call it ` + `via table_in_out_function(input=...), not table_function().`);
|
|
15218
15232
|
}
|
|
15219
|
-
const
|
|
15233
|
+
const freshState = () => config.initialState ? config.initialState(processParams) : null;
|
|
15220
15234
|
return {
|
|
15221
15235
|
outputSchema,
|
|
15222
15236
|
inputSchema: request.bind_call.input_schema,
|
|
15223
15237
|
continuesOutput: true,
|
|
15224
|
-
exchangeInit: () => ({
|
|
15238
|
+
exchangeInit: (restored) => ({
|
|
15239
|
+
state: restored ? restored.state : freshState(),
|
|
15240
|
+
processParams,
|
|
15241
|
+
filterHistory: carriedFilterHistory,
|
|
15242
|
+
morePending: false
|
|
15243
|
+
}),
|
|
15225
15244
|
exchangeFn: async (eState, input, out) => {
|
|
15226
15245
|
await continuationTurn(config.name, eState, input, out, config.resume != null, async (tick) => {
|
|
15227
15246
|
applyRevalidationValidators(eState.processParams, input);
|
|
@@ -15470,8 +15489,10 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
15470
15489
|
for (const tbl of sch.tables ?? []) {
|
|
15471
15490
|
for (const key of ["function", "insertFunction", "updateFunction", "deleteFunction"]) {
|
|
15472
15491
|
const fn = tbl[key];
|
|
15473
|
-
if (fn)
|
|
15474
|
-
|
|
15492
|
+
if (!fn)
|
|
15493
|
+
continue;
|
|
15494
|
+
registry.registerInSchema(fn, schemaDescriptorPath(sch), descriptor.name);
|
|
15495
|
+
registry.register(fn);
|
|
15475
15496
|
}
|
|
15476
15497
|
}
|
|
15477
15498
|
}
|
|
@@ -15487,14 +15508,14 @@ class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
15487
15508
|
return [this._descriptor.name];
|
|
15488
15509
|
}
|
|
15489
15510
|
attachOptionSpecs(_name) {
|
|
15490
|
-
return [];
|
|
15511
|
+
return this._descriptor.attachOptions ?? [];
|
|
15491
15512
|
}
|
|
15492
15513
|
catalogsInfo() {
|
|
15493
15514
|
return [{
|
|
15494
15515
|
name: this._descriptor.name,
|
|
15495
15516
|
implementation_version: null,
|
|
15496
15517
|
data_version_spec: null,
|
|
15497
|
-
attach_option_specs:
|
|
15518
|
+
attach_option_specs: serializeAttachOptionSpecs(this.attachOptionSpecs(this._descriptor.name)),
|
|
15498
15519
|
releases: [],
|
|
15499
15520
|
source_url: this._descriptor.sourceUrl ?? null
|
|
15500
15521
|
}];
|
|
@@ -16567,10 +16588,12 @@ class FunctionRegistry {
|
|
|
16567
16588
|
_byCatalog = new Map;
|
|
16568
16589
|
register(func) {
|
|
16569
16590
|
const name = func.meta.name;
|
|
16570
|
-
|
|
16571
|
-
|
|
16591
|
+
const bucket = this._functions.get(name);
|
|
16592
|
+
if (!bucket) {
|
|
16593
|
+
this._functions.set(name, [func]);
|
|
16594
|
+
} else if (!bucket.includes(func)) {
|
|
16595
|
+
bucket.push(func);
|
|
16572
16596
|
}
|
|
16573
|
-
this._functions.get(name).push(func);
|
|
16574
16597
|
}
|
|
16575
16598
|
registerInSchema(func, schemaPath, catalogName) {
|
|
16576
16599
|
const add = (map, key) => {
|
|
@@ -16891,4 +16914,4 @@ export {
|
|
|
16891
16914
|
validateTableConstraints
|
|
16892
16915
|
};
|
|
16893
16916
|
|
|
16894
|
-
//# debugId=
|
|
16917
|
+
//# debugId=F8503787BE8D309164756E2164756E21
|