@query-farm/vgi 0.45.0 → 0.47.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/README.md +19 -6
- package/dist/arrow/impl-arrowjs/index.d.ts +1 -1
- package/dist/arrow/impl-arrowjs/iterate.d.ts +2 -0
- package/dist/arrow/impl-flechette/canonical.d.ts +1 -1
- package/dist/arrow/impl-flechette/index.d.ts +1 -1
- package/dist/arrow/impl-flechette/iterate.d.ts +2 -0
- package/dist/arrow/impl-flechette/schema.d.ts +19 -5
- package/dist/arrow/index.d.ts +1 -1
- package/dist/catalog/column-expressions.d.ts +8 -0
- package/dist/catalog/column-metadata.d.ts +11 -0
- package/dist/catalog/composite.d.ts +2 -1
- package/dist/catalog/descriptors.d.ts +21 -29
- package/dist/catalog/interface.d.ts +15 -20
- package/dist/catalog/macro-overloads.d.ts +4 -0
- package/dist/catalog/read-only.d.ts +1 -1
- package/dist/catalog/unconstrained-columns.d.ts +2 -0
- package/dist/client/client.d.ts +38 -14
- package/dist/client-entry.js +806 -115
- package/dist/client-entry.js.map +18 -14
- package/dist/functions/continuation.d.ts +69 -0
- package/dist/functions/projection.d.ts +18 -0
- package/dist/functions/table-in-out.d.ts +51 -7
- package/dist/functions/table.d.ts +6 -1
- package/dist/functions/types.d.ts +21 -0
- package/dist/generated/vgi-client.d.ts +178 -36
- package/dist/generated/vgi-protocol-schemas.d.ts +51 -1
- package/dist/generated/vgi-protocol-types.d.ts +317 -3
- package/dist/generated/vgi-service.d.ts +266 -29
- package/dist/index.core.d.ts +3 -1
- package/dist/index.js +1747 -320
- package/dist/index.js.map +45 -37
- package/dist/protocol/dispatch.d.ts +9 -9
- package/dist/protocol/handlers/aggregate.d.ts +1 -1
- package/dist/protocol/handlers/catalog/index.d.ts +1 -1
- package/dist/protocol/handlers/catalog/metadata.d.ts +1 -0
- package/dist/protocol/handlers/function.d.ts +1 -1
- package/dist/protocol/handlers/table-buffering.d.ts +1 -1
- package/dist/protocol/handlers/unimplemented.d.ts +1 -1
- package/dist/protocol/serializers/bind.d.ts +5 -1
- package/dist/protocol/types.d.ts +5 -0
- package/dist/rpc-server.d.ts +6 -6
- package/dist/serve-entry.js +1607 -436
- package/dist/serve-entry.js.map +33 -27
- package/dist/util/arrow/index.d.ts +1 -1
- package/dist/util/parent-rows.d.ts +8 -0
- package/dist/worker-cf-entry.d.ts +1 -1
- package/dist/worker-cf-entry.js +1901 -526
- package/dist/worker-cf-entry.js.map +45 -37
- package/dist/worker.d.ts +1 -1
- package/package.json +8 -7
- package/src/arrow/impl-arrowjs/index.ts +1 -1
- package/src/arrow/impl-arrowjs/iterate.ts +9 -1
- package/src/arrow/impl-arrowjs/project.ts +1 -1
- package/src/arrow/impl-flechette/canonical.ts +7 -5
- package/src/arrow/impl-flechette/index.ts +1 -1
- package/src/arrow/impl-flechette/ipc.ts +12 -0
- package/src/arrow/impl-flechette/iterate.ts +5 -0
- package/src/arrow/impl-flechette/project.ts +6 -8
- package/src/arrow/index.ts +1 -1
- package/src/catalog/column-expressions.ts +224 -0
- package/src/catalog/column-metadata.ts +151 -0
- package/src/catalog/composite.ts +5 -1
- package/src/catalog/contents-codec.ts +6 -1
- package/src/catalog/descriptors.ts +21 -29
- package/src/catalog/interface.ts +70 -55
- package/src/catalog/macro-overloads.ts +44 -0
- package/src/catalog/read-only.ts +69 -71
- package/src/catalog/unconstrained-columns.ts +23 -0
- package/src/client/client.ts +180 -69
- package/src/codec/asd.ts +3 -1
- package/src/filter-pushdown/collector.ts +17 -1
- package/src/functions/continuation.ts +202 -0
- package/src/functions/projection.ts +207 -0
- package/src/functions/table-in-out.ts +131 -56
- package/src/functions/table.ts +10 -0
- package/src/functions/types.ts +21 -0
- package/src/generated/vgi-client.ts +200 -37
- package/src/generated/vgi-protocol-schemas.ts +456 -41
- package/src/generated/vgi-protocol-types.ts +879 -5
- package/src/generated/vgi-service.ts +514 -42
- package/src/http/client-bundle.ts +1 -1
- package/src/http/fetch.ts +1 -1
- package/src/index.core.ts +10 -0
- package/src/protocol/dispatch.ts +9 -9
- package/src/protocol/handlers/aggregate.ts +1 -1
- package/src/protocol/handlers/catalog/admin.ts +10 -5
- package/src/protocol/handlers/catalog/index.ts +2 -2
- package/src/protocol/handlers/catalog/macro.ts +6 -5
- package/src/protocol/handlers/catalog/metadata.ts +16 -0
- package/src/protocol/handlers/catalog/table.ts +72 -26
- package/src/protocol/handlers/catalog/view.ts +24 -3
- package/src/protocol/handlers/function.ts +79 -1
- package/src/protocol/handlers/table-buffering.ts +1 -1
- package/src/protocol/handlers/unimplemented.ts +6 -6
- package/src/protocol/serializers/bind.ts +17 -1
- package/src/protocol/state-serializer.ts +7 -1
- package/src/protocol/types.ts +6 -0
- package/src/rpc-server.ts +9 -9
- package/src/util/arrow/index.ts +1 -1
- package/src/util/parent-rows.ts +41 -0
- package/src/worker-cf-entry.ts +3 -0
- package/src/worker.ts +1 -1
|
@@ -43,6 +43,8 @@ import {
|
|
|
43
43
|
import { FunctionStability } from "../types.js";
|
|
44
44
|
import { BoundStorage, storage as defaultStorage, FrameworkNS } from "./storage.js";
|
|
45
45
|
import { serializeUserState, deserializeUserState } from "../protocol/state-serializer.js";
|
|
46
|
+
import { PARENT_ROW_METADATA_KEY, encodeParentRows } from "../util/parent-rows.js";
|
|
47
|
+
import { checkInputRowsPerCall, checkResumeContract, continuationTurn } from "./continuation.js";
|
|
46
48
|
|
|
47
49
|
/**
|
|
48
50
|
* State-log key the streaming FINALIZE drain uses within
|
|
@@ -140,6 +142,26 @@ export interface TableInOutConfig<
|
|
|
140
142
|
batch: VgiBatch,
|
|
141
143
|
out: OutputCollector
|
|
142
144
|
) => void | Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* Resume: emit the next reply for the last input batch (continued output).
|
|
147
|
+
*
|
|
148
|
+
* One input batch can produce several replies: `process()` emits the first
|
|
149
|
+
* with {@link moreOutputMetadata}`(true)`, and the framework then calls
|
|
150
|
+
* `resume()`, with no input, for each next reply until one is emitted
|
|
151
|
+
* without it. Like `process()`, each call emits exactly one batch.
|
|
152
|
+
*
|
|
153
|
+
* `resume()` continues from `state` alone, so a function that defines it
|
|
154
|
+
* must define `initialState`. Mutate the state in place: it survives between
|
|
155
|
+
* calls on every transport -- over HTTP inside the stream's state token -- so
|
|
156
|
+
* keep it small (positions to resume from, never buffered output). Not
|
|
157
|
+
* allowed with `maxWorkers: 1`, which runs on one connection shared by every
|
|
158
|
+
* pipeline and so cannot leave output pending.
|
|
159
|
+
*/
|
|
160
|
+
resume?: (
|
|
161
|
+
params: TableInOutProcessParams<TArgs>,
|
|
162
|
+
state: TState,
|
|
163
|
+
out: OutputCollector,
|
|
164
|
+
) => void | Promise<void>;
|
|
143
165
|
/** Finalize: emit final batches after all input processed.
|
|
144
166
|
* Receives all worker states collected from storage (matches Python's finish(params, states)). */
|
|
145
167
|
finalize?: (
|
|
@@ -164,7 +186,9 @@ export function defineTableInOutFunction<
|
|
|
164
186
|
TState = null,
|
|
165
187
|
>(config: TableInOutConfig<TArgs, TState>): VgiFunction {
|
|
166
188
|
assertArrowTypes((config as any).args, `defineTableInOutFunction("${config.name}"): args`);
|
|
167
|
-
|
|
189
|
+
checkResumeContract(config.name, config);
|
|
190
|
+
// A classic (TABLE-input) function cannot split its input into calls.
|
|
191
|
+
checkInputRowsPerCall(config.name, (config as any).inputRowsPerCall, false);
|
|
168
192
|
|
|
169
193
|
// Build argument specs
|
|
170
194
|
const specs: ArgumentSpec[] = [];
|
|
@@ -485,37 +509,52 @@ export function defineTableInOutFunction<
|
|
|
485
509
|
return {
|
|
486
510
|
outputSchema,
|
|
487
511
|
inputSchema: request.bind_call.input_schema,
|
|
488
|
-
|
|
512
|
+
continuesOutput: true,
|
|
513
|
+
exchangeInit: () => ({ state, processParams, filterHistory: carriedFilterHistory, morePending: false }),
|
|
489
514
|
exchangeFn: async (
|
|
490
515
|
eState: {
|
|
491
516
|
state: TState;
|
|
492
517
|
processParams: TableInOutProcessParams<TArgs>;
|
|
493
518
|
filterHistory: FilterDeltaHistory;
|
|
519
|
+
morePending: boolean;
|
|
494
520
|
},
|
|
495
521
|
input: VgiBatch,
|
|
496
522
|
out: OutputCollector
|
|
497
523
|
) => {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
524
|
+
await continuationTurn(config.name, eState, input, out, config.resume != null, async (tick) => {
|
|
525
|
+
// Surface conditional-revalidation validators off the input batch's
|
|
526
|
+
// custom metadata (attached by the C++ WriteInputBatch), so process()
|
|
527
|
+
// can answer a 0-row `notModified` batch instead of recomputing. A
|
|
528
|
+
// tick never carries them, so this also withdraws the last input's
|
|
529
|
+
// from resume().
|
|
530
|
+
applyRevalidationValidators(eState.processParams, input);
|
|
531
|
+
applyDynamicFilterUpdate(eState, input);
|
|
532
|
+
// Bake emit metadata onto the batch (0-row HTTP survival), then
|
|
533
|
+
// reconcile emitted batches to the (possibly projected) output schema
|
|
534
|
+
// by name — a process() may emit its full declared schema and let the
|
|
535
|
+
// framework project (mirrors Python's OutputCollector.emit reconcile).
|
|
536
|
+
let wrappedOut: OutputCollector = makeMetadataBakingCollector(out);
|
|
537
|
+
if (projIds) {
|
|
538
|
+
wrappedOut = makeSchemaReconcilingCollector(wrappedOut, outputSchema);
|
|
539
|
+
}
|
|
540
|
+
const currentFilters = eState.processParams.pushdownFilters;
|
|
541
|
+
if (config.autoApplyFilters && currentFilters) {
|
|
542
|
+
wrappedOut = new FilteringOutputCollector(wrappedOut, currentFilters) as unknown as OutputCollector;
|
|
543
|
+
}
|
|
544
|
+
if (tick) {
|
|
545
|
+
await config.resume!(eState.processParams, eState.state, wrappedOut);
|
|
546
|
+
} else {
|
|
547
|
+
await processFn(eState.processParams, eState.state, input, wrappedOut);
|
|
548
|
+
}
|
|
549
|
+
});
|
|
516
550
|
|
|
517
|
-
// Auto-persist accumulated state for FINALIZE recovery (matches
|
|
518
|
-
|
|
551
|
+
// Auto-persist accumulated state for FINALIZE recovery (matches
|
|
552
|
+
// Python/Go pattern) -- every turn, ticks included, since resume()
|
|
553
|
+
// advances the state finalize() must see. Only the FINALIZE phase
|
|
554
|
+
// reads it back, and only finalize() uses what it reads: a function
|
|
555
|
+
// without one advertises has_finalize=false, so nothing would ever
|
|
556
|
+
// collect the write.
|
|
557
|
+
if (config.finalize && eState.state != null) {
|
|
519
558
|
const serialized = serializeUserState(eState.state);
|
|
520
559
|
if (serialized != null) {
|
|
521
560
|
await boundStorage.put(serialized);
|
|
@@ -661,10 +700,7 @@ function makeSchemaReconcilingCollector(
|
|
|
661
700
|
// Per-output-row provenance (batched correlated LATERAL)
|
|
662
701
|
// ============================================================================
|
|
663
702
|
|
|
664
|
-
|
|
665
|
-
* little-endian int32[] mapping each output row to the input row that
|
|
666
|
-
* produced it. Shared by string with the C++ extension and vgi-python. */
|
|
667
|
-
export const PARENT_ROW_METADATA_KEY = "vgi_rpc.parent_row#b64";
|
|
703
|
+
export { PARENT_ROW_METADATA_KEY };
|
|
668
704
|
|
|
669
705
|
/**
|
|
670
706
|
* Fold per-output-row provenance into an emit metadata map.
|
|
@@ -703,24 +739,10 @@ export function parentRowsMetadata(
|
|
|
703
739
|
// Nothing to map; skip the base64+pack for an empty emit.
|
|
704
740
|
return md;
|
|
705
741
|
}
|
|
706
|
-
|
|
707
|
-
const dv = new DataView(raw.buffer);
|
|
708
|
-
for (let i = 0; i < parentRows.length; i++) {
|
|
709
|
-
dv.setInt32(i * 4, parentRows[i], true);
|
|
710
|
-
}
|
|
711
|
-
md.set(PARENT_ROW_METADATA_KEY, base64Encode(raw));
|
|
742
|
+
md.set(PARENT_ROW_METADATA_KEY, encodeParentRows(parentRows));
|
|
712
743
|
return md;
|
|
713
744
|
}
|
|
714
745
|
|
|
715
|
-
function base64Encode(bytes: Uint8Array): string {
|
|
716
|
-
if (typeof (globalThis as any).Buffer !== "undefined") {
|
|
717
|
-
return (globalThis as any).Buffer.from(bytes).toString("base64");
|
|
718
|
-
}
|
|
719
|
-
let bin = "";
|
|
720
|
-
for (let i = 0; i < bytes.length; i++) bin += String.fromCharCode(bytes[i]);
|
|
721
|
-
return (globalThis as any).btoa(bin);
|
|
722
|
-
}
|
|
723
|
-
|
|
724
746
|
// ============================================================================
|
|
725
747
|
// Blended ("UNNEST-style") row-transform functions
|
|
726
748
|
// ============================================================================
|
|
@@ -734,7 +756,7 @@ function base64Encode(bytes: Uint8Array): string {
|
|
|
734
756
|
export type RowTransformProcessParams<TArgs = Record<string, any>> =
|
|
735
757
|
TableInOutProcessParams<TArgs>;
|
|
736
758
|
|
|
737
|
-
export interface RowTransformConfig<TArgs = Record<string, any
|
|
759
|
+
export interface RowTransformConfig<TArgs = Record<string, any>, TState = null> {
|
|
738
760
|
name: string;
|
|
739
761
|
description?: string;
|
|
740
762
|
/**
|
|
@@ -774,12 +796,47 @@ export interface RowTransformConfig<TArgs = Record<string, any>> {
|
|
|
774
796
|
* per-row map (DuckDB forbids FinalExecute under correlated LATERAL, one of
|
|
775
797
|
* the call shapes blended must serve). Accumulating functions use a classic
|
|
776
798
|
* TableInput table-in-out or a TableBufferingFunction.
|
|
799
|
+
*
|
|
800
|
+
* `state` is the stream's state from {@link initialState} (`null` without
|
|
801
|
+
* one); a function that continues its output keeps its resume position there.
|
|
777
802
|
*/
|
|
778
803
|
process: (
|
|
779
804
|
params: RowTransformProcessParams<TArgs>,
|
|
780
805
|
batch: VgiBatch,
|
|
781
806
|
out: OutputCollector,
|
|
807
|
+
state: TState,
|
|
808
|
+
) => void | Promise<void>;
|
|
809
|
+
/**
|
|
810
|
+
* The stream's initial state, needed only by a function with {@link resume}:
|
|
811
|
+
* where the next reply resumes. Mutate it in place; it survives between
|
|
812
|
+
* calls on every transport (over HTTP inside the stream's state token), so
|
|
813
|
+
* keep it small: positions to resume from, never buffered output rows.
|
|
814
|
+
*/
|
|
815
|
+
initialState?: (params: RowTransformProcessParams<TArgs>) => TState;
|
|
816
|
+
/**
|
|
817
|
+
* Continued output: emit the next reply for the last input batch.
|
|
818
|
+
*
|
|
819
|
+
* Large output for one input batch (an upstream API paged across many
|
|
820
|
+
* requests) need not be built into one batch: `process()` emits the first
|
|
821
|
+
* reply with {@link moreOutputMetadata}`(true)`, and the framework calls
|
|
822
|
+
* `resume()`, with no input, for each next reply until one is emitted
|
|
823
|
+
* without it. Each call emits exactly one batch, whose parent rows index the
|
|
824
|
+
* input batch `process()` received. Requires {@link initialState}; not
|
|
825
|
+
* allowed with `maxWorkers: 1`.
|
|
826
|
+
*/
|
|
827
|
+
resume?: (
|
|
828
|
+
params: RowTransformProcessParams<TArgs>,
|
|
829
|
+
state: TState,
|
|
830
|
+
out: OutputCollector,
|
|
782
831
|
) => void | Promise<void>;
|
|
832
|
+
/**
|
|
833
|
+
* The most input rows one worker call receives: the client's batched-LATERAL
|
|
834
|
+
* operator splits each input chunk (after dedup) into calls of at most this
|
|
835
|
+
* many rows, in order. Unset sends a whole chunk per call. A positive
|
|
836
|
+
* integer. Surfaces as `FunctionInfo.input_rows_per_call`; mirrors
|
|
837
|
+
* vgi-python's `Meta.input_rows_per_call`.
|
|
838
|
+
*/
|
|
839
|
+
inputRowsPerCall?: number;
|
|
783
840
|
// Metadata
|
|
784
841
|
projectionPushdown?: boolean;
|
|
785
842
|
filterPushdown?: boolean;
|
|
@@ -806,7 +863,8 @@ export interface RowTransformConfig<TArgs = Record<string, any>> {
|
|
|
806
863
|
*/
|
|
807
864
|
export function defineRowTransformFunction<
|
|
808
865
|
TArgs = Record<string, any>,
|
|
809
|
-
|
|
866
|
+
TState = null,
|
|
867
|
+
>(config: RowTransformConfig<TArgs, TState>): VgiFunction {
|
|
810
868
|
// Foot-gun guard (mirrors Python's resolve_metadata check): a blended
|
|
811
869
|
// function needs at least one positional Arg — its per-row input column.
|
|
812
870
|
const numPositional = Object.keys(config.args ?? {}).length + (config.varargs ? 1 : 0);
|
|
@@ -816,6 +874,8 @@ export function defineRowTransformFunction<
|
|
|
816
874
|
`positional arg (its per-row input column); found none.`,
|
|
817
875
|
);
|
|
818
876
|
}
|
|
877
|
+
checkResumeContract(config.name, config);
|
|
878
|
+
const inputRowsPerCall = checkInputRowsPerCall(config.name, config.inputRowsPerCall, true);
|
|
819
879
|
|
|
820
880
|
// Positional args are the per-row input columns — REAL typed args on the
|
|
821
881
|
// wire (no TableInput placeholder). Named args follow.
|
|
@@ -884,6 +944,7 @@ export function defineRowTransformFunction<
|
|
|
884
944
|
// Map-shaped, per-row: a blended function never has a finalize.
|
|
885
945
|
hasFinalize: false,
|
|
886
946
|
inputFromArgs: true,
|
|
947
|
+
inputRowsPerCall,
|
|
887
948
|
};
|
|
888
949
|
|
|
889
950
|
// Only NAMED args are on the wire — positional args are the input columns,
|
|
@@ -1018,30 +1079,44 @@ export function defineRowTransformFunction<
|
|
|
1018
1079
|
);
|
|
1019
1080
|
}
|
|
1020
1081
|
|
|
1082
|
+
const state = config.initialState
|
|
1083
|
+
? config.initialState(processParams)
|
|
1084
|
+
: (null as TState);
|
|
1085
|
+
|
|
1021
1086
|
return {
|
|
1022
1087
|
outputSchema,
|
|
1023
1088
|
inputSchema: request.bind_call.input_schema,
|
|
1024
|
-
|
|
1089
|
+
continuesOutput: true,
|
|
1090
|
+
exchangeInit: () => ({ state, processParams, filterHistory: carriedFilterHistory, morePending: false }),
|
|
1025
1091
|
exchangeFn: async (
|
|
1026
1092
|
eState: {
|
|
1027
|
-
state:
|
|
1093
|
+
state: TState;
|
|
1028
1094
|
processParams: RowTransformProcessParams<TArgs>;
|
|
1029
1095
|
filterHistory: FilterDeltaHistory;
|
|
1096
|
+
morePending: boolean;
|
|
1030
1097
|
},
|
|
1031
1098
|
input: VgiBatch,
|
|
1032
1099
|
out: OutputCollector,
|
|
1033
1100
|
) => {
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1101
|
+
await continuationTurn(config.name, eState, input, out, config.resume != null, async (tick) => {
|
|
1102
|
+
// A tick carries no validators, so this also withdraws the last
|
|
1103
|
+
// input's from resume().
|
|
1104
|
+
applyRevalidationValidators(eState.processParams, input);
|
|
1105
|
+
applyDynamicFilterUpdate(eState, input);
|
|
1106
|
+
let wrappedOut: OutputCollector = makeMetadataBakingCollector(out);
|
|
1107
|
+
if (projIds) {
|
|
1108
|
+
wrappedOut = makeSchemaReconcilingCollector(wrappedOut, outputSchema);
|
|
1109
|
+
}
|
|
1110
|
+
const currentFilters = eState.processParams.pushdownFilters;
|
|
1111
|
+
if (config.autoApplyFilters && currentFilters) {
|
|
1112
|
+
wrappedOut = new FilteringOutputCollector(wrappedOut, currentFilters) as unknown as OutputCollector;
|
|
1113
|
+
}
|
|
1114
|
+
if (tick) {
|
|
1115
|
+
await config.resume!(eState.processParams, eState.state, wrappedOut);
|
|
1116
|
+
} else {
|
|
1117
|
+
await config.process(eState.processParams, input, wrappedOut, eState.state);
|
|
1118
|
+
}
|
|
1119
|
+
});
|
|
1045
1120
|
},
|
|
1046
1121
|
};
|
|
1047
1122
|
},
|
package/src/functions/table.ts
CHANGED
|
@@ -21,6 +21,7 @@ import type {
|
|
|
21
21
|
import type {
|
|
22
22
|
BindRequest,
|
|
23
23
|
BindResponse,
|
|
24
|
+
BindRepeatability,
|
|
24
25
|
InitRequest,
|
|
25
26
|
GlobalInitResponse,
|
|
26
27
|
TableFunctionCardinalityRequest,
|
|
@@ -216,6 +217,8 @@ export interface TableFunctionConfig<
|
|
|
216
217
|
| {
|
|
217
218
|
outputSchema: VgiSchema;
|
|
218
219
|
opaqueData?: Uint8Array;
|
|
220
|
+
projectionExpressionProfiles?: string[];
|
|
221
|
+
repeatability?: BindRepeatability;
|
|
219
222
|
lookupSecretTypes?: string[];
|
|
220
223
|
lookupScopes?: string[];
|
|
221
224
|
lookupNames?: string[];
|
|
@@ -223,10 +226,13 @@ export interface TableFunctionConfig<
|
|
|
223
226
|
| Promise<{
|
|
224
227
|
outputSchema: VgiSchema;
|
|
225
228
|
opaqueData?: Uint8Array;
|
|
229
|
+
projectionExpressionProfiles?: string[];
|
|
230
|
+
repeatability?: BindRepeatability;
|
|
226
231
|
lookupSecretTypes?: string[];
|
|
227
232
|
lookupScopes?: string[];
|
|
228
233
|
lookupNames?: string[];
|
|
229
234
|
}>;
|
|
235
|
+
projection?: (params: TableBindParams<TArgs>, proposal: import("./projection.js").ProjectionProposal) => import("./projection.js").ProjectionAcceptance | Promise<import("./projection.js").ProjectionAcceptance>;
|
|
230
236
|
/** Init (optional). May be async — common when storage is HTTP-backed. */
|
|
231
237
|
onInit?: (params: {
|
|
232
238
|
args: TArgs;
|
|
@@ -460,12 +466,16 @@ export function defineTableFunction<
|
|
|
460
466
|
return {
|
|
461
467
|
output_schema: result.outputSchema,
|
|
462
468
|
opaque_data: result.opaqueData ?? null,
|
|
469
|
+
projection_expression_profiles: result.projectionExpressionProfiles ?? [],
|
|
470
|
+
repeatability: result.repeatability === undefined ? "UNKNOWN" : result.repeatability,
|
|
463
471
|
lookup_secret_types: result.lookupSecretTypes,
|
|
464
472
|
lookup_scopes: result.lookupScopes,
|
|
465
473
|
lookup_names: result.lookupNames,
|
|
466
474
|
};
|
|
467
475
|
},
|
|
468
476
|
|
|
477
|
+
projection: config.projection ? (proposal) => config.projection!({args: extractArgs(proposal.bindCall), bindCall:proposal.bindCall, settings:batchToScalarDict(proposal.bindCall.settings),secrets:batchToSecretDict(proposal.bindCall.secrets),resolvedSecretsProvided:proposal.bindCall.resolved_secrets_provided},proposal) : undefined,
|
|
478
|
+
|
|
469
479
|
async globalInit(request: InitRequest): Promise<GlobalInitResponse> {
|
|
470
480
|
const executionId = new Uint8Array(16);
|
|
471
481
|
crypto.getRandomValues(executionId);
|
package/src/functions/types.ts
CHANGED
|
@@ -32,6 +32,12 @@ export interface HandlerState<T = any> {
|
|
|
32
32
|
* rebuilds the filters this one left.
|
|
33
33
|
*/
|
|
34
34
|
filterHistory?: import("../filter-pushdown/history.js").FilterDeltaHistory;
|
|
35
|
+
/**
|
|
36
|
+
* A table-in-out exchange's continued-output flag: the last reply said
|
|
37
|
+
* HAVE_MORE_OUTPUT, so the next input must be a continuation tick. Carried
|
|
38
|
+
* in the HTTP cursor like `filterHistory`.
|
|
39
|
+
*/
|
|
40
|
+
morePending?: boolean;
|
|
35
41
|
[key: string]: any;
|
|
36
42
|
}
|
|
37
43
|
|
|
@@ -109,6 +115,13 @@ export interface FunctionMeta {
|
|
|
109
115
|
* ResolvedMetadata.input_from_args.
|
|
110
116
|
*/
|
|
111
117
|
inputFromArgs?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Blended only: the most input rows one worker call receives; the client
|
|
120
|
+
* splits each input chunk into calls of at most this many rows. Unset sends
|
|
121
|
+
* a whole chunk per call. Set by {@link defineRowTransformFunction}'s
|
|
122
|
+
* `inputRowsPerCall`; surfaces as FunctionInfo.input_rows_per_call.
|
|
123
|
+
*/
|
|
124
|
+
inputRowsPerCall?: number;
|
|
112
125
|
/**
|
|
113
126
|
* table_buffering: force ParallelSink=false in the C++ operator
|
|
114
127
|
* (single-thread, source-ordered ingest).
|
|
@@ -222,6 +235,13 @@ export interface StreamHandlers {
|
|
|
222
235
|
* from DuckDB's Top-N optimizer).
|
|
223
236
|
*/
|
|
224
237
|
onTick?: (state: any, tickMetadata: Map<string, string> | undefined) => void | Promise<void>;
|
|
238
|
+
/**
|
|
239
|
+
* A table-in-out exchange, which may continue one input's output across
|
|
240
|
+
* replies (see functions/continuation.ts). It keeps `morePending` on its
|
|
241
|
+
* handler state, which the dispatcher carries in the HTTP state token. Every
|
|
242
|
+
* other stream's reply is refused if it says HAVE_MORE_OUTPUT.
|
|
243
|
+
*/
|
|
244
|
+
continuesOutput?: boolean;
|
|
225
245
|
}
|
|
226
246
|
|
|
227
247
|
/**
|
|
@@ -253,6 +273,7 @@ export interface VgiFunction {
|
|
|
253
273
|
* function is not split-capable: the whole scan is one unit of work, and the
|
|
254
274
|
* framework answers with a single empty-payload split.
|
|
255
275
|
*/
|
|
276
|
+
projection?(proposal: import("./projection.js").ProjectionProposal): import("./projection.js").ProjectionAcceptance | Promise<import("./projection.js").ProjectionAcceptance>;
|
|
256
277
|
plan?(request: import("../protocol/serializers/splits.js").TableFunctionPlanRequest):
|
|
257
278
|
| import("../protocol/serializers/splits.js").PlanResult
|
|
258
279
|
| Promise<import("../protocol/serializers/splits.js").PlanResult>;
|