@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.
@@ -50,7 +50,7 @@ export { VGI_PROTOCOL_NAME };
50
50
  * hash covers method names, types and the params/result/header schemas only
51
51
  * (WIRE_PROTOCOL.md §14).
52
52
  *
53
- * It changes only with vgi.v3's protocol version (currently 3.0.0). Asserted
53
+ * It changes only with vgi.v3's protocol version (currently 3.1.0). Asserted
54
54
  * by src/protocol/__tests__/vgi-v3-hash.test.ts; if that test fails, the
55
55
  * surface drifted from the reference -- fix the schemas, do not bump this.
56
56
  */
@@ -1,5 +1,6 @@
1
1
  import { type VgiSchema } from "../../arrow/index.js";
2
2
  import type { BindRequest } from "../types.js";
3
+ import { OrderByDirection, OrderByNullOrder } from "../types.js";
3
4
  /**
4
5
  * One named, independently redeemable unit of scan work.
5
6
  *
@@ -21,7 +22,16 @@ export interface ScanSplit {
21
22
  * claiming client needs no cost model at all.
22
23
  */
23
24
  estimatedBytes?: number | bigint | null;
24
- /** 2-row (min, max) batch in the existing `vgi_partition_values` encoding. */
25
+ /** One-row exact transformed-key tuple aligned with `PlanResult.keyGrouping`. */
26
+ keyValue?: Uint8Array | null;
27
+ /** Zero-based range owned by this split under `PlanResult.rangePartitioning`. */
28
+ rangeIndex?: number | bigint | null;
29
+ /** Two-row (min, max) pruning batch; never an exact distribution claim. */
30
+ columnBounds?: Uint8Array | null;
31
+ /**
32
+ * Two-row (min, max) batch in the legacy `vgi_partition_values` encoding.
33
+ * @deprecated Protocol 3 producers should use `columnBounds`.
34
+ */
25
35
  partitionBounds?: Uint8Array | null;
26
36
  columnStatistics?: Uint8Array | null;
27
37
  locationIds?: number[] | null;
@@ -61,7 +71,21 @@ export interface PlanResult {
61
71
  * cacheable and is not redeemable after commit or rollback.
62
72
  */
63
73
  scope?: "catalog" | "transaction";
74
+ /** Hoisted host list indexed by each split's `locationIds`. */
75
+ locations?: string[] | null;
76
+ /** Serialized `KeyGrouping` shared by every page of this plan. */
77
+ keyGrouping?: Uint8Array | null;
78
+ /** Serialized `RangePartitioning` shared by every page of this plan. */
79
+ rangePartitioning?: Uint8Array | null;
80
+ /** @deprecated Protocol 3 producers should use `keyGrouping` or `rangePartitioning`. */
81
+ partitioning?: Uint8Array[] | null;
82
+ /** Serialized `SortField` records describing order within each split. */
83
+ sortOrder?: Uint8Array[] | null;
64
84
  cacheMaxAgeSeconds?: number | null;
85
+ /** Actual exclusive lower data position selected by the worker. */
86
+ startPosition?: Uint8Array | null;
87
+ /** Data frontier resolved by the worker for this plan. */
88
+ endPosition?: Uint8Array | null;
65
89
  }
66
90
  /** The request a client sends to divide a scan. */
67
91
  export interface TableFunctionPlanRequest {
@@ -69,6 +93,8 @@ export interface TableFunctionPlanRequest {
69
93
  bind_opaque_data: Uint8Array | null;
70
94
  projection_ids: number[] | null;
71
95
  pushdown_filters: Uint8Array | null;
96
+ join_keys: Uint8Array[] | null;
97
+ row_limit: bigint | null;
72
98
  /** The primary sizing lever: every engine is byte-driven. */
73
99
  target_split_bytes: bigint | null;
74
100
  /**
@@ -76,12 +102,26 @@ export interface TableFunctionPlanRequest {
76
102
  * per thread, which a byte target alone would not give it.
77
103
  */
78
104
  min_splits: bigint | null;
105
+ /** Maximum number of splits to enumerate on this response page. */
106
+ max_splits_per_response: bigint | null;
79
107
  /**
80
108
  * A place in the ENUMERATION of splits — NOT a place in the data. A cursor
81
109
  * lives for one plan call; a position is checkpointed and must survive
82
110
  * restarts, upgrades and key rotation.
83
111
  */
84
112
  cursor: Uint8Array | null;
113
+ /** Narrower filters supplied on a continuation request. */
114
+ refined_filters: Uint8Array | null;
115
+ /** False while the client may still send further filter refinement. */
116
+ filters_complete: boolean;
117
+ start_position: Uint8Array | null;
118
+ end_position: Uint8Array | null;
119
+ order_by_column_name: string | null;
120
+ order_by_direction: OrderByDirection | null;
121
+ order_by_null_order: OrderByNullOrder | null;
122
+ order_by_limit: bigint | null;
123
+ tablesample_percentage: number | null;
124
+ tablesample_seed: bigint | null;
85
125
  }
86
126
  /**
87
127
  * The ScanSplit shape, from codegen rather than hand-written.
@@ -2955,6 +2955,18 @@ function deserializeBindResponse(params) {
2955
2955
  repeatability: parseBindRepeatability(params.repeatability)
2956
2956
  };
2957
2957
  }
2958
+ // src/protocol/types.ts
2959
+ var OrderByDirection;
2960
+ ((OrderByDirection) => {
2961
+ OrderByDirection["ASC"] = "ASC";
2962
+ OrderByDirection["DESC"] = "DESC";
2963
+ })(OrderByDirection ||= {});
2964
+ var OrderByNullOrder;
2965
+ ((OrderByNullOrder) => {
2966
+ OrderByNullOrder["NULLS_FIRST"] = "NULLS_FIRST";
2967
+ OrderByNullOrder["NULLS_LAST"] = "NULLS_LAST";
2968
+ })(OrderByNullOrder ||= {});
2969
+
2958
2970
  // src/protocol/serializers/init.ts
2959
2971
  var INIT_REQUEST_SCHEMA = schema2([
2960
2972
  field2("bind_call", binary2(), false),
@@ -3396,7 +3408,7 @@ import {
3396
3408
  Protocol
3397
3409
  } from "@query-farm/vgi-rpc";
3398
3410
  var VGI_PROTOCOL_NAME = "vgi.v3";
3399
- var VGI_PROTOCOL_VERSION = "3.0.0";
3411
+ var VGI_PROTOCOL_VERSION = "3.1.0";
3400
3412
  function exchangeStream(callbacks) {
3401
3413
  return { kind: "exchange", ...callbacks };
3402
3414
  }
@@ -4986,6 +4998,26 @@ var CopyFromFormatInfoSchema = schema2([
4986
4998
  field2("description", utf82(), false),
4987
4999
  field2("ordered", bool2(), false)
4988
5000
  ]);
5001
+ var FieldPathSchema = schema2([
5002
+ field2("components", list2(field2("item", utf82(), true)), false)
5003
+ ]);
5004
+ var TransformSpecSchema = schema2([
5005
+ field2("id", utf82(), false),
5006
+ field2("inputs", list2(field2("item", binary2(), true)), false),
5007
+ field2("parameters", binary2(), true)
5008
+ ]);
5009
+ var KeyGroupingSchema = schema2([
5010
+ field2("keys", list2(field2("item", binary2(), true)), false)
5011
+ ]);
5012
+ var RangeKeySchema = schema2([
5013
+ field2("transform", binary2(), false),
5014
+ field2("direction", dictionary2(utf82(), int162()), false),
5015
+ field2("null_order", dictionary2(utf82(), int162()), false)
5016
+ ]);
5017
+ var RangePartitioningSchema = schema2([
5018
+ field2("keys", list2(field2("item", binary2(), true)), false),
5019
+ field2("split_points", binary2(), false)
5020
+ ]);
4989
5021
  var MacroParameterSchema = schema2([
4990
5022
  field2("name", utf82(), false),
4991
5023
  field2("declared_type", binary2(), true),
@@ -5216,6 +5248,9 @@ var ScanSplitSchema = schema2([
5216
5248
  field2("estimated_rows", int642(), true),
5217
5249
  field2("rows_exact", bool2(), false),
5218
5250
  field2("estimated_bytes", int642(), true),
5251
+ field2("key_value", binary2(), true),
5252
+ field2("range_index", int642(), true),
5253
+ field2("column_bounds", binary2(), true),
5219
5254
  field2("partition_bounds", binary2(), true),
5220
5255
  field2("column_statistics", binary2(), true),
5221
5256
  field2("location_ids", list2(field2("item", int642(), true)), true),
@@ -5691,6 +5726,8 @@ var TableFunctionPlanResultSchema = schema2([
5691
5726
  field2("catalog_version", int642(), true),
5692
5727
  field2("scope", utf82(), false),
5693
5728
  field2("locations", list2(field2("item", utf82(), true)), true),
5729
+ field2("key_grouping", binary2(), true),
5730
+ field2("range_partitioning", binary2(), true),
5694
5731
  field2("partitioning", list2(field2("item", binary2(), true)), true),
5695
5732
  field2("sort_order", list2(field2("item", binary2(), true)), true),
5696
5733
  field2("cache_max_age_seconds", int642(), true),
@@ -8328,14 +8365,40 @@ function deserializePlanRequest(params) {
8328
8365
  projectionIds = [...raw].map(Number);
8329
8366
  }
8330
8367
  const asBigInt = (v) => v == null ? null : typeof v === "bigint" ? v : BigInt(Number(v));
8368
+ const asBytes = (v) => v == null ? null : toUint8Array2(v);
8369
+ const asBytesList = (v) => {
8370
+ if (v == null)
8371
+ return null;
8372
+ const values = Array.isArray(v) ? v : v && typeof v[Symbol.iterator] === "function" ? [...v] : [];
8373
+ return values.filter((entry) => entry != null).map(toUint8Array2);
8374
+ };
8375
+ const enumValue = (v, values) => {
8376
+ if (v == null)
8377
+ return null;
8378
+ const text = String(v);
8379
+ return values.includes(text) ? text : null;
8380
+ };
8331
8381
  return {
8332
8382
  bind_call: bindCall,
8333
- bind_opaque_data: params.bind_opaque_data ? toUint8Array2(params.bind_opaque_data) : null,
8383
+ bind_opaque_data: asBytes(params.bind_opaque_data),
8334
8384
  projection_ids: projectionIds,
8335
- pushdown_filters: params.pushdown_filters ? toUint8Array2(params.pushdown_filters) : null,
8385
+ pushdown_filters: asBytes(params.pushdown_filters),
8386
+ join_keys: asBytesList(params.join_keys),
8387
+ row_limit: asBigInt(params.row_limit),
8336
8388
  target_split_bytes: asBigInt(params.target_split_bytes),
8337
8389
  min_splits: asBigInt(params.min_splits),
8338
- cursor: params.cursor ? toUint8Array2(params.cursor) : null
8390
+ max_splits_per_response: asBigInt(params.max_splits_per_response),
8391
+ cursor: asBytes(params.cursor),
8392
+ refined_filters: asBytes(params.refined_filters),
8393
+ filters_complete: params.filters_complete == null ? true : Boolean(params.filters_complete),
8394
+ start_position: asBytes(params.start_position),
8395
+ end_position: asBytes(params.end_position),
8396
+ order_by_column_name: params.order_by_column_name == null ? null : String(params.order_by_column_name),
8397
+ order_by_direction: enumValue(params.order_by_direction, Object.values(OrderByDirection)),
8398
+ order_by_null_order: enumValue(params.order_by_null_order, Object.values(OrderByNullOrder)),
8399
+ order_by_limit: asBigInt(params.order_by_limit),
8400
+ tablesample_percentage: params.tablesample_percentage == null ? null : Number(params.tablesample_percentage),
8401
+ tablesample_seed: asBigInt(params.tablesample_seed)
8339
8402
  };
8340
8403
  }
8341
8404
  function fingerprintInputs(bindCallBytes) {
@@ -8355,6 +8418,9 @@ function scanSplitRow(split, token) {
8355
8418
  estimated_rows: asBigInt(split.estimatedRows),
8356
8419
  rows_exact: split.rowsExact === true,
8357
8420
  estimated_bytes: asBigInt(split.estimatedBytes),
8421
+ key_value: split.keyValue ?? null,
8422
+ range_index: asBigInt(split.rangeIndex),
8423
+ column_bounds: split.columnBounds ?? null,
8358
8424
  partition_bounds: split.partitionBounds ?? null,
8359
8425
  column_statistics: split.columnStatistics ?? null,
8360
8426
  location_ids: split.locationIds ?? null,
@@ -8375,12 +8441,14 @@ function planResponseRow(result, splitBlobs) {
8375
8441
  estimated_total_bytes: asBigInt(result.estimatedTotalBytes),
8376
8442
  catalog_version: asBigInt(result.catalogVersion),
8377
8443
  scope: result.scope ?? "catalog",
8378
- locations: null,
8379
- partitioning: [],
8380
- sort_order: [],
8444
+ locations: result.locations ?? null,
8445
+ key_grouping: result.keyGrouping ?? null,
8446
+ range_partitioning: result.rangePartitioning ?? null,
8447
+ partitioning: result.partitioning ?? null,
8448
+ sort_order: result.sortOrder ?? null,
8381
8449
  cache_max_age_seconds: asBigInt(result.cacheMaxAgeSeconds),
8382
- start_position: new Uint8Array(0),
8383
- end_position: new Uint8Array(0)
8450
+ start_position: result.startPosition ?? null,
8451
+ end_position: result.endPosition ?? null
8384
8452
  };
8385
8453
  }
8386
8454
 
@@ -11834,4 +11902,4 @@ export {
11834
11902
  serveVgiWorker
11835
11903
  };
11836
11904
 
11837
- //# debugId=CFEC3B6AACFA587664756E2164756E21
11905
+ //# debugId=C9BDB2DE50B86FAE64756E2164756E21