@query-farm/vgi 0.47.2 → 0.48.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 +1 -1
- package/dist/client-entry.js +26 -1
- package/dist/client-entry.js.map +5 -5
- package/dist/generated/vgi-client.d.ts +5 -0
- package/dist/generated/vgi-protocol-schemas.d.ts +5 -0
- package/dist/generated/vgi-protocol-types.d.ts +57 -0
- package/dist/generated/vgi-service.d.ts +1 -1
- package/dist/index.core.d.ts +2 -0
- package/dist/index.js +135 -10
- package/dist/index.js.map +11 -10
- package/dist/protocol/dispatch.d.ts +1 -1
- package/dist/protocol/serializers/splits.d.ts +41 -1
- package/dist/serve-entry.js +78 -10
- package/dist/serve-entry.js.map +10 -9
- package/dist/worker-cf-entry.js +80 -10
- package/dist/worker-cf-entry.js.map +11 -10
- package/package.json +1 -1
- package/src/generated/vgi-client.ts +6 -1
- package/src/generated/vgi-protocol-schemas.ts +36 -1
- package/src/generated/vgi-protocol-types.ts +130 -1
- package/src/generated/vgi-service.ts +2 -2
- package/src/index.core.ts +32 -0
- package/src/protocol/dispatch.ts +1 -1
- package/src/protocol/serializers/splits.ts +82 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@query-farm/vgi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.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)",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// GENERATED by vgi.codegen.ts_client. DO NOT EDIT BY HAND.
|
|
3
3
|
//
|
|
4
4
|
// Generator: vgi-gen-ts-client v1
|
|
5
|
-
// Content hash:
|
|
5
|
+
// Content hash: 0fab849ec28b
|
|
6
6
|
//
|
|
7
7
|
// To regenerate:
|
|
8
8
|
// uv run --project ~/Development/vgi-python vgi-gen-ts-client \
|
|
@@ -784,6 +784,9 @@ export interface ScanSplit {
|
|
|
784
784
|
estimated_rows?: number | null;
|
|
785
785
|
rows_exact: boolean;
|
|
786
786
|
estimated_bytes?: number | null;
|
|
787
|
+
key_value?: /** @record-batch */ Uint8Array | null;
|
|
788
|
+
range_index?: number | null;
|
|
789
|
+
column_bounds?: /** @record-batch */ Uint8Array | null;
|
|
787
790
|
partition_bounds?: /** @record-batch */ Uint8Array | null;
|
|
788
791
|
column_statistics?: Uint8Array | null;
|
|
789
792
|
location_ids?: number[] | null;
|
|
@@ -803,6 +806,8 @@ export interface PlanResponse {
|
|
|
803
806
|
catalog_version?: number | null;
|
|
804
807
|
scope: string;
|
|
805
808
|
locations?: string[] | null;
|
|
809
|
+
key_grouping?: Uint8Array | null;
|
|
810
|
+
range_partitioning?: Uint8Array | null;
|
|
806
811
|
partitioning?: Uint8Array[] | null;
|
|
807
812
|
sort_order?: Uint8Array[] | null;
|
|
808
813
|
cache_max_age_seconds?: number | null;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// GENERATED by vgi.codegen.ts_schemas. DO NOT EDIT BY HAND.
|
|
3
3
|
//
|
|
4
4
|
// Generator: vgi-gen-ts-schemas v2
|
|
5
|
-
// Content hash:
|
|
5
|
+
// Content hash: 4b57381f6bef
|
|
6
6
|
//
|
|
7
7
|
// To regenerate:
|
|
8
8
|
// uv run --project ~/Development/vgi-python vgi-gen-ts-schemas \
|
|
@@ -165,6 +165,36 @@ export const CopyFromFormatInfoSchema = schema([
|
|
|
165
165
|
field("ordered", bool(), false),
|
|
166
166
|
]);
|
|
167
167
|
|
|
168
|
+
// Origin: FieldPath
|
|
169
|
+
export const FieldPathSchema = schema([
|
|
170
|
+
field("components", list(field("item", utf8(), true)), false),
|
|
171
|
+
]);
|
|
172
|
+
|
|
173
|
+
// Origin: TransformSpec
|
|
174
|
+
export const TransformSpecSchema = schema([
|
|
175
|
+
field("id", utf8(), false),
|
|
176
|
+
field("inputs", list(field("item", binary(), true)), false),
|
|
177
|
+
field("parameters", binary(), true),
|
|
178
|
+
]);
|
|
179
|
+
|
|
180
|
+
// Origin: KeyGrouping
|
|
181
|
+
export const KeyGroupingSchema = schema([
|
|
182
|
+
field("keys", list(field("item", binary(), true)), false),
|
|
183
|
+
]);
|
|
184
|
+
|
|
185
|
+
// Origin: RangeKey
|
|
186
|
+
export const RangeKeySchema = schema([
|
|
187
|
+
field("transform", binary(), false),
|
|
188
|
+
field("direction", dictionary(utf8(), int16()), false),
|
|
189
|
+
field("null_order", dictionary(utf8(), int16()), false),
|
|
190
|
+
]);
|
|
191
|
+
|
|
192
|
+
// Origin: RangePartitioning
|
|
193
|
+
export const RangePartitioningSchema = schema([
|
|
194
|
+
field("keys", list(field("item", binary(), true)), false),
|
|
195
|
+
field("split_points", binary(), false),
|
|
196
|
+
]);
|
|
197
|
+
|
|
168
198
|
// Origin: MacroParameter
|
|
169
199
|
export const MacroParameterSchema = schema([
|
|
170
200
|
field("name", utf8(), false),
|
|
@@ -462,6 +492,9 @@ export const ScanSplitSchema = schema([
|
|
|
462
492
|
field("estimated_rows", int64(), true),
|
|
463
493
|
field("rows_exact", bool(), false),
|
|
464
494
|
field("estimated_bytes", int64(), true),
|
|
495
|
+
field("key_value", binary(), true),
|
|
496
|
+
field("range_index", int64(), true),
|
|
497
|
+
field("column_bounds", binary(), true),
|
|
465
498
|
field("partition_bounds", binary(), true),
|
|
466
499
|
field("column_statistics", binary(), true),
|
|
467
500
|
field("location_ids", list(field("item", int64(), true)), true),
|
|
@@ -1087,6 +1120,8 @@ export const TableFunctionPlanResultSchema = schema([
|
|
|
1087
1120
|
field("catalog_version", int64(), true),
|
|
1088
1121
|
field("scope", utf8(), false),
|
|
1089
1122
|
field("locations", list(field("item", utf8(), true)), true),
|
|
1123
|
+
field("key_grouping", binary(), true),
|
|
1124
|
+
field("range_partitioning", binary(), true),
|
|
1090
1125
|
field("partitioning", list(field("item", binary(), true)), true),
|
|
1091
1126
|
field("sort_order", list(field("item", binary(), true)), true),
|
|
1092
1127
|
field("cache_max_age_seconds", int64(), true),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// GENERATED by vgi.codegen.ts_types. DO NOT EDIT BY HAND.
|
|
3
3
|
//
|
|
4
4
|
// Generator: python -m vgi.codegen.ts_types v1
|
|
5
|
-
// Content hash:
|
|
5
|
+
// Content hash: 50667b91293f
|
|
6
6
|
//
|
|
7
7
|
// To regenerate:
|
|
8
8
|
// uv run --project ~/Development/vgi-python python scripts/regen_generated.py
|
|
@@ -24,9 +24,11 @@ import {
|
|
|
24
24
|
ConstraintSnapshotSchema,
|
|
25
25
|
ConstraintsApplyRequestSchema,
|
|
26
26
|
DependencySnapshotSchema,
|
|
27
|
+
FieldPathSchema,
|
|
27
28
|
ForeignKeyDefinitionSchema,
|
|
28
29
|
IndexDefinitionSchema,
|
|
29
30
|
IndexKeySchema,
|
|
31
|
+
KeyGroupingSchema,
|
|
30
32
|
MacroOverloadSchema,
|
|
31
33
|
MacroParameterSchema,
|
|
32
34
|
ObjectDependencySchema,
|
|
@@ -36,6 +38,8 @@ import {
|
|
|
36
38
|
QueryCapabilitiesSchema,
|
|
37
39
|
QueryEvaluationContextSchema,
|
|
38
40
|
QueryObjectReferenceSchema,
|
|
41
|
+
RangeKeySchema,
|
|
42
|
+
RangePartitioningSchema,
|
|
39
43
|
RequiredFilterPathsSchema,
|
|
40
44
|
SchemaContentsSchema,
|
|
41
45
|
SortKeySchema,
|
|
@@ -43,10 +47,135 @@ import {
|
|
|
43
47
|
SqlStatementSchema,
|
|
44
48
|
TableLayoutChangeSchema,
|
|
45
49
|
TableLayoutSchema,
|
|
50
|
+
TransformSpecSchema,
|
|
46
51
|
} from "./vgi-protocol-schemas.js";
|
|
47
52
|
import type { CatalogAttachResult, CatalogCapabilities, CatalogContentsResponse, CatalogObjectRef, CatalogQueryPrepareRequest, CatalogQueryPrepareResult, ClientQueryCapabilities, ConstraintSnapshot, ConstraintsApplyRequest, DependencySnapshot, IndexDefinition, MacroOverload, MacroParameter, OptionDefinitions, OptionState, QueryCapabilities, QueryEvaluationContext, QueryObjectReference, SqlExpression, TableLayout } from "./vgi-client.js";
|
|
48
53
|
export type { CatalogAttachResult, CatalogCapabilities, CatalogContentsResponse, CatalogObjectRef, CatalogQueryPrepareRequest, CatalogQueryPrepareResult, ClientQueryCapabilities, ConstraintSnapshot, ConstraintsApplyRequest, DependencySnapshot, IndexDefinition, MacroOverload, MacroParameter, OptionDefinitions, OptionState, QueryCapabilities, QueryEvaluationContext, QueryObjectReference, SqlExpression, TableLayout };
|
|
49
54
|
|
|
55
|
+
// ----------------------------------------------------------------------------
|
|
56
|
+
// FieldPath (schema: FieldPathSchema)
|
|
57
|
+
// ----------------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
/** One raw, component-preserving field reference used by a transform. */
|
|
60
|
+
export interface FieldPath {
|
|
61
|
+
components: string[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** `FieldPath` has no defaulted fields, so its init is the record itself. */
|
|
65
|
+
export type FieldPathInit = FieldPath;
|
|
66
|
+
|
|
67
|
+
/** Build a complete `FieldPath`, filling the protocol defaults, in wire order. */
|
|
68
|
+
export function buildFieldPath(init: FieldPathInit): FieldPath {
|
|
69
|
+
return {
|
|
70
|
+
components: init.components,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const encodeFieldPath = (v: FieldPath): Uint8Array => encodeASD(FieldPathSchema, v);
|
|
75
|
+
export const decodeFieldPath = (b: Uint8Array): FieldPath => decodeASD<FieldPath>(FieldPathSchema, b);
|
|
76
|
+
|
|
77
|
+
// ----------------------------------------------------------------------------
|
|
78
|
+
// TransformSpec (schema: TransformSpecSchema)
|
|
79
|
+
// ----------------------------------------------------------------------------
|
|
80
|
+
|
|
81
|
+
/** A versioned, registry-defined partition transform. `id` identifies normative semantics (for example `vgi.identity/1` or `iceberg.bucket/1`). `inputs` contains serialized :class:`FieldPath` records. `parameters` is either absent or a one-row Arrow batch, which permits any number of named, typed parameters without admitting arbitrary recursive expressions. */
|
|
82
|
+
export interface TransformSpec {
|
|
83
|
+
id: string;
|
|
84
|
+
inputs: Uint8Array[];
|
|
85
|
+
parameters?: Uint8Array | null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Fields of `TransformSpec` that have a protocol default. */
|
|
89
|
+
export type TransformSpecDefaultedField =
|
|
90
|
+
| "inputs"
|
|
91
|
+
| "parameters";
|
|
92
|
+
/** `TransformSpec` with every field that has a protocol default optional. */
|
|
93
|
+
export type TransformSpecInit = Omit<TransformSpec, TransformSpecDefaultedField> & Partial<Pick<TransformSpec, TransformSpecDefaultedField>>;
|
|
94
|
+
|
|
95
|
+
/** Build a complete `TransformSpec`, filling the protocol defaults, in wire order. */
|
|
96
|
+
export function buildTransformSpec(init: TransformSpecInit): TransformSpec {
|
|
97
|
+
return {
|
|
98
|
+
id: init.id,
|
|
99
|
+
inputs: init.inputs ?? [],
|
|
100
|
+
parameters: init.parameters ?? null,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const encodeTransformSpec = (v: TransformSpec): Uint8Array => encodeASD(TransformSpecSchema, v);
|
|
105
|
+
export const decodeTransformSpec = (b: Uint8Array): TransformSpec => decodeASD<TransformSpec>(TransformSpecSchema, b);
|
|
106
|
+
|
|
107
|
+
// ----------------------------------------------------------------------------
|
|
108
|
+
// KeyGrouping (schema: KeyGroupingSchema)
|
|
109
|
+
// ----------------------------------------------------------------------------
|
|
110
|
+
|
|
111
|
+
/** Transforms whose exact result tuple is constant within every split. */
|
|
112
|
+
export interface KeyGrouping {
|
|
113
|
+
keys: Uint8Array[];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** `KeyGrouping` has no defaulted fields, so its init is the record itself. */
|
|
117
|
+
export type KeyGroupingInit = KeyGrouping;
|
|
118
|
+
|
|
119
|
+
/** Build a complete `KeyGrouping`, filling the protocol defaults, in wire order. */
|
|
120
|
+
export function buildKeyGrouping(init: KeyGroupingInit): KeyGrouping {
|
|
121
|
+
return {
|
|
122
|
+
keys: init.keys,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export const encodeKeyGrouping = (v: KeyGrouping): Uint8Array => encodeASD(KeyGroupingSchema, v);
|
|
127
|
+
export const decodeKeyGrouping = (b: Uint8Array): KeyGrouping => decodeASD<KeyGrouping>(KeyGroupingSchema, b);
|
|
128
|
+
|
|
129
|
+
// ----------------------------------------------------------------------------
|
|
130
|
+
// RangeKey (schema: RangeKeySchema)
|
|
131
|
+
// ----------------------------------------------------------------------------
|
|
132
|
+
|
|
133
|
+
/** One transform and comparator component of a range key. */
|
|
134
|
+
export interface RangeKey {
|
|
135
|
+
transform: Uint8Array;
|
|
136
|
+
direction: string;
|
|
137
|
+
null_order: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** `RangeKey` has no defaulted fields, so its init is the record itself. */
|
|
141
|
+
export type RangeKeyInit = RangeKey;
|
|
142
|
+
|
|
143
|
+
/** Build a complete `RangeKey`, filling the protocol defaults, in wire order. */
|
|
144
|
+
export function buildRangeKey(init: RangeKeyInit): RangeKey {
|
|
145
|
+
return {
|
|
146
|
+
transform: init.transform,
|
|
147
|
+
direction: init.direction,
|
|
148
|
+
null_order: init.null_order,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export const encodeRangeKey = (v: RangeKey): Uint8Array => encodeASD(RangeKeySchema, v);
|
|
153
|
+
export const decodeRangeKey = (b: Uint8Array): RangeKey => decodeASD<RangeKey>(RangeKeySchema, b);
|
|
154
|
+
|
|
155
|
+
// ----------------------------------------------------------------------------
|
|
156
|
+
// RangePartitioning (schema: RangePartitioningSchema)
|
|
157
|
+
// ----------------------------------------------------------------------------
|
|
158
|
+
|
|
159
|
+
/** Exact half-open range distribution shared by all splits in a plan. `N` split-point rows define `N + 1` ranges. Values equal to point `i` belong to range `i + 1`. Each split names its range with :attr:`ScanSplit.range_index`. */
|
|
160
|
+
export interface RangePartitioning {
|
|
161
|
+
keys: Uint8Array[];
|
|
162
|
+
split_points: Uint8Array;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** `RangePartitioning` has no defaulted fields, so its init is the record itself. */
|
|
166
|
+
export type RangePartitioningInit = RangePartitioning;
|
|
167
|
+
|
|
168
|
+
/** Build a complete `RangePartitioning`, filling the protocol defaults, in wire order. */
|
|
169
|
+
export function buildRangePartitioning(init: RangePartitioningInit): RangePartitioning {
|
|
170
|
+
return {
|
|
171
|
+
keys: init.keys,
|
|
172
|
+
split_points: init.split_points,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export const encodeRangePartitioning = (v: RangePartitioning): Uint8Array => encodeASD(RangePartitioningSchema, v);
|
|
177
|
+
export const decodeRangePartitioning = (b: Uint8Array): RangePartitioning => decodeASD<RangePartitioning>(RangePartitioningSchema, b);
|
|
178
|
+
|
|
50
179
|
// ----------------------------------------------------------------------------
|
|
51
180
|
// MacroParameter (schema: MacroParameterSchema)
|
|
52
181
|
// ----------------------------------------------------------------------------
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// GENERATED by vgi.codegen.ts_registry. DO NOT EDIT BY HAND.
|
|
3
3
|
//
|
|
4
4
|
// Generator: python -m vgi.codegen.ts_registry v1
|
|
5
|
-
// Content hash:
|
|
5
|
+
// Content hash: d92d651266e2
|
|
6
6
|
//
|
|
7
7
|
// To regenerate:
|
|
8
8
|
// uv run --project ~/Development/vgi-python python scripts/regen_generated.py
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
export const VGI_PROTOCOL_NAME = "vgi.v3";
|
|
39
39
|
|
|
40
40
|
/** The protocol's semver, stamped on every request by a client of this protocol. */
|
|
41
|
-
export const VGI_PROTOCOL_VERSION = "3.
|
|
41
|
+
export const VGI_PROTOCOL_VERSION = "3.1.0";
|
|
42
42
|
|
|
43
43
|
/** What a unary handler returns: the result row, now or later. */
|
|
44
44
|
export type VgiReply<T> = T | ExternalRef | Promise<T | ExternalRef>;
|
package/src/index.core.ts
CHANGED
|
@@ -115,6 +115,38 @@ export type {
|
|
|
115
115
|
GlobalInitResponse,
|
|
116
116
|
TableCardinality,
|
|
117
117
|
} from "./protocol/types.js";
|
|
118
|
+
export type {
|
|
119
|
+
ScanSplit,
|
|
120
|
+
PlanResult,
|
|
121
|
+
TableFunctionPlanRequest,
|
|
122
|
+
} from "./protocol/serializers/splits.js";
|
|
123
|
+
export {
|
|
124
|
+
type FieldPath,
|
|
125
|
+
type FieldPathInit,
|
|
126
|
+
buildFieldPath,
|
|
127
|
+
encodeFieldPath,
|
|
128
|
+
decodeFieldPath,
|
|
129
|
+
type TransformSpec,
|
|
130
|
+
type TransformSpecInit,
|
|
131
|
+
buildTransformSpec,
|
|
132
|
+
encodeTransformSpec,
|
|
133
|
+
decodeTransformSpec,
|
|
134
|
+
type KeyGrouping,
|
|
135
|
+
type KeyGroupingInit,
|
|
136
|
+
buildKeyGrouping,
|
|
137
|
+
encodeKeyGrouping,
|
|
138
|
+
decodeKeyGrouping,
|
|
139
|
+
type RangeKey,
|
|
140
|
+
type RangeKeyInit,
|
|
141
|
+
buildRangeKey,
|
|
142
|
+
encodeRangeKey,
|
|
143
|
+
decodeRangeKey,
|
|
144
|
+
type RangePartitioning,
|
|
145
|
+
type RangePartitioningInit,
|
|
146
|
+
buildRangePartitioning,
|
|
147
|
+
encodeRangePartitioning,
|
|
148
|
+
decodeRangePartitioning,
|
|
149
|
+
} from "./generated/vgi-protocol-types.js";
|
|
118
150
|
|
|
119
151
|
// Arguments
|
|
120
152
|
export { Arguments } from "./arguments/arguments.js";
|
package/src/protocol/dispatch.ts
CHANGED
|
@@ -69,7 +69,7 @@ export { VGI_PROTOCOL_NAME };
|
|
|
69
69
|
* hash covers method names, types and the params/result/header schemas only
|
|
70
70
|
* (WIRE_PROTOCOL.md §14).
|
|
71
71
|
*
|
|
72
|
-
* It changes only with vgi.v3's protocol version (currently 3.
|
|
72
|
+
* It changes only with vgi.v3's protocol version (currently 3.1.0). Asserted
|
|
73
73
|
* by src/protocol/__tests__/vgi-v3-hash.test.ts; if that test fails, the
|
|
74
74
|
* surface drifted from the reference -- fix the schemas, do not bump this.
|
|
75
75
|
*/
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
TableFunctionPlanResultSchema,
|
|
11
11
|
} from "../../generated/vgi-protocol-schemas.js";
|
|
12
12
|
import type { BindRequest } from "../types.js";
|
|
13
|
+
import { OrderByDirection, OrderByNullOrder } from "../types.js";
|
|
13
14
|
import { deserializeBatch, batchToScalarDict } from "../../util/arrow/index.js";
|
|
14
15
|
import { toUint8Array } from "./shared.js";
|
|
15
16
|
import { deserializeBindRequest } from "./bind.js";
|
|
@@ -35,7 +36,16 @@ export interface ScanSplit {
|
|
|
35
36
|
* claiming client needs no cost model at all.
|
|
36
37
|
*/
|
|
37
38
|
estimatedBytes?: number | bigint | null;
|
|
38
|
-
/**
|
|
39
|
+
/** One-row exact transformed-key tuple aligned with `PlanResult.keyGrouping`. */
|
|
40
|
+
keyValue?: Uint8Array | null;
|
|
41
|
+
/** Zero-based range owned by this split under `PlanResult.rangePartitioning`. */
|
|
42
|
+
rangeIndex?: number | bigint | null;
|
|
43
|
+
/** Two-row (min, max) pruning batch; never an exact distribution claim. */
|
|
44
|
+
columnBounds?: Uint8Array | null;
|
|
45
|
+
/**
|
|
46
|
+
* Two-row (min, max) batch in the legacy `vgi_partition_values` encoding.
|
|
47
|
+
* @deprecated Protocol 3 producers should use `columnBounds`.
|
|
48
|
+
*/
|
|
39
49
|
partitionBounds?: Uint8Array | null;
|
|
40
50
|
columnStatistics?: Uint8Array | null;
|
|
41
51
|
locationIds?: number[] | null;
|
|
@@ -76,7 +86,21 @@ export interface PlanResult {
|
|
|
76
86
|
* cacheable and is not redeemable after commit or rollback.
|
|
77
87
|
*/
|
|
78
88
|
scope?: "catalog" | "transaction";
|
|
89
|
+
/** Hoisted host list indexed by each split's `locationIds`. */
|
|
90
|
+
locations?: string[] | null;
|
|
91
|
+
/** Serialized `KeyGrouping` shared by every page of this plan. */
|
|
92
|
+
keyGrouping?: Uint8Array | null;
|
|
93
|
+
/** Serialized `RangePartitioning` shared by every page of this plan. */
|
|
94
|
+
rangePartitioning?: Uint8Array | null;
|
|
95
|
+
/** @deprecated Protocol 3 producers should use `keyGrouping` or `rangePartitioning`. */
|
|
96
|
+
partitioning?: Uint8Array[] | null;
|
|
97
|
+
/** Serialized `SortField` records describing order within each split. */
|
|
98
|
+
sortOrder?: Uint8Array[] | null;
|
|
79
99
|
cacheMaxAgeSeconds?: number | null;
|
|
100
|
+
/** Actual exclusive lower data position selected by the worker. */
|
|
101
|
+
startPosition?: Uint8Array | null;
|
|
102
|
+
/** Data frontier resolved by the worker for this plan. */
|
|
103
|
+
endPosition?: Uint8Array | null;
|
|
80
104
|
}
|
|
81
105
|
|
|
82
106
|
/** The request a client sends to divide a scan. */
|
|
@@ -85,6 +109,8 @@ export interface TableFunctionPlanRequest {
|
|
|
85
109
|
bind_opaque_data: Uint8Array | null;
|
|
86
110
|
projection_ids: number[] | null;
|
|
87
111
|
pushdown_filters: Uint8Array | null;
|
|
112
|
+
join_keys: Uint8Array[] | null;
|
|
113
|
+
row_limit: bigint | null;
|
|
88
114
|
/** The primary sizing lever: every engine is byte-driven. */
|
|
89
115
|
target_split_bytes: bigint | null;
|
|
90
116
|
/**
|
|
@@ -92,12 +118,26 @@ export interface TableFunctionPlanRequest {
|
|
|
92
118
|
* per thread, which a byte target alone would not give it.
|
|
93
119
|
*/
|
|
94
120
|
min_splits: bigint | null;
|
|
121
|
+
/** Maximum number of splits to enumerate on this response page. */
|
|
122
|
+
max_splits_per_response: bigint | null;
|
|
95
123
|
/**
|
|
96
124
|
* A place in the ENUMERATION of splits — NOT a place in the data. A cursor
|
|
97
125
|
* lives for one plan call; a position is checkpointed and must survive
|
|
98
126
|
* restarts, upgrades and key rotation.
|
|
99
127
|
*/
|
|
100
128
|
cursor: Uint8Array | null;
|
|
129
|
+
/** Narrower filters supplied on a continuation request. */
|
|
130
|
+
refined_filters: Uint8Array | null;
|
|
131
|
+
/** False while the client may still send further filter refinement. */
|
|
132
|
+
filters_complete: boolean;
|
|
133
|
+
start_position: Uint8Array | null;
|
|
134
|
+
end_position: Uint8Array | null;
|
|
135
|
+
order_by_column_name: string | null;
|
|
136
|
+
order_by_direction: OrderByDirection | null;
|
|
137
|
+
order_by_null_order: OrderByNullOrder | null;
|
|
138
|
+
order_by_limit: bigint | null;
|
|
139
|
+
tablesample_percentage: number | null;
|
|
140
|
+
tablesample_seed: bigint | null;
|
|
101
141
|
}
|
|
102
142
|
|
|
103
143
|
/**
|
|
@@ -136,15 +176,43 @@ export function deserializePlanRequest(params: Record<string, any>): TableFuncti
|
|
|
136
176
|
|
|
137
177
|
const asBigInt = (v: unknown): bigint | null =>
|
|
138
178
|
v == null ? null : typeof v === "bigint" ? v : BigInt(Number(v));
|
|
179
|
+
const asBytes = (v: unknown): Uint8Array | null => v == null ? null : toUint8Array(v);
|
|
180
|
+
const asBytesList = (v: unknown): Uint8Array[] | null => {
|
|
181
|
+
if (v == null) return null;
|
|
182
|
+
const values = Array.isArray(v)
|
|
183
|
+
? v
|
|
184
|
+
: v && typeof (v as any)[Symbol.iterator] === "function"
|
|
185
|
+
? [...(v as Iterable<unknown>)]
|
|
186
|
+
: [];
|
|
187
|
+
return values.filter((entry) => entry != null).map(toUint8Array);
|
|
188
|
+
};
|
|
189
|
+
const enumValue = <T extends string>(v: unknown, values: readonly T[]): T | null => {
|
|
190
|
+
if (v == null) return null;
|
|
191
|
+
const text = String(v) as T;
|
|
192
|
+
return values.includes(text) ? text : null;
|
|
193
|
+
};
|
|
139
194
|
|
|
140
195
|
return {
|
|
141
196
|
bind_call: bindCall,
|
|
142
|
-
bind_opaque_data:
|
|
197
|
+
bind_opaque_data: asBytes(params.bind_opaque_data),
|
|
143
198
|
projection_ids: projectionIds,
|
|
144
|
-
pushdown_filters:
|
|
199
|
+
pushdown_filters: asBytes(params.pushdown_filters),
|
|
200
|
+
join_keys: asBytesList(params.join_keys),
|
|
201
|
+
row_limit: asBigInt(params.row_limit),
|
|
145
202
|
target_split_bytes: asBigInt(params.target_split_bytes),
|
|
146
203
|
min_splits: asBigInt(params.min_splits),
|
|
147
|
-
|
|
204
|
+
max_splits_per_response: asBigInt(params.max_splits_per_response),
|
|
205
|
+
cursor: asBytes(params.cursor),
|
|
206
|
+
refined_filters: asBytes(params.refined_filters),
|
|
207
|
+
filters_complete: params.filters_complete == null ? true : Boolean(params.filters_complete),
|
|
208
|
+
start_position: asBytes(params.start_position),
|
|
209
|
+
end_position: asBytes(params.end_position),
|
|
210
|
+
order_by_column_name: params.order_by_column_name == null ? null : String(params.order_by_column_name),
|
|
211
|
+
order_by_direction: enumValue(params.order_by_direction, Object.values(OrderByDirection)),
|
|
212
|
+
order_by_null_order: enumValue(params.order_by_null_order, Object.values(OrderByNullOrder)),
|
|
213
|
+
order_by_limit: asBigInt(params.order_by_limit),
|
|
214
|
+
tablesample_percentage: params.tablesample_percentage == null ? null : Number(params.tablesample_percentage),
|
|
215
|
+
tablesample_seed: asBigInt(params.tablesample_seed),
|
|
148
216
|
};
|
|
149
217
|
}
|
|
150
218
|
|
|
@@ -188,6 +256,9 @@ export function scanSplitRow(split: ScanSplit, token: Uint8Array): Record<string
|
|
|
188
256
|
estimated_rows: asBigInt(split.estimatedRows),
|
|
189
257
|
rows_exact: split.rowsExact === true,
|
|
190
258
|
estimated_bytes: asBigInt(split.estimatedBytes),
|
|
259
|
+
key_value: split.keyValue ?? null,
|
|
260
|
+
range_index: asBigInt(split.rangeIndex),
|
|
261
|
+
column_bounds: split.columnBounds ?? null,
|
|
191
262
|
partition_bounds: split.partitionBounds ?? null,
|
|
192
263
|
column_statistics: split.columnStatistics ?? null,
|
|
193
264
|
location_ids: split.locationIds ?? null,
|
|
@@ -211,11 +282,13 @@ export function planResponseRow(result: PlanResult, splitBlobs: Uint8Array[]): R
|
|
|
211
282
|
estimated_total_bytes: asBigInt(result.estimatedTotalBytes),
|
|
212
283
|
catalog_version: asBigInt(result.catalogVersion),
|
|
213
284
|
scope: result.scope ?? "catalog",
|
|
214
|
-
locations: null,
|
|
215
|
-
|
|
216
|
-
|
|
285
|
+
locations: result.locations ?? null,
|
|
286
|
+
key_grouping: result.keyGrouping ?? null,
|
|
287
|
+
range_partitioning: result.rangePartitioning ?? null,
|
|
288
|
+
partitioning: result.partitioning ?? null,
|
|
289
|
+
sort_order: result.sortOrder ?? null,
|
|
217
290
|
cache_max_age_seconds: asBigInt(result.cacheMaxAgeSeconds),
|
|
218
|
-
start_position:
|
|
219
|
-
end_position:
|
|
291
|
+
start_position: result.startPosition ?? null,
|
|
292
|
+
end_position: result.endPosition ?? null,
|
|
220
293
|
};
|
|
221
294
|
}
|