@query-farm/vgi 0.49.2 → 0.50.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 (37) hide show
  1. package/README.md +1 -1
  2. package/dist/catalog/composite.d.ts +1 -1
  3. package/dist/catalog/descriptors.d.ts +34 -2
  4. package/dist/catalog/interface.d.ts +47 -8
  5. package/dist/catalog/read-only.d.ts +48 -1
  6. package/dist/client/client.d.ts +13 -7
  7. package/dist/client-entry.d.ts +1 -1
  8. package/dist/client-entry.js +40 -16
  9. package/dist/client-entry.js.map +6 -6
  10. package/dist/functions/storage.d.ts +7 -0
  11. package/dist/generated/vgi-client.d.ts +4 -0
  12. package/dist/generated/vgi-protocol-schemas.d.ts +2 -2
  13. package/dist/generated/vgi-service.d.ts +7 -26
  14. package/dist/index.core.d.ts +4 -3
  15. package/dist/index.js +265 -170
  16. package/dist/index.js.map +16 -16
  17. package/dist/protocol/dispatch.d.ts +5 -3
  18. package/dist/serve-entry.js +43 -45
  19. package/dist/serve-entry.js.map +9 -9
  20. package/dist/worker-cf-entry.js +221 -154
  21. package/dist/worker-cf-entry.js.map +15 -15
  22. package/dist/write-results.d.ts +8 -1
  23. package/package.json +1 -1
  24. package/src/catalog/composite.ts +2 -2
  25. package/src/catalog/descriptors.ts +35 -2
  26. package/src/catalog/interface.ts +78 -10
  27. package/src/catalog/read-only.ts +297 -175
  28. package/src/client/client.ts +22 -13
  29. package/src/client-entry.ts +4 -0
  30. package/src/functions/storage.ts +44 -3
  31. package/src/generated/vgi-client.ts +6 -1
  32. package/src/generated/vgi-protocol-schemas.ts +8 -12
  33. package/src/generated/vgi-service.ts +9 -48
  34. package/src/index.core.ts +4 -3
  35. package/src/protocol/dispatch.ts +5 -3
  36. package/src/protocol/handlers/catalog/table.ts +14 -21
  37. package/src/write-results.ts +8 -3
package/README.md CHANGED
@@ -60,7 +60,7 @@ npm install @query-farm/vgi
60
60
 
61
61
  Requires **Node.js ≥ 22.15** or **Bun**.
62
62
 
63
- This branch uses **`vgi.v3` / `3.2.0`** and requires a matching VGI
63
+ This branch uses **`vgi.v3` / `3.3.0`** and requires a matching VGI
64
64
  extension. Existing `vgi.v2` extensions need SDK 0.46.x; upgrade the engine-side
65
65
  extension and workers together. This release prepares the shared protocol for
66
66
  DuckDB 2.0; it does not require upgrading DuckDB itself. See
@@ -32,7 +32,7 @@ export declare class CompositeCatalogInterface extends CatalogInterface {
32
32
  macroGet(attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, transactionOpaqueData?: TransactionOpaqueData): Promise<MacroInfo | null>;
33
33
  schemaCreate(...args: Parameters<CatalogInterface["schemaCreate"]>): Promise<void>;
34
34
  schemaDrop(...args: Parameters<CatalogInterface["schemaDrop"]>): Promise<void>;
35
- tableCreate(...args: Parameters<CatalogInterface["tableCreate"]>): Promise<void>;
35
+ tableCreate(...args: Parameters<CatalogInterface["tableCreate"]>): Promise<boolean | void>;
36
36
  tableDrop(...args: Parameters<CatalogInterface["tableDrop"]>): Promise<void>;
37
37
  tableCommentSet(...args: Parameters<CatalogInterface["tableCommentSet"]>): Promise<void>;
38
38
  tableRename(...args: Parameters<CatalogInterface["tableRename"]>): Promise<void>;
@@ -32,21 +32,41 @@ export interface TableDescriptor {
32
32
  definitionRevision?: Uint8Array | null;
33
33
  name: string;
34
34
  columns?: VgiSchema;
35
+ /**
36
+ * The table's scan function. It need not be listed in any schema's
37
+ * `functions`: the SDK always sends it in the table's schema listing so
38
+ * DuckDB knows its capabilities (projection/filter pushdown, rowid, ...),
39
+ * as `table_only` (absent from `duckdb_functions()`, not callable from SQL)
40
+ * unless `exposeScan` is set or a schema also lists it in `functions`.
41
+ */
35
42
  function?: VgiFunction;
43
+ /**
44
+ * Protocol 3.3: also expose the scan `function` as an ordinary, callable
45
+ * table function (`visibility: "public"`). Default false: the scan is sent
46
+ * `table_only`, so it resolves this table but is absent from
47
+ * `duckdb_functions()` and cannot be called directly. Listing the function
48
+ * in a schema's `functions` makes it public too. Requires `function`.
49
+ */
50
+ exposeScan?: boolean;
36
51
  arguments?: Arguments;
37
52
  /**
38
53
  * Table in-out function backing `INSERT INTO <table>`. It receives the new
39
54
  * rows (the table's user columns) and returns a `writeResultSchema` batch
40
55
  * for the mode in its `write_options` (see `write-results.ts`). Omitted
41
56
  * means the table does not accept INSERT.
57
+ *
58
+ * Write functions are always sent `table_only` (protocol 3.3): DuckDB
59
+ * learns their capabilities (`has_finalize`, the write schema) but they are
60
+ * not callable from SQL, even when a schema also lists them in `functions`.
42
61
  */
43
62
  insertFunction?: VgiFunction;
44
63
  /**
45
64
  * Table in-out function backing `UPDATE <table>`. It receives the changed
46
65
  * columns plus the row-id column (`rowIdField()`, which the scan
47
66
  * `function` must emit) for each updated row. Requires `function`, which
48
- * must also support projection pushdown and be listed in the schema's
49
- * `functions` (see `rowIdField`).
67
+ * must also support projection pushdown (see `rowIdField`). The scan need
68
+ * not be listed in the schema's `functions`: it is always sent, as
69
+ * `table_only` unless `exposeScan`.
50
70
  */
51
71
  updateFunction?: VgiFunction;
52
72
  /**
@@ -133,6 +153,18 @@ export interface TableDescriptor {
133
153
  comment?: string;
134
154
  tags?: Record<string, string>;
135
155
  }
156
+ /**
157
+ * Protocol 3.3 `FunctionInfo.visibility` values. Null/absent on the wire means
158
+ * `public`.
159
+ *
160
+ * - `public`: an ordinary catalog function, listed in `duckdb_functions()` and
161
+ * callable from SQL.
162
+ * - `table_only`: sent only so the client knows the capabilities of a table's
163
+ * scan or write function; hidden from `duckdb_functions()` and not callable.
164
+ */
165
+ export declare const FUNCTION_VISIBILITY_PUBLIC = "public";
166
+ export declare const FUNCTION_VISIBILITY_TABLE_ONLY = "table_only";
167
+ export type FunctionVisibility = typeof FUNCTION_VISIBILITY_PUBLIC | typeof FUNCTION_VISIBILITY_TABLE_ONLY;
136
168
  export interface ViewDescriptor {
137
169
  name: string;
138
170
  /** Ordered raw output identifiers; empty uses query names. */
@@ -124,9 +124,9 @@ export interface ScanFunctionResultRecord {
124
124
  }
125
125
  /**
126
126
  * Encode a ScanFunctionResult wire record — the single-row batch shape
127
- * `{ function_name, arguments, required_extensions, schema_path }` that
128
- * `catalog_table_scan_function_get` returns and that a function-backed table
129
- * inlines into `TableInfo.scan_function`.
127
+ * `{ function_name, arguments, required_extensions, schema_path }` that the
128
+ * write-function lookups return and that a function-backed table inlines into
129
+ * `TableInfo.scan_function` / `insert_function` / ....
130
130
  *
131
131
  * It exists so there is exactly one place that names those columns. The
132
132
  * inline-scan path used to restate the schema locally even though codegen
@@ -150,11 +150,36 @@ export declare function encodeScanFunctionResult(functionName: string, arguments
150
150
  * name for named args.
151
151
  */
152
152
  export declare function decodeScanFunctionResult(inner: Record<string, unknown>): ScanFunctionResult;
153
+ /** One decoded `ScanBranch`: a function branch, or a format branch (`formatName`). */
154
+ export interface ScanBranchInfo extends ScanFunctionResult {
155
+ /** SQL predicate routing rows to this branch, or null. */
156
+ branchFilter: string | null;
157
+ /** Whether INSERTs route to this branch. */
158
+ writable: boolean;
159
+ sourceCatalog: string | null;
160
+ sourceSchemaPath: string[] | null;
161
+ sourceTable: string | null;
162
+ /** DuckDB file format (e.g. `parquet`) for a format branch; null for a function branch. */
163
+ formatName: string | null;
164
+ formatLocations: string[] | null;
165
+ rowCount: bigint | null;
166
+ }
167
+ /** A decoded `ScanBranchesResult` (the reply of `catalog_table_scan_branches_get`). */
168
+ export interface ScanBranchesInfo {
169
+ branches: ScanBranchInfo[];
170
+ requiredExtensions: string[];
171
+ }
172
+ /**
173
+ * Decode a `ScanBranchesResult` wire dict (`branches`: one IPC stream per
174
+ * `ScanBranch`, `required_extensions`).
175
+ */
176
+ export declare function decodeScanBranchesResult(inner: Record<string, unknown>): ScanBranchesInfo;
153
177
  /**
154
- * Synthesise a one-branch `ScanBranchesResult` wire dict from a legacy
155
- * `tableScanFunctionGet` wire result. Mirrors vgi-python's default
156
- * `table_scan_branches_get` (catalog_interface.py): a single-source worker is
157
- * automatically compatible with the branches-aware C++ side.
178
+ * Synthesise a one-branch `ScanBranchesResult` wire dict from a
179
+ * `tableScanFunctionGet` result. Mirrors vgi-python's default
180
+ * `table_scan_branches_get` (catalog_interface.py): this is how a
181
+ * single-source catalog answers `catalog_table_scan_branches_get`, the only
182
+ * scan-discovery RPC since protocol 3.3.
158
183
  *
159
184
  * Each branch is its own IPC stream carried in a `list<binary>` column. The
160
185
  * legacy result's `arguments` field is already the nested-IPC form
@@ -403,8 +428,15 @@ export declare abstract class CatalogInterface {
403
428
  * `catalogCapabilities()`), and the catalog must then enforce every one on
404
429
  * every write and serve each back as an ENFORCED + ALL_ROWS `ConstraintInfo`
405
430
  * record (see `constraintRecord`). Refuse any it cannot enforce.
431
+ *
432
+ * Return `false` when `onConflict` is `IGNORE` (`IF NOT EXISTS`) and the
433
+ * table already existed, leaving it unchanged; `true` or nothing means this
434
+ * call created the table. The worker sends this as the reply's `created`
435
+ * (protocol 3.3), which keeps `CREATE TABLE IF NOT EXISTS ... AS SELECT`
436
+ * from appending into the existing table. A catalog that returns nothing
437
+ * for an existing table makes that CTAS insert its rows into it.
406
438
  */
407
- tableCreate(attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, columns: Uint8Array, onConflict: string, constraintDefinitions?: Uint8Array[], transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
439
+ tableCreate(attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, columns: Uint8Array, onConflict: string, constraintDefinitions?: Uint8Array[], transactionOpaqueData?: TransactionOpaqueData): Awaitable<boolean | void>;
408
440
  /**
409
441
  * The profiles this catalog implements for an attachment (advertised as
410
442
  * `CatalogAttachResult.catalog_capabilities` when `attach()` leaves it
@@ -434,6 +466,13 @@ export declare abstract class CatalogInterface {
434
466
  */
435
467
  tableConstraintsApply(request: ConstraintsApplyRequest): Promise<ConstraintSnapshot>;
436
468
  tableDrop(attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
469
+ /**
470
+ * The table function that reads a single-source table. Protocol 3.3 has no
471
+ * RPC of this name any more: the default `tableScanBranchesGet` calls it and
472
+ * sends the result as a one-branch `catalog_table_scan_branches_get` reply,
473
+ * so a single-source catalog implements only this. Override
474
+ * `tableScanBranchesGet` instead for a multi-source table.
475
+ */
437
476
  tableScanFunctionGet(attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, atUnit?: string, atValue?: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<any>;
438
477
  /**
439
478
  * The table in-out function backing `INSERT INTO` this table. Default:
@@ -1,5 +1,6 @@
1
1
  import { CatalogInterface, type AttachOpaqueData, type TransactionOpaqueData, type CatalogAttachResult, type SchemaInfo, type CatalogInfo, type TableInfo, type ViewInfo, type FunctionInfo, type MacroInfo, type IndexInfo, type CopyFromFormatInfo, type ScanFunctionResultRecord } from "./interface.js";
2
- import { type CatalogDescriptor } from "./descriptors.js";
2
+ import { type FunctionVisibility, type CatalogDescriptor, type SchemaDescriptor } from "./descriptors.js";
3
+ import type { VgiFunction } from "../functions/types.js";
3
4
  import type { FunctionRegistry } from "../functions/registry.js";
4
5
  type Awaitable<T> = T | Promise<T>;
5
6
  import { type AttachOptionSpec } from "./attach-option.js";
@@ -56,9 +57,25 @@ export declare class ReadOnlyCatalogInterface extends CatalogInterface {
56
57
  private _functionListings;
57
58
  /** One frozen FunctionInfo per (declaring schema, function), shared by listings and `global_functions`. */
58
59
  private _functionInfos;
60
+ /**
61
+ * Protocol 3.3: every function each schema's listing carries, in order, with
62
+ * its visibility -- the schema's own `functions`, then each of its tables'
63
+ * scan and write functions that no schema declares (see
64
+ * `buildFunctionListings`).
65
+ */
66
+ private _builtListings?;
59
67
  constructor(descriptor: CatalogDescriptor, registry: FunctionRegistry, options?: {
60
68
  perAttachItemIds?: boolean;
61
69
  });
70
+ /** Per-schema listings, built on first use (the descriptor is immutable from then on). */
71
+ private get _listings();
72
+ /** The schema whose listing carries each function (first one wins). */
73
+ private get _listedIn();
74
+ /**
75
+ * The visibility `fn` is listed with in `schema` (protocol 3.3), or null
76
+ * when that schema's listing does not carry it.
77
+ */
78
+ functionVisibility(schema: SchemaDescriptor, fn: VgiFunction): FunctionVisibility | null;
62
79
  /**
63
80
  * Which schema declares `fn`, by object identity, or null if no schema does.
64
81
  *
@@ -162,4 +179,34 @@ export declare class ReadOnlyCatalogInterface extends CatalogInterface {
162
179
  viewGet(attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, transactionOpaqueData?: TransactionOpaqueData): Promise<ViewInfo | null>;
163
180
  copyFromFormats(attachOpaqueData: AttachOpaqueData, transactionOpaqueData?: TransactionOpaqueData): CopyFromFormatInfo[];
164
181
  }
182
+ /**
183
+ * Build the wire `FunctionInfo` a schema listing carries for `f`.
184
+ *
185
+ * `schemaPath` is the schema the function is listed in (the bind-dispatch
186
+ * key). `visibility` is protocol 3.3's `FunctionInfo.visibility`: pass
187
+ * `FUNCTION_VISIBILITY_TABLE_ONLY` for a table's scan or write function that
188
+ * must not be callable from SQL. A hand-written `CatalogInterface` uses this
189
+ * from `schemaContentsFunctions` to list the functions its tables name (the
190
+ * client takes their capabilities only from the listing and refuses a table
191
+ * whose function no listing carries). `ReadOnlyCatalogInterface` builds its
192
+ * listings with it.
193
+ */
194
+ export declare function functionInfoFor(f: VgiFunction, schemaPath: string[], visibility?: FunctionVisibility): FunctionInfo;
195
+ /**
196
+ * Protocol 3.3 function listings for a descriptor: per schema, every function
197
+ * its listing carries and the visibility each is sent with.
198
+ *
199
+ * The rules (enforced here, so authors need do nothing):
200
+ * - Every function a table names (scan, insert, update, delete) is sent: a
201
+ * function a schema declares in `functions` is listed there; any other is
202
+ * listed in its table's schema, after the declared functions.
203
+ * - Write functions are always `table_only`, wherever they are listed.
204
+ * - A scan is `table_only` unless a schema declares it in `functions` or a
205
+ * table naming it sets `exposeScan`; then it is `public`.
206
+ * - Every other declared function is `public`.
207
+ */
208
+ export declare function buildFunctionListings(descriptor: CatalogDescriptor): {
209
+ listings: Map<SchemaDescriptor, Map<VgiFunction, FunctionVisibility>>;
210
+ listedIn: Map<VgiFunction, SchemaDescriptor>;
211
+ };
165
212
  export {};
@@ -1,6 +1,6 @@
1
1
  import { type VgiBatch } from "../arrow/index.js";
2
2
  import type { RpcClient, StreamSession } from "@query-farm/vgi-rpc";
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";
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 ScanBranchesInfo } from "../catalog/interface.js";
4
4
  import { VgiClientError } from "./errors.js";
5
5
  export { VgiClientError };
6
6
  import type { VgiClientOptions, TableFunctionOptions, TableFunctionRowsOptions, ScalarFunctionOptions, TableInOutFunctionOptions, OnCreateConflict, CatalogFunctionType, CatalogMacroType, CatalogAttachOptions, AttachOptionValue, CatalogSnapshot, LoadCatalogOptions } from "./types.js";
@@ -209,16 +209,22 @@ export declare class VgiClient {
209
209
  schemaContentsIndexes(attachOpaqueData: AttachOpaqueData, path: string[] | string, transactionOpaqueData?: TransactionOpaqueData): Promise<IndexInfo[]>;
210
210
  /** Get a table by name, or null if not found. */
211
211
  tableGet(attachOpaqueData: AttachOpaqueData, schemaPath: string[] | string, name: string, transactionOpaqueData?: TransactionOpaqueData): Promise<TableInfo | null>;
212
- /** Create a new table. */
213
- tableCreate(attachOpaqueData: AttachOpaqueData, schemaPath: string[] | string, name: string, columns: Uint8Array, onConflict: OnCreateConflict, constraintDefinitions?: Uint8Array[], transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
212
+ /**
213
+ * Create a new table. Resolves to whether this call created it: `false`
214
+ * when `onConflict` is IGNORE (`IF NOT EXISTS`) and the table already
215
+ * existed (protocol 3.3 `created`).
216
+ */
217
+ tableCreate(attachOpaqueData: AttachOpaqueData, schemaPath: string[] | string, name: string, columns: Uint8Array, onConflict: OnCreateConflict, constraintDefinitions?: Uint8Array[], transactionOpaqueData?: TransactionOpaqueData): Promise<boolean>;
214
218
  /** Drop a table by name. */
215
219
  tableDrop(attachOpaqueData: AttachOpaqueData, schemaPath: string[] | string, name: string, ignoreNotFound?: boolean, cascade?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
216
220
  /**
217
- * Get the scan function for a table — tells DuckDB which function to call
218
- * to read the table data (e.g. `read_parquet` with a path argument). Used
219
- * by the VGI extension during query planning.
221
+ * Get a table's scan branches -- tells DuckDB which function (or file
222
+ * format) reads each physical source of the table. A single-source table
223
+ * has one branch. Protocol 3.3 removed the single-function
224
+ * `catalog_table_scan_function_get` RPC (and this client's
225
+ * `tableScanFunctionGet`); this is the only scan-discovery call.
220
226
  */
221
- tableScanFunctionGet(attachOpaqueData: AttachOpaqueData, schemaPath: string[] | string, name: string, atUnit?: string | null, atValue?: string | null, transactionOpaqueData?: TransactionOpaqueData): Promise<ScanFunctionResult>;
227
+ tableScanBranchesGet(attachOpaqueData: AttachOpaqueData, schemaPath: string[] | string, name: string, atUnit?: string | null, atValue?: string | null, transactionOpaqueData?: TransactionOpaqueData): Promise<ScanBranchesInfo>;
222
228
  /** Set or clear the comment on a table. */
223
229
  tableCommentSet(attachOpaqueData: AttachOpaqueData, schemaPath: string[] | string, name: string, comment?: string | null, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
224
230
  /** Rename a table. */
@@ -4,7 +4,7 @@ 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";
6
6
  export type { BindRequest, BindResponse, InitRequest, GlobalInitResponse, TableCardinality, } from "./protocol/types.js";
7
- export { type SchemaInfo, encodeSchemaInfo, decodeSchemaInfo, type TableInfo, encodeTableInfo, decodeTableInfo, type ViewInfo, encodeViewInfo, decodeViewInfo, type FunctionInfo, encodeFunctionInfo, decodeFunctionInfo, type MacroInfo, encodeMacroInfo, decodeMacroInfo, type CatalogAttachResult, type AttachOpaqueData, type TransactionOpaqueData, } from "./catalog/interface.js";
7
+ export { type SchemaInfo, encodeSchemaInfo, decodeSchemaInfo, type TableInfo, encodeTableInfo, decodeTableInfo, type ViewInfo, encodeViewInfo, decodeViewInfo, type FunctionInfo, encodeFunctionInfo, decodeFunctionInfo, type MacroInfo, encodeMacroInfo, decodeMacroInfo, type CatalogAttachResult, type AttachOpaqueData, type TransactionOpaqueData, type ScanFunctionResult, type ScanBranchInfo, type ScanBranchesInfo, decodeScanBranchesResult, } from "./catalog/interface.js";
8
8
  export * from "./catalog/public-codecs.js";
9
9
  export { VgiError, RowCountMismatchError, FunctionNotFoundError, CatalogReadOnlyError, CatalogNotFoundError, CatalogAlreadyExistsError, ArgumentValidationError, NoCatalogError, } from "./errors.js";
10
10
  export { iterRows, batchFromRows, batchFromColumns, emptyBatch, filterBatch, projectSchema, projectBatch, batchToScalarDict, safeNumber, serializeSchema, deserializeSchema, serializeBatch, deserializeBatch, } from "./util/arrow/index.js";
@@ -2722,7 +2722,8 @@ var FunctionInfoSchema = schema2([
2722
2722
  field2("input_from_args", bool2(), false),
2723
2723
  field2("input_rows_per_call", int642(), true),
2724
2724
  field2("required_settings", list2(field2("item", utf82(), true)), false),
2725
- field2("required_secrets", list2(field2("item", struct2([field2("secret_type", utf82(), false), field2("scope", utf82(), true), field2("secret_name", utf82(), true)]), true)), false)
2725
+ field2("required_secrets", list2(field2("item", struct2([field2("secret_type", utf82(), false), field2("scope", utf82(), true), field2("secret_name", utf82(), true)]), true)), false),
2726
+ field2("visibility", utf82(), true)
2726
2727
  ]);
2727
2728
  var MacroInfoSchema = schema2([
2728
2729
  field2("comment", utf82(), true),
@@ -3435,6 +3436,9 @@ var CatalogTableConstraintsApplyResultSchema = schema2([
3435
3436
  field2("definition_revision", binary2(), false),
3436
3437
  field2("constraints", list2(field2("item", binary2(), true)), false)
3437
3438
  ]);
3439
+ var CatalogTableCreateResultSchema = schema2([
3440
+ field2("created", bool2(), false)
3441
+ ]);
3438
3442
  var CatalogTableGetResultSchema = schema2([
3439
3443
  field2("items", list2(field2("item", binary2(), true)), false)
3440
3444
  ]);
@@ -3840,14 +3844,6 @@ var CatalogTableScanBranchesGetParamsSchema = schema2([
3840
3844
  field2("transaction_opaque_data", binary2(), true),
3841
3845
  field2("pushdown_filters", binary2(), true)
3842
3846
  ]);
3843
- var CatalogTableScanFunctionGetParamsSchema = schema2([
3844
- field2("attach_opaque_data", binary2(), false),
3845
- field2("schema_path", list2(field2("item", utf82(), true)), false),
3846
- field2("name", utf82(), false),
3847
- field2("at_unit", utf82(), true),
3848
- field2("at_value", utf82(), true),
3849
- field2("transaction_opaque_data", binary2(), true)
3850
- ]);
3851
3847
  var CatalogTableUpdateFunctionGetParamsSchema = schema2([
3852
3848
  field2("attach_opaque_data", binary2(), false),
3853
3849
  field2("schema_path", list2(field2("item", utf82(), true)), false),
@@ -5325,6 +5321,29 @@ function decodeScanFunctionResult(inner) {
5325
5321
  schemaPath: inner.schema_path == null ? null : (Array.isArray(inner.schema_path) ? inner.schema_path : [...inner.schema_path]).filter((value) => value != null).map(String)
5326
5322
  };
5327
5323
  }
5324
+ var stringList = (value) => value == null ? null : (Array.isArray(value) ? value : [...value]).filter((v) => v != null).map(String);
5325
+ function decodeScanBranchesResult(inner) {
5326
+ const raw = inner.branches == null ? [] : Array.isArray(inner.branches) ? inner.branches : [...inner.branches];
5327
+ const branches = raw.map((bytes) => {
5328
+ const batch = deserializeBatch(toUint8Array(bytes));
5329
+ const row = {};
5330
+ for (const f of batch.schema.fields)
5331
+ row[f.name] = batch.getChild(f.name)?.get(0) ?? null;
5332
+ const fn = decodeScanFunctionResult(row);
5333
+ return {
5334
+ ...fn,
5335
+ branchFilter: row.branch_filter == null ? null : String(row.branch_filter),
5336
+ writable: row.writable === true,
5337
+ sourceCatalog: row.source_catalog == null ? null : String(row.source_catalog),
5338
+ sourceSchemaPath: stringList(row.source_schema_path),
5339
+ sourceTable: row.source_table == null ? null : String(row.source_table),
5340
+ formatName: row.format_name == null ? null : String(row.format_name),
5341
+ formatLocations: stringList(row.format_locations),
5342
+ rowCount: row.row_count == null ? null : BigInt(row.row_count)
5343
+ };
5344
+ });
5345
+ return { branches, requiredExtensions: stringList(inner.required_extensions) ?? [] };
5346
+ }
5328
5347
 
5329
5348
  // src/client/protocol.ts
5330
5349
  function wrapRequest(batch) {
@@ -6356,7 +6375,7 @@ class VgiClient {
6356
6375
  return items[0] ?? null;
6357
6376
  }
6358
6377
  async tableCreate(attachOpaqueData, schemaPath, name, columns, onConflict, constraintDefinitions = [], transactionOpaqueData) {
6359
- await this.rpc.call("catalog_table_create", {
6378
+ const result = await this.rpc.call("catalog_table_create", {
6360
6379
  request: encodeASD(TableCreateRequestSchema, {
6361
6380
  attach_opaque_data: attachOpaqueData,
6362
6381
  schema_path: normalizeSchemaPath(schemaPath),
@@ -6367,6 +6386,9 @@ class VgiClient {
6367
6386
  transaction_opaque_data: transactionOpaqueData ?? null
6368
6387
  })
6369
6388
  });
6389
+ if (!result)
6390
+ throw new VgiClientError("table_create returned null");
6391
+ return unwrapResult(result).created === true;
6370
6392
  }
6371
6393
  async tableDrop(attachOpaqueData, schemaPath, name, ignoreNotFound, cascade, transactionOpaqueData) {
6372
6394
  await this.rpc.call("catalog_table_drop", {
@@ -6378,18 +6400,19 @@ class VgiClient {
6378
6400
  transaction_opaque_data: transactionOpaqueData ?? null
6379
6401
  });
6380
6402
  }
6381
- async tableScanFunctionGet(attachOpaqueData, schemaPath, name, atUnit, atValue, transactionOpaqueData) {
6382
- const result = await this.rpc.call("catalog_table_scan_function_get", {
6403
+ async tableScanBranchesGet(attachOpaqueData, schemaPath, name, atUnit, atValue, transactionOpaqueData) {
6404
+ const result = await this.rpc.call("catalog_table_scan_branches_get", {
6383
6405
  attach_opaque_data: attachOpaqueData,
6384
6406
  schema_path: normalizeSchemaPath(schemaPath),
6385
6407
  name,
6386
6408
  at_unit: atUnit ?? null,
6387
6409
  at_value: atValue ?? null,
6388
- transaction_opaque_data: transactionOpaqueData ?? null
6410
+ transaction_opaque_data: transactionOpaqueData ?? null,
6411
+ pushdown_filters: null
6389
6412
  });
6390
6413
  if (!result)
6391
- throw new VgiClientError("table_scan_function_get returned null");
6392
- return decodeScanFunctionResult(unwrapResult(result));
6414
+ throw new VgiClientError("table_scan_branches_get returned null");
6415
+ return decodeScanBranchesResult(unwrapResult(result));
6393
6416
  }
6394
6417
  async tableCommentSet(attachOpaqueData, schemaPath, name, comment, ignoreNotFound, transactionOpaqueData) {
6395
6418
  await this.rpc.call("catalog_table_comment_set", {
@@ -6832,6 +6855,7 @@ export {
6832
6855
  decodeIndexDefinition,
6833
6856
  decodeMacroInfo,
6834
6857
  decodeMacroOverload,
6858
+ decodeScanBranchesResult,
6835
6859
  decodeSchemaInfo,
6836
6860
  decodeSqlExpression,
6837
6861
  decodeTableInfo,
@@ -6885,4 +6909,4 @@ export {
6885
6909
  validateTableConstraints
6886
6910
  };
6887
6911
 
6888
- //# debugId=21F171AD00864D0C64756E2164756E21
6912
+ //# debugId=DFB6060E5EBBB9FD64756E2164756E21