@query-farm/vgi 0.48.6 → 0.49.1

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/src/index.core.ts CHANGED
@@ -272,6 +272,17 @@ export {
272
272
 
273
273
  // Column statistics (for inlining on TableInfo.column_statistics).
274
274
  export { type ColumnStatistics, serializeColumnStatistics } from "./util/statistics.js";
275
+ // Protocol 3.2 filtered scan planning (TableInfo.scan_planning, tableScanBranchesPlan).
276
+ export {
277
+ ScanPlanningFilters,
278
+ filtersMayMatch,
279
+ validateScanPlanning,
280
+ SCAN_PLANNING_BIND,
281
+ SCAN_PLANNING_FILTERED,
282
+ SCAN_PLANNING_MODES,
283
+ type ScanPlanningMode,
284
+ type ScanCandidateStatistics,
285
+ } from "./catalog/scan-planning.js";
275
286
 
276
287
  // Byte utilities
277
288
  export { toUint8Array } from "./util/bytes.js";
@@ -80,11 +80,11 @@ export { VGI_PROTOCOL_NAME };
80
80
  * hash covers method names, types and the params/result/header schemas only
81
81
  * (WIRE_PROTOCOL.md §14).
82
82
  *
83
- * It changes only with vgi.v3's protocol version (currently 3.1.0). Asserted
83
+ * It changes only with vgi.v3's protocol version (currently 3.2.0). Asserted
84
84
  * by src/protocol/__tests__/vgi-v3-hash.test.ts; if that test fails, the
85
85
  * surface drifted from the reference -- fix the schemas, do not bump this.
86
86
  */
87
- export const VGI_V3_PROTOCOL_HASH = "50e9404173bee3262e96b8939eb5c425463336abca2a17916812d68b6e0f6cad";
87
+ export const VGI_V3_PROTOCOL_HASH = "171ac8263bf22ffdd5dd4ac2c3d3c4e1dc186a7ceba45d386f324af8c9c6fced";
88
88
 
89
89
  /**
90
90
  * This worker's `vgi.v3` implementation: the generated UNIMPLEMENTED default
@@ -13,6 +13,8 @@ import {
13
13
  ScanFunctionResultSchema,
14
14
  } from "../../../generated/vgi-protocol-schemas.js";
15
15
  import { toUint8Array } from "../../../util/bytes.js";
16
+ import { deserializeSchema } from "../../../arrow/index.js";
17
+ import { ScanPlanningFilters } from "../../../catalog/scan-planning.js";
16
18
  import { requireCreateColumns } from "../../../catalog/unconstrained-columns.js";
17
19
  import { CONSTRAINT_CREATE, CONSTRAINT_ENFORCE, CONSTRAINT_MUTATE, readConstraintRecord } from "../../../catalog/constraints.js";
18
20
  import { decodeCatalogObjectRef } from "../../../generated/vgi-protocol-types.js";
@@ -201,16 +203,25 @@ export function catalogTableHandlers(getCatalog: GetCatalog, signingKey?: Uint8A
201
203
  // catalog_table_scan_branches_get — branches-aware variant of
202
204
  // scan_function_get. The branches-aware C++ extension calls this for every
203
205
  // table scan; single-source catalogs synthesise a one-branch result.
206
+ //
207
+ // Protocol 3.2: always dispatches to tableScanBranchesPlan with the
208
+ // `pushdown_filters` wrapped as a ScanPlanningFilters (decoded lazily against
209
+ // the table's declared columns); its default returns tableScanBranchesGet.
204
210
  const catalogTableScanBranchesGet = catalogHandler(keys, async (params) => {
205
211
  const cat = getCatalog();
206
- const branchesResult = await cat.tableScanBranchesGet(
207
- toUint8Array(params.attach_opaque_data),
208
- params.schema_path,
209
- params.name,
210
- params.at_unit,
211
- params.at_value,
212
- params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined
213
- );
212
+ const attach = toUint8Array(params.attach_opaque_data);
213
+ const tx = params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined;
214
+ const schemaPath = params.schema_path;
215
+ const name = params.name;
216
+ const atUnit = params.at_unit;
217
+ const atValue = params.at_value;
218
+ const filters = params.pushdown_filters != null
219
+ ? new ScanPlanningFilters(toUint8Array(params.pushdown_filters), async () => {
220
+ const info = await cat.tableGet(attach, schemaPath, name, atUnit, atValue, tx);
221
+ return info && info.columns.length ? deserializeSchema(toUint8Array(info.columns)) : null;
222
+ })
223
+ : null;
224
+ const branchesResult = await cat.tableScanBranchesPlan(attach, schemaPath, name, atUnit, atValue, tx, filters);
214
225
  return wrapResult(branchesResult, ScanBranchesResultSchema);
215
226
  });
216
227
 
@@ -63,6 +63,12 @@ export {
63
63
  serializeAttachOptionSpec,
64
64
  serializeAttachOptionSpecs,
65
65
  serializeColumnStatistics,
66
+ // Multi-branch scans and protocol 3.2 filtered scan planning.
67
+ buildScanBranchesResult,
68
+ ScanPlanningFilters,
69
+ filtersMayMatch,
70
+ SCAN_PLANNING_BIND,
71
+ SCAN_PLANNING_FILTERED,
66
72
  BindResultSchema,
67
73
  ScanFunctionResultSchema,
68
74
  // Resolved-secret selection (the batch is keyed by secret NAME, not type).
@@ -83,6 +89,9 @@ export type {
83
89
  CacheScope,
84
90
  AttachOptionSpec,
85
91
  ColumnStatistics,
92
+ ScanBranchInput,
93
+ ScanPlanningMode,
94
+ ScanCandidateStatistics,
86
95
  CatalogAttachResult,
87
96
  CatalogDescriptor,
88
97
  CatalogInfo,