@query-farm/vgi 0.47.2 → 0.48.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.
Files changed (105) hide show
  1. package/README.md +1 -1
  2. package/dist/arguments/argument-spec.d.ts +17 -11
  3. package/dist/catalog/descriptors.d.ts +2 -2
  4. package/dist/catalog/publication.d.ts +7 -7
  5. package/dist/client/client.d.ts +9 -3
  6. package/dist/client/errors.d.ts +2 -2
  7. package/dist/client/types.d.ts +21 -0
  8. package/dist/client-entry.d.ts +1 -1
  9. package/dist/client-entry.js +56 -7
  10. package/dist/client-entry.js.map +23 -23
  11. package/dist/filter-pushdown/deserialize.d.ts +1 -1
  12. package/dist/filter-pushdown/types.d.ts +10 -10
  13. package/dist/functions/scalar.d.ts +1 -1
  14. package/dist/functions/table-buffering.d.ts +20 -20
  15. package/dist/functions/table-in-out.d.ts +4 -4
  16. package/dist/functions/table.d.ts +7 -7
  17. package/dist/functions/types.d.ts +47 -47
  18. package/dist/generated/vgi-client.d.ts +5 -0
  19. package/dist/generated/vgi-protocol-schemas.d.ts +5 -0
  20. package/dist/generated/vgi-protocol-types.d.ts +57 -0
  21. package/dist/generated/vgi-service.d.ts +1 -1
  22. package/dist/http/fetch.d.ts +10 -10
  23. package/dist/index.core.d.ts +3 -1
  24. package/dist/index.js +289 -103
  25. package/dist/index.js.map +57 -55
  26. package/dist/protocol/dispatch.d.ts +4 -4
  27. package/dist/protocol/handlers/function.d.ts +2 -2
  28. package/dist/protocol/serializers/cardinality.d.ts +4 -1
  29. package/dist/protocol/serializers/splits.d.ts +41 -1
  30. package/dist/protocol/types.d.ts +5 -5
  31. package/dist/rpc-server.d.ts +6 -6
  32. package/dist/serve-entry.d.ts +16 -16
  33. package/dist/serve-entry.js +119 -30
  34. package/dist/serve-entry.js.map +42 -40
  35. package/dist/split-token.d.ts +6 -6
  36. package/dist/types.d.ts +9 -2
  37. package/dist/util/defined.d.ts +21 -0
  38. package/dist/worker-cf-entry.js +199 -94
  39. package/dist/worker-cf-entry.js.map +55 -53
  40. package/dist/worker.d.ts +2 -2
  41. package/package.json +6 -4
  42. package/src/arguments/argument-spec.ts +17 -11
  43. package/src/arrow/codec/registry.ts +2 -2
  44. package/src/arrow/impl-arrowjs/build.ts +1 -1
  45. package/src/arrow/impl-arrowjs/canonical.ts +23 -23
  46. package/src/arrow/impl-arrowjs/empty.ts +2 -2
  47. package/src/arrow/impl-arrowjs/ipc.ts +2 -2
  48. package/src/arrow/impl-arrowjs/iterate.ts +2 -2
  49. package/src/arrow/impl-arrowjs/project.ts +2 -2
  50. package/src/arrow/impl-flechette/build.ts +2 -1
  51. package/src/arrow/impl-flechette/canonical.ts +10 -9
  52. package/src/arrow/impl-flechette/compat.ts +3 -3
  53. package/src/arrow/impl-flechette/message-meta.ts +5 -4
  54. package/src/arrow/impl-flechette/statistics.ts +2 -2
  55. package/src/attach-ticket.ts +2 -2
  56. package/src/catalog/column-metadata.ts +1 -1
  57. package/src/catalog/composite.ts +2 -2
  58. package/src/catalog/constraints.ts +9 -9
  59. package/src/catalog/descriptors.ts +1 -1
  60. package/src/catalog/interface.ts +12 -12
  61. package/src/catalog/publication.ts +9 -8
  62. package/src/catalog/read-only.ts +9 -8
  63. package/src/catalog/sql-grammar.ts +6 -6
  64. package/src/client/client.ts +52 -15
  65. package/src/client/errors.ts +1 -1
  66. package/src/client/types.ts +23 -0
  67. package/src/client-entry.ts +2 -0
  68. package/src/codec/asd.ts +3 -3
  69. package/src/codec/conform.ts +3 -3
  70. package/src/filter-pushdown/collector.ts +1 -1
  71. package/src/filter-pushdown/deserialize.ts +13 -10
  72. package/src/filter-pushdown/evaluate.ts +3 -2
  73. package/src/filter-pushdown/history.ts +3 -2
  74. package/src/filter-pushdown/types.ts +10 -10
  75. package/src/functions/continuation.ts +1 -1
  76. package/src/functions/projection.ts +1 -1
  77. package/src/functions/registry.ts +14 -14
  78. package/src/functions/scalar.ts +3 -3
  79. package/src/functions/storage-cf-do.ts +2 -2
  80. package/src/functions/table-buffering.ts +25 -21
  81. package/src/functions/table-in-out.ts +8 -8
  82. package/src/functions/table.ts +27 -25
  83. package/src/functions/types.ts +47 -47
  84. package/src/generated/vgi-client.ts +6 -1
  85. package/src/generated/vgi-protocol-schemas.ts +36 -1
  86. package/src/generated/vgi-protocol-types.ts +130 -1
  87. package/src/generated/vgi-service.ts +7 -5
  88. package/src/http/fetch.ts +17 -12
  89. package/src/index.core.ts +34 -0
  90. package/src/protocol/carried-init-request.ts +1 -1
  91. package/src/protocol/dispatch.ts +4 -4
  92. package/src/protocol/handlers/aggregate.ts +8 -7
  93. package/src/protocol/handlers/catalog/shared.ts +1 -1
  94. package/src/protocol/handlers/function.ts +2 -2
  95. package/src/protocol/serializers/cardinality.ts +16 -3
  96. package/src/protocol/serializers/splits.ts +82 -9
  97. package/src/protocol/state-serializer.ts +1 -1
  98. package/src/protocol/types.ts +5 -5
  99. package/src/rpc-server.ts +13 -12
  100. package/src/serve-entry.ts +18 -18
  101. package/src/split-token.ts +10 -9
  102. package/src/types.ts +9 -2
  103. package/src/util/defined.ts +30 -0
  104. package/src/util/parent-rows.ts +2 -2
  105. package/src/worker.ts +15 -14
package/README.md CHANGED
@@ -40,7 +40,7 @@ npm install @query-farm/vgi
40
40
 
41
41
  Requires **Node.js ≥ 22.15** or **Bun**.
42
42
 
43
- Version 0.47.0 uses **`vgi.v3` / `3.0.0`** and requires a matching VGI
43
+ This branch uses **`vgi.v3` / `3.1.0`** and requires a matching VGI
44
44
  extension. Existing `vgi.v2` extensions need SDK 0.46.x; upgrade the engine-side
45
45
  extension and workers together. This release prepares the shared protocol for
46
46
  DuckDB 2.0; it does not require upgrading DuckDB itself. See
@@ -3,11 +3,11 @@ export interface ArgumentSpec {
3
3
  name: string;
4
4
  position: number | string;
5
5
  arrowType: VgiDataType;
6
- isTableInput?: boolean;
7
- isAnyType?: boolean;
8
- isVarargs?: boolean;
9
- isConst?: boolean;
10
- doc?: string;
6
+ isTableInput?: boolean | undefined;
7
+ isAnyType?: boolean | undefined;
8
+ isVarargs?: boolean | undefined;
9
+ isConst?: boolean | undefined;
10
+ doc?: string | undefined;
11
11
  /**
12
12
  * Discovery-facing constraint metadata, pre-encoded to their surfaced UTF-8
13
13
  * forms (presence-only — `undefined` means the constraint is absent and the
@@ -15,10 +15,10 @@ export interface ArgumentSpec {
15
15
  * `ArgumentSpec.default_json` / `choices_json` / `range_notation` / `pattern`
16
16
  * so `argumentSpecsToSchema`/`schemaToArgumentSpecs` round-trip symmetrically.
17
17
  */
18
- defaultJson?: string;
19
- choicesJson?: string;
20
- rangeNotation?: string;
21
- pattern?: string;
18
+ defaultJson?: string | undefined;
19
+ choicesJson?: string | undefined;
20
+ rangeNotation?: string | undefined;
21
+ pattern?: string | undefined;
22
22
  }
23
23
  /**
24
24
  * Raw per-argument constraint declarations, as authored on a function's
@@ -36,7 +36,11 @@ export interface ArgumentConstraints {
36
36
  gt?: number;
37
37
  /** Exclusive upper bound (`<`). */
38
38
  lt?: number;
39
- /** Regex the value must match (surfaced as `vgi_pattern`, as-is). */
39
+ /**
40
+ * Regex the value must match (surfaced as `vgi_pattern`, as-is). Matching is
41
+ * an UNANCHORED search (JSON Schema / ECMA-262 semantics, same across SDKs):
42
+ * `"\\d"` accepts `"ab1"`. Anchor with `^...$` to require a full match.
43
+ */
40
44
  pattern?: string;
41
45
  /** Default value (JSON-encoded into `vgi_default`); optional args only. */
42
46
  default?: unknown;
@@ -117,7 +121,9 @@ export declare function assertArrowTypes(types: Record<string, unknown> | undefi
117
121
  * Enforce a bind-time const value against its declared {@link ArgumentConstraints},
118
122
  * throwing {@link ArgumentValidationError} on violation. Mirrors the Python SDK's
119
123
  * `Arg._validate`: numeric range (`ge`/`le`/`gt`/`lt`), closed choice set, and
120
- * regex `pattern`. A `null`/`undefined` value skips its value constraints.
124
+ * regex `pattern` (an unanchored search — `RegExp.prototype.test`, matching the
125
+ * JSON Schema `pattern` keyword). A `null`/`undefined` value skips its value
126
+ * constraints.
121
127
  */
122
128
  export declare function validateConstConstraints(name: string, constraints: ArgumentConstraints, value: unknown): void;
123
129
  /**
@@ -85,8 +85,8 @@ export interface TableDescriptor {
85
85
  * tables; static-column tables don't have a function to call.
86
86
  */
87
87
  inlinedCardinality?: {
88
- estimate: bigint;
89
- max: bigint;
88
+ estimate: number | bigint;
89
+ max: number | bigint;
90
90
  };
91
91
  comment?: string;
92
92
  tags?: Record<string, string>;
@@ -11,7 +11,7 @@ export interface SnapshotIdentity {
11
11
  export interface SnapshotRequest {
12
12
  catalog: CatalogInterface;
13
13
  attachOpaqueData: AttachOpaqueData;
14
- callContext?: CallContext;
14
+ callContext?: CallContext | undefined;
15
15
  catalogVersion: number;
16
16
  }
17
17
  export interface CatalogPublicationManifest {
@@ -29,9 +29,9 @@ export interface CatalogPublicationManifest {
29
29
  rawSize: number;
30
30
  storedSize: number;
31
31
  url: string;
32
- objectId?: string;
33
- expiresAt?: number;
34
- retainUntil?: number;
32
+ objectId?: string | undefined;
33
+ expiresAt?: number | undefined;
34
+ retainUntil?: number | undefined;
35
35
  stable: boolean;
36
36
  validated: true;
37
37
  }
@@ -87,9 +87,9 @@ export declare class MemoryCatalogPublicationRepository implements CatalogPublic
87
87
  rawSize: number;
88
88
  storedSize: number;
89
89
  url: string;
90
- objectId?: string;
91
- expiresAt?: number;
92
- retainUntil?: number;
90
+ objectId?: string | undefined;
91
+ expiresAt?: number | undefined;
92
+ retainUntil?: number | undefined;
93
93
  stable: boolean;
94
94
  validated: true;
95
95
  }>>;
@@ -3,7 +3,7 @@ import type { RpcClient, StreamSession } from "@query-farm/vgi-rpc";
3
3
  import { type SchemaInfo, type TableInfo, type ViewInfo, type FunctionInfo, type MacroInfo, type MacroType, type CatalogAttachResult, type SchemaContentsInfo, type IndexInfo, type AttachOpaqueData, type TransactionOpaqueData, type CatalogInfo, type ScanFunctionResult } from "../catalog/interface.js";
4
4
  import { VgiClientError } from "./errors.js";
5
5
  export { VgiClientError };
6
- import type { VgiClientOptions, TableFunctionOptions, ScalarFunctionOptions, TableInOutFunctionOptions, OnCreateConflict, CatalogFunctionType, CatalogMacroType, CatalogAttachOptions, AttachOptionValue, CatalogSnapshot, LoadCatalogOptions } from "./types.js";
6
+ import type { VgiClientOptions, TableFunctionOptions, TableFunctionRowsOptions, ScalarFunctionOptions, TableInOutFunctionOptions, OnCreateConflict, CatalogFunctionType, CatalogMacroType, CatalogAttachOptions, AttachOptionValue, CatalogSnapshot, LoadCatalogOptions } from "./types.js";
7
7
  /**
8
8
  * Send one input batch on a table-in-out exchange and yield the rows of every
9
9
  * reply it gets (continued output, docs/table_in_out.md "Continued Output").
@@ -75,8 +75,14 @@ export declare class VgiClient {
75
75
  tableInOutFunctionRows(opts: TableInOutFunctionOptions): AsyncGenerator<Record<string, any>[]>;
76
76
  /** Call a table-in-out function, yielding output as RecordBatch instances. */
77
77
  tableInOutFunction(opts: TableInOutFunctionOptions): AsyncGenerator<VgiBatch>;
78
- /** Call a table function, yielding output as row objects. */
79
- tableFunctionRows(opts: TableFunctionOptions): AsyncGenerator<Record<string, any>[]>;
78
+ /**
79
+ * Call a table function, yielding output as row objects.
80
+ *
81
+ * int64/uint64 columns follow `opts.int64` (see {@link Int64Mode}); pass
82
+ * `int64: "bigint"` to get a `bigint` for every value instead of a
83
+ * magnitude-dependent mix of `number` and `bigint`.
84
+ */
85
+ tableFunctionRows(opts: TableFunctionRowsOptions): AsyncGenerator<Record<string, any>[]>;
80
86
  /**
81
87
  * List all catalogs with their advertised version metadata.
82
88
  *
@@ -7,8 +7,8 @@ export declare class VgiClientError extends Error {
7
7
  /** Underlying error type from the worker (e.g. "ValueError"), when known. */
8
8
  readonly errorType?: string;
9
9
  constructor(message: string, options?: {
10
- remoteTraceback?: string;
11
- errorType?: string;
10
+ remoteTraceback?: string | undefined;
11
+ errorType?: string | undefined;
12
12
  cause?: unknown;
13
13
  });
14
14
  /**
@@ -84,6 +84,27 @@ export interface TableFunctionOptions {
84
84
  /** Invoked after bind, before init. Receives the bind response. */
85
85
  onBind?: BindResultCallback;
86
86
  }
87
+ /**
88
+ * How {@link VgiClient.tableFunctionRows} surfaces int64/uint64 column
89
+ * values. Same vocabulary as `@query-farm/vgi-rpc`'s client `int64` option.
90
+ *
91
+ * - `"number-if-safe"`: values within `Number.MAX_SAFE_INTEGER` become
92
+ * `number`, larger ones stay `bigint` (one column can hold both).
93
+ * - `"bigint"`: every value stays a `bigint` — one JS type per column.
94
+ */
95
+ export type Int64Mode = "number-if-safe" | "bigint";
96
+ /** Options for {@link VgiClient.tableFunctionRows}. */
97
+ export interface TableFunctionRowsOptions extends TableFunctionOptions {
98
+ /**
99
+ * Surfacing of top-level int64/uint64 output columns (see {@link Int64Mode}).
100
+ * When omitted, rows are returned as the underlying `RpcClient` produced
101
+ * them — `"number-if-safe"` unless that client was created with
102
+ * `int64: "bigint"` (`@query-farm/vgi-rpc` >= 0.29.6). Setting it here
103
+ * overrides the client either way. The omitted-default may become
104
+ * `"bigint"` in a future minor release; pass it explicitly to pin it.
105
+ */
106
+ int64?: Int64Mode;
107
+ }
87
108
  /** Options for calling a scalar function. */
88
109
  export interface ScalarFunctionOptions {
89
110
  /** Name of the function to call. */
@@ -1,5 +1,5 @@
1
1
  export { VgiClient, VgiClientError } from "./client/client.js";
2
- export type { VgiClientOptions, TableFunctionOptions, ScalarFunctionOptions, TableInOutFunctionOptions, OnCreateConflict, CatalogFunctionType, } from "./client/types.js";
2
+ export type { VgiClientOptions, TableFunctionOptions, TableFunctionRowsOptions, Int64Mode, ScalarFunctionOptions, TableInOutFunctionOptions, OnCreateConflict, CatalogFunctionType, } from "./client/types.js";
3
3
  export { Arguments } from "./arguments/arguments.js";
4
4
  export { type ArgumentSpec, argumentSpecsToSchema, schemaToArgumentSpecs, } from "./arguments/argument-spec.js";
5
5
  export { FunctionType, FunctionStability, NullHandling, ArgumentMonotonicity, OrderPreservation, OrderDependence, DistinctDependence, TableInOutPhase, } from "./types.js";
@@ -2765,6 +2765,26 @@ var CopyFromFormatInfoSchema = schema2([
2765
2765
  field2("description", utf82(), false),
2766
2766
  field2("ordered", bool2(), false)
2767
2767
  ]);
2768
+ var FieldPathSchema = schema2([
2769
+ field2("components", list2(field2("item", utf82(), true)), false)
2770
+ ]);
2771
+ var TransformSpecSchema = schema2([
2772
+ field2("id", utf82(), false),
2773
+ field2("inputs", list2(field2("item", binary2(), true)), false),
2774
+ field2("parameters", binary2(), true)
2775
+ ]);
2776
+ var KeyGroupingSchema = schema2([
2777
+ field2("keys", list2(field2("item", binary2(), true)), false)
2778
+ ]);
2779
+ var RangeKeySchema = schema2([
2780
+ field2("transform", binary2(), false),
2781
+ field2("direction", dictionary2(utf82(), int162()), false),
2782
+ field2("null_order", dictionary2(utf82(), int162()), false)
2783
+ ]);
2784
+ var RangePartitioningSchema = schema2([
2785
+ field2("keys", list2(field2("item", binary2(), true)), false),
2786
+ field2("split_points", binary2(), false)
2787
+ ]);
2768
2788
  var MacroParameterSchema = schema2([
2769
2789
  field2("name", utf82(), false),
2770
2790
  field2("declared_type", binary2(), true),
@@ -2995,6 +3015,9 @@ var ScanSplitSchema = schema2([
2995
3015
  field2("estimated_rows", int642(), true),
2996
3016
  field2("rows_exact", bool2(), false),
2997
3017
  field2("estimated_bytes", int642(), true),
3018
+ field2("key_value", binary2(), true),
3019
+ field2("range_index", int642(), true),
3020
+ field2("column_bounds", binary2(), true),
2998
3021
  field2("partition_bounds", binary2(), true),
2999
3022
  field2("column_statistics", binary2(), true),
3000
3023
  field2("location_ids", list2(field2("item", int642(), true)), true),
@@ -3470,6 +3493,8 @@ var TableFunctionPlanResultSchema = schema2([
3470
3493
  field2("catalog_version", int642(), true),
3471
3494
  field2("scope", utf82(), false),
3472
3495
  field2("locations", list2(field2("item", utf82(), true)), true),
3496
+ field2("key_grouping", binary2(), true),
3497
+ field2("range_partitioning", binary2(), true),
3473
3498
  field2("partitioning", list2(field2("item", binary2(), true)), true),
3474
3499
  field2("sort_order", list2(field2("item", binary2(), true)), true),
3475
3500
  field2("cache_max_age_seconds", int642(), true),
@@ -5678,6 +5703,26 @@ function toAsyncIterator(input) {
5678
5703
  }
5679
5704
 
5680
5705
  // src/client/client.ts
5706
+ function int64ColumnNames(s) {
5707
+ if (!s)
5708
+ return [];
5709
+ return s.fields.filter((f) => isInt(f.type) && f.type.bitWidth === 64).map((f) => f.name);
5710
+ }
5711
+ var MIN_SAFE_BIGINT = BigInt(Number.MIN_SAFE_INTEGER);
5712
+ var MAX_SAFE_BIGINT = BigInt(Number.MAX_SAFE_INTEGER);
5713
+ function applyInt64Mode(rows, columns, mode) {
5714
+ for (const row of rows) {
5715
+ for (const name of columns) {
5716
+ const v = row[name];
5717
+ if (mode === "bigint") {
5718
+ if (typeof v === "number" && Number.isInteger(v))
5719
+ row[name] = BigInt(v);
5720
+ } else if (typeof v === "bigint" && v >= MIN_SAFE_BIGINT && v <= MAX_SAFE_BIGINT) {
5721
+ row[name] = Number(v);
5722
+ }
5723
+ }
5724
+ }
5725
+ }
5681
5726
  function onConflictName(onConflict) {
5682
5727
  return String(onConflict).toUpperCase();
5683
5728
  }
@@ -5969,10 +6014,14 @@ class VgiClient {
5969
6014
  tablesample: opts.tablesample,
5970
6015
  joinKeys: opts.joinKeys
5971
6016
  });
6017
+ const int64Columns = opts.int64 === undefined ? [] : int64ColumnNames(bindResp.output_schema);
5972
6018
  try {
5973
6019
  for await (const rows of session) {
5974
- if (rows.length > 0)
5975
- yield rows;
6020
+ if (rows.length === 0)
6021
+ continue;
6022
+ if (int64Columns.length > 0)
6023
+ applyInt64Mode(rows, int64Columns, opts.int64);
6024
+ yield rows;
5976
6025
  }
5977
6026
  } finally {
5978
6027
  session.close();
@@ -6214,7 +6263,7 @@ class VgiClient {
6214
6263
  return null;
6215
6264
  const inner = unwrapResult(result);
6216
6265
  const items = deserializeInfoList(inner.items, decodeSchemaInfo);
6217
- return items.length > 0 ? items[0] : null;
6266
+ return items[0] ?? null;
6218
6267
  }
6219
6268
  async schemaCreate(attachOpaqueData, path, opts) {
6220
6269
  const tagsMap = opts?.tags ? new Map(Object.entries(opts.tags)) : null;
@@ -6292,7 +6341,7 @@ class VgiClient {
6292
6341
  return null;
6293
6342
  const inner = unwrapResult(result);
6294
6343
  const items = deserializeInfoList(inner.items, decodeTableInfo);
6295
- return items.length > 0 ? items[0] : null;
6344
+ return items[0] ?? null;
6296
6345
  }
6297
6346
  async tableCreate(attachOpaqueData, schemaPath, name, columns, onConflict, constraintDefinitions = [], transactionOpaqueData) {
6298
6347
  await this.rpc.call("catalog_table_create", {
@@ -6460,7 +6509,7 @@ class VgiClient {
6460
6509
  return null;
6461
6510
  const inner = unwrapResult(result);
6462
6511
  const items = deserializeInfoList(inner.items, decodeViewInfo);
6463
- return items.length > 0 ? items[0] : null;
6512
+ return items[0] ?? null;
6464
6513
  }
6465
6514
  async viewCreate(attachOpaqueData, schemaPath, name, definition, onConflict, transactionOpaqueData, aliases, security = "regular", comment, tags, columnComments) {
6466
6515
  await this.rpc.call("catalog_view_create", {
@@ -6529,7 +6578,7 @@ class VgiClient {
6529
6578
  return null;
6530
6579
  const inner = unwrapResult(result);
6531
6580
  const items = deserializeInfoList(inner.items, decodeMacroInfo);
6532
- return items.length > 0 ? items[0] : null;
6581
+ return items[0] ?? null;
6533
6582
  }
6534
6583
  async schemaContentsMacros(attachOpaqueData, path, type, transactionOpaqueData) {
6535
6584
  const result = await this.rpc.call("catalog_schema_contents_macros", {
@@ -6824,4 +6873,4 @@ export {
6824
6873
  validateTableConstraints
6825
6874
  };
6826
6875
 
6827
- //# debugId=E76CFFFCFD3AD3B764756E2164756E21
6876
+ //# debugId=F1A002FFA544727064756E2164756E21