@query-farm/vgi 0.6.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/LICENSE +134 -0
- package/README.md +494 -0
- package/dist/__dbg.test-d.d.ts +1 -0
- package/dist/arguments/argument-spec.d.ts +51 -0
- package/dist/arguments/arguments.d.ts +13 -0
- package/dist/arrow/codec/branded.d.ts +83 -0
- package/dist/arrow/codec/registry.d.ts +29 -0
- package/dist/arrow/codec/repr.d.ts +23 -0
- package/dist/arrow/codec/type-descriptors.d.ts +109 -0
- package/dist/arrow/impl-arrowjs/build.d.ts +19 -0
- package/dist/arrow/impl-arrowjs/canonical.d.ts +15 -0
- package/dist/arrow/impl-arrowjs/empty.d.ts +7 -0
- package/dist/arrow/impl-arrowjs/filter.d.ts +11 -0
- package/dist/arrow/impl-arrowjs/index.d.ts +11 -0
- package/dist/arrow/impl-arrowjs/ipc.d.ts +24 -0
- package/dist/arrow/impl-arrowjs/iterate.d.ts +39 -0
- package/dist/arrow/impl-arrowjs/project.d.ts +10 -0
- package/dist/arrow/impl-arrowjs/schema.d.ts +62 -0
- package/dist/arrow/impl-arrowjs/statistics.d.ts +13 -0
- package/dist/arrow/impl-flechette/build.d.ts +14 -0
- package/dist/arrow/impl-flechette/canonical.d.ts +18 -0
- package/dist/arrow/impl-flechette/empty.d.ts +9 -0
- package/dist/arrow/impl-flechette/filter.d.ts +10 -0
- package/dist/arrow/impl-flechette/index.d.ts +11 -0
- package/dist/arrow/impl-flechette/ipc.d.ts +33 -0
- package/dist/arrow/impl-flechette/iterate.d.ts +29 -0
- package/dist/arrow/impl-flechette/message-meta.d.ts +10 -0
- package/dist/arrow/impl-flechette/normalize-type.d.ts +11 -0
- package/dist/arrow/impl-flechette/project.d.ts +3 -0
- package/dist/arrow/impl-flechette/schema.d.ts +47 -0
- package/dist/arrow/impl-flechette/statistics.d.ts +13 -0
- package/dist/arrow/index.d.ts +11 -0
- package/dist/arrow/predicates.d.ts +47 -0
- package/dist/arrow/repr.test-d.d.ts +52 -0
- package/dist/arrow/schema-types.d.ts +71 -0
- package/dist/arrow/types.d.ts +57 -0
- package/dist/catalog/attach-option.d.ts +33 -0
- package/dist/catalog/attach-options.d.ts +30 -0
- package/dist/catalog/composite.d.ts +33 -0
- package/dist/catalog/descriptors.d.ts +154 -0
- package/dist/catalog/interface.d.ts +239 -0
- package/dist/catalog/read-only.d.ts +33 -0
- package/dist/client/client.d.ts +189 -0
- package/dist/client/errors.d.ts +26 -0
- package/dist/client/helpers.d.ts +12 -0
- package/dist/client/protocol.d.ts +16 -0
- package/dist/client/types.d.ts +125 -0
- package/dist/client-entry.d.ts +11 -0
- package/dist/client-entry.js +48 -0
- package/dist/client-entry.js.map +9 -0
- package/dist/codec/asd.d.ts +25 -0
- package/dist/crypto.d.ts +36 -0
- package/dist/errors.d.ts +24 -0
- package/dist/filter-pushdown/collector.d.ts +32 -0
- package/dist/filter-pushdown/deserialize.d.ts +16 -0
- package/dist/filter-pushdown/evaluate.d.ts +51 -0
- package/dist/filter-pushdown/index.d.ts +4 -0
- package/dist/filter-pushdown/types.d.ts +84 -0
- package/dist/functions/aggregate.d.ts +129 -0
- package/dist/functions/copy-from.d.ts +81 -0
- package/dist/functions/copy-to.d.ts +121 -0
- package/dist/functions/registry.d.ts +16 -0
- package/dist/functions/scalar.d.ts +98 -0
- package/dist/functions/storage-cf-do.d.ts +47 -0
- package/dist/functions/storage.d.ts +86 -0
- package/dist/functions/table-buffering.d.ts +99 -0
- package/dist/functions/table-in-out.d.ts +64 -0
- package/dist/functions/table.d.ts +118 -0
- package/dist/functions/types.d.ts +157 -0
- package/dist/generated/vgi-client.d.ts +466 -0
- package/dist/generated/vgi-protocol-schemas.d.ts +115 -0
- package/dist/index.core.d.ts +42 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +10888 -0
- package/dist/index.js.map +85 -0
- package/dist/metadata/resolve.d.ts +3 -0
- package/dist/metadata/serialize.d.ts +12 -0
- package/dist/metadata/types.d.ts +47 -0
- package/dist/protocol/dispatch.d.ts +23 -0
- package/dist/protocol/handlers/aggregate.d.ts +3 -0
- package/dist/protocol/handlers/catalog/admin.d.ts +3 -0
- package/dist/protocol/handlers/catalog/index.d.ts +3 -0
- package/dist/protocol/handlers/catalog/index_methods.d.ts +3 -0
- package/dist/protocol/handlers/catalog/macro.d.ts +3 -0
- package/dist/protocol/handlers/catalog/shared.d.ts +70 -0
- package/dist/protocol/handlers/catalog/table.d.ts +3 -0
- package/dist/protocol/handlers/catalog/view.d.ts +3 -0
- package/dist/protocol/handlers/function.d.ts +8 -0
- package/dist/protocol/handlers/shared.d.ts +31 -0
- package/dist/protocol/handlers/table-buffering.d.ts +3 -0
- package/dist/protocol/serialize.d.ts +4 -0
- package/dist/protocol/serializers/arguments.d.ts +3 -0
- package/dist/protocol/serializers/bind.d.ts +9 -0
- package/dist/protocol/serializers/cardinality.d.ts +7 -0
- package/dist/protocol/serializers/init.d.ts +9 -0
- package/dist/protocol/serializers/shared.d.ts +12 -0
- package/dist/protocol/state-serializer.d.ts +23 -0
- package/dist/protocol/types.d.ts +129 -0
- package/dist/secrets/helpers.d.ts +15 -0
- package/dist/types.d.ts +52 -0
- package/dist/util/arrow/index.d.ts +1 -0
- package/dist/util/bytes.d.ts +2 -0
- package/dist/util/statistics.d.ts +7 -0
- package/dist/worker-cf-entry.d.ts +30 -0
- package/dist/worker-cf-entry.js +8767 -0
- package/dist/worker-cf-entry.js.map +74 -0
- package/dist/worker.d.ts +36 -0
- package/package.json +96 -0
- package/src/arguments/argument-spec.ts +200 -0
- package/src/arguments/arguments.ts +81 -0
- package/src/arrow/codec/branded.ts +206 -0
- package/src/arrow/codec/registry.ts +674 -0
- package/src/arrow/codec/repr.ts +181 -0
- package/src/arrow/codec/type-descriptors.ts +137 -0
- package/src/arrow/impl-arrowjs/build.ts +88 -0
- package/src/arrow/impl-arrowjs/canonical.ts +509 -0
- package/src/arrow/impl-arrowjs/empty.ts +72 -0
- package/src/arrow/impl-arrowjs/filter.ts +53 -0
- package/src/arrow/impl-arrowjs/index.ts +54 -0
- package/src/arrow/impl-arrowjs/ipc.ts +67 -0
- package/src/arrow/impl-arrowjs/iterate.ts +159 -0
- package/src/arrow/impl-arrowjs/project.ts +73 -0
- package/src/arrow/impl-arrowjs/schema.ts +256 -0
- package/src/arrow/impl-arrowjs/statistics.ts +185 -0
- package/src/arrow/impl-flechette/build.ts +65 -0
- package/src/arrow/impl-flechette/canonical.ts +289 -0
- package/src/arrow/impl-flechette/empty.ts +20 -0
- package/src/arrow/impl-flechette/filter.ts +42 -0
- package/src/arrow/impl-flechette/index.ts +54 -0
- package/src/arrow/impl-flechette/ipc.ts +110 -0
- package/src/arrow/impl-flechette/iterate.ts +121 -0
- package/src/arrow/impl-flechette/message-meta.ts +175 -0
- package/src/arrow/impl-flechette/normalize-type.ts +99 -0
- package/src/arrow/impl-flechette/project.ts +64 -0
- package/src/arrow/impl-flechette/schema.ts +202 -0
- package/src/arrow/impl-flechette/statistics.ts +198 -0
- package/src/arrow/index.ts +129 -0
- package/src/arrow/predicates.ts +66 -0
- package/src/arrow/repr.test-d.ts +189 -0
- package/src/arrow/schema-types.ts +213 -0
- package/src/arrow/types.ts +74 -0
- package/src/catalog/attach-option.ts +107 -0
- package/src/catalog/attach-options.ts +79 -0
- package/src/catalog/composite.ts +180 -0
- package/src/catalog/descriptors.ts +164 -0
- package/src/catalog/interface.ts +721 -0
- package/src/catalog/read-only.ts +909 -0
- package/src/client/client.ts +1348 -0
- package/src/client/errors.ts +69 -0
- package/src/client/helpers.ts +56 -0
- package/src/client/protocol.ts +33 -0
- package/src/client/types.ts +140 -0
- package/src/client-entry.ts +112 -0
- package/src/codec/asd.ts +147 -0
- package/src/crypto.ts +143 -0
- package/src/errors.ts +61 -0
- package/src/filter-pushdown/collector.ts +147 -0
- package/src/filter-pushdown/deserialize.ts +253 -0
- package/src/filter-pushdown/evaluate.ts +591 -0
- package/src/filter-pushdown/index.ts +28 -0
- package/src/filter-pushdown/types.ts +91 -0
- package/src/functions/aggregate.ts +384 -0
- package/src/functions/copy-from.ts +282 -0
- package/src/functions/copy-to.ts +319 -0
- package/src/functions/registry.ts +258 -0
- package/src/functions/scalar.ts +356 -0
- package/src/functions/storage-cf-do.ts +303 -0
- package/src/functions/storage.ts +521 -0
- package/src/functions/table-buffering.ts +562 -0
- package/src/functions/table-in-out.ts +373 -0
- package/src/functions/table.ts +521 -0
- package/src/functions/types.ts +192 -0
- package/src/generated/vgi-client.ts +560 -0
- package/src/generated/vgi-protocol-schemas.ts +864 -0
- package/src/index.core.ts +267 -0
- package/src/index.ts +11 -0
- package/src/metadata/resolve.ts +109 -0
- package/src/metadata/serialize.ts +242 -0
- package/src/metadata/types.ts +60 -0
- package/src/protocol/dispatch.ts +52 -0
- package/src/protocol/handlers/aggregate.ts +355 -0
- package/src/protocol/handlers/catalog/admin.ts +368 -0
- package/src/protocol/handlers/catalog/index.ts +25 -0
- package/src/protocol/handlers/catalog/index_methods.ts +65 -0
- package/src/protocol/handlers/catalog/macro.ts +114 -0
- package/src/protocol/handlers/catalog/shared.ts +291 -0
- package/src/protocol/handlers/catalog/table.ts +401 -0
- package/src/protocol/handlers/catalog/view.ts +119 -0
- package/src/protocol/handlers/function.ts +302 -0
- package/src/protocol/handlers/shared.ts +80 -0
- package/src/protocol/handlers/table-buffering.ts +207 -0
- package/src/protocol/serialize.ts +23 -0
- package/src/protocol/serializers/arguments.ts +160 -0
- package/src/protocol/serializers/bind.ts +212 -0
- package/src/protocol/serializers/cardinality.ts +45 -0
- package/src/protocol/serializers/init.ts +247 -0
- package/src/protocol/serializers/shared.ts +46 -0
- package/src/protocol/state-serializer.ts +181 -0
- package/src/protocol/types.ts +153 -0
- package/src/secrets/helpers.ts +70 -0
- package/src/types.ts +71 -0
- package/src/util/arrow/index.ts +23 -0
- package/src/util/bytes.ts +14 -0
- package/src/util/statistics.ts +40 -0
- package/src/worker-cf-entry.ts +172 -0
- package/src/worker.ts +212 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
export type AttachOpaqueData = Uint8Array;
|
|
2
|
+
export type TransactionOpaqueData = Uint8Array;
|
|
3
|
+
import type { MacroType } from "../generated/vgi-client.js";
|
|
4
|
+
export type { MacroType };
|
|
5
|
+
import type { CatalogAttachResult } from "../generated/vgi-client.js";
|
|
6
|
+
export type { CatalogAttachResult };
|
|
7
|
+
import type { SchemaInfo } from "../generated/vgi-client.js";
|
|
8
|
+
export type { SchemaInfo };
|
|
9
|
+
export { encodeSchemaInfo, decodeSchemaInfo } from "../generated/vgi-client.js";
|
|
10
|
+
import type { CatalogInfo } from "../generated/vgi-client.js";
|
|
11
|
+
export type { CatalogInfo };
|
|
12
|
+
export { encodeCatalogInfo, decodeCatalogInfo } from "../generated/vgi-client.js";
|
|
13
|
+
import type { TableInfo } from "../generated/vgi-client.js";
|
|
14
|
+
export type { TableInfo };
|
|
15
|
+
export { encodeTableInfo, decodeTableInfo } from "../generated/vgi-client.js";
|
|
16
|
+
import type { ViewInfo } from "../generated/vgi-client.js";
|
|
17
|
+
export type { ViewInfo };
|
|
18
|
+
export { encodeViewInfo, decodeViewInfo } from "../generated/vgi-client.js";
|
|
19
|
+
import type { FunctionInfo } from "../generated/vgi-client.js";
|
|
20
|
+
export type { FunctionInfo };
|
|
21
|
+
/** @deprecated Use the FunctionInfo interface (snake_case) directly. */
|
|
22
|
+
export type FunctionInfoOptions = FunctionInfo;
|
|
23
|
+
export { encodeFunctionInfo, decodeFunctionInfo } from "../generated/vgi-client.js";
|
|
24
|
+
import type { MacroInfo } from "../generated/vgi-client.js";
|
|
25
|
+
export type { MacroInfo };
|
|
26
|
+
export { encodeMacroInfo, decodeMacroInfo } from "../generated/vgi-client.js";
|
|
27
|
+
import type { IndexInfo, IndexConstraintType } from "../generated/vgi-client.js";
|
|
28
|
+
export type { IndexInfo, IndexConstraintType };
|
|
29
|
+
export { encodeIndexInfo, decodeIndexInfo } from "../generated/vgi-client.js";
|
|
30
|
+
export interface CopyFromFormatInfo {
|
|
31
|
+
/** Free-text comment (CopyFromFunction's `copyFromComment`). */
|
|
32
|
+
comment?: string | null;
|
|
33
|
+
/** Function/format tags. */
|
|
34
|
+
tags: Record<string, string>;
|
|
35
|
+
/** The `FORMAT` identifier users type (single global namespace). */
|
|
36
|
+
format_name: string;
|
|
37
|
+
/** Registered name of the worker function that performs the read. */
|
|
38
|
+
handler: string;
|
|
39
|
+
/**
|
|
40
|
+
* Serialized Arrow schema of the format's options (same encoding as
|
|
41
|
+
* `FunctionInfo.arguments`), each field carrying type / `vgi_doc` description.
|
|
42
|
+
*/
|
|
43
|
+
options: Uint8Array;
|
|
44
|
+
/** `"from"` / `"to"` / `"both"` — the COPY direction this format serves. */
|
|
45
|
+
direction: string;
|
|
46
|
+
/** Intrinsic documentation from the handler's description. */
|
|
47
|
+
description: string;
|
|
48
|
+
/**
|
|
49
|
+
* COPY ... TO only — when true the writer requires rows in source order, so
|
|
50
|
+
* the extension uses a single-threaded sink (`REGULAR_COPY_TO_FILE`) instead
|
|
51
|
+
* of the default parallel sharded write. Set via `Meta.sinkOrderDependent`
|
|
52
|
+
* on a CopyToFunction; always false for readers. Mirrors vgi-python's
|
|
53
|
+
* `CopyFromFormatInfo.ordered`.
|
|
54
|
+
*/
|
|
55
|
+
ordered: boolean;
|
|
56
|
+
}
|
|
57
|
+
/** Encode a CopyFromFormatInfo to Arrow IPC bytes (single-row batch). */
|
|
58
|
+
export declare const encodeCopyFromFormatInfo: (v: CopyFromFormatInfo) => Uint8Array;
|
|
59
|
+
import { type VgiDataType } from "../arrow/index.js";
|
|
60
|
+
/**
|
|
61
|
+
* Result from `tableScanFunctionGet` — tells the VGI DuckDB extension which
|
|
62
|
+
* DuckDB function to call to obtain the data for a table.
|
|
63
|
+
*/
|
|
64
|
+
export interface ScanFunctionResult {
|
|
65
|
+
/** The DuckDB function to call (e.g. "read_parquet"). */
|
|
66
|
+
functionName: string;
|
|
67
|
+
/** Positional arguments, decoded from the inner Arrow batch. */
|
|
68
|
+
positionalArguments: unknown[];
|
|
69
|
+
/** Named arguments, decoded from the inner Arrow batch. */
|
|
70
|
+
namedArguments: Record<string, unknown>;
|
|
71
|
+
/** DuckDB extensions to load before calling the function. */
|
|
72
|
+
requiredExtensions: string[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Decode a ScanFunctionResult from a wire-shape inner result dict.
|
|
76
|
+
*
|
|
77
|
+
* The wire shape (per ScanFunctionResultSchema) is
|
|
78
|
+
* `{ function_name: utf8, arguments: binary, required_extensions: list<utf8> }`,
|
|
79
|
+
* where `arguments` is a serialized single-row batch with one column per
|
|
80
|
+
* argument: `arg_<index>` for positional args, the bare name for named args.
|
|
81
|
+
*/
|
|
82
|
+
export declare function decodeScanFunctionResult(inner: Record<string, unknown>): ScanFunctionResult;
|
|
83
|
+
/**
|
|
84
|
+
* Synthesise a one-branch `ScanBranchesResult` wire dict from a legacy
|
|
85
|
+
* `tableScanFunctionGet` wire result. Mirrors vgi-python's default
|
|
86
|
+
* `table_scan_branches_get` (catalog_interface.py): a single-source worker is
|
|
87
|
+
* automatically compatible with the branches-aware C++ side.
|
|
88
|
+
*
|
|
89
|
+
* Each branch is its own IPC stream carried in a `list<binary>` column. The
|
|
90
|
+
* legacy result's `arguments` field is already the nested-IPC form
|
|
91
|
+
* `ScanBranch` expects, so it passes through untouched.
|
|
92
|
+
*/
|
|
93
|
+
export declare function singleBranchResult(legacy: {
|
|
94
|
+
function_name: string;
|
|
95
|
+
arguments: unknown;
|
|
96
|
+
required_extensions?: string[];
|
|
97
|
+
}): {
|
|
98
|
+
branches: Uint8Array[];
|
|
99
|
+
required_extensions: string[];
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* One physical source backing a multi-branch scan, in the shape the
|
|
103
|
+
* `buildScanBranchesResult` helper consumes. Mirrors vgi-python's
|
|
104
|
+
* `ScanBranch` (catalog_interface.py).
|
|
105
|
+
*
|
|
106
|
+
* Each scalar argument carries an explicit Arrow `type` so the nested
|
|
107
|
+
* arguments batch is built with the wire type the C++ binder expects
|
|
108
|
+
* (e.g. utf8 for file paths, int64 for counts).
|
|
109
|
+
*/
|
|
110
|
+
export interface ScanBranchInput {
|
|
111
|
+
/** DuckDB function to call for this branch (e.g. "sequence", "read_parquet"). */
|
|
112
|
+
functionName: string;
|
|
113
|
+
/** Positional scalar arguments, each with its Arrow type. */
|
|
114
|
+
positionalArguments?: {
|
|
115
|
+
value: unknown;
|
|
116
|
+
type: VgiDataType;
|
|
117
|
+
}[];
|
|
118
|
+
/** Named scalar arguments, each with its Arrow type. */
|
|
119
|
+
namedArguments?: Record<string, {
|
|
120
|
+
value: unknown;
|
|
121
|
+
type: VgiDataType;
|
|
122
|
+
}>;
|
|
123
|
+
/** Optional SQL filter text AND'd into every scan of this branch. */
|
|
124
|
+
branchFilter?: string | null;
|
|
125
|
+
/** Declares this branch as the INSERT target (at most one per table). */
|
|
126
|
+
writable?: boolean;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Build a multi-branch `ScanBranchesResult` wire dict from explicit branch
|
|
130
|
+
* definitions. Each branch becomes its own 1-row `ScanBranchSchema` IPC
|
|
131
|
+
* stream carried in the `branches` list<binary> column. Mirrors vgi-python's
|
|
132
|
+
* `ScanBranchesResult` construction in the test fixture's
|
|
133
|
+
* `table_scan_branches_get`.
|
|
134
|
+
*
|
|
135
|
+
* An empty `branches` list is serialized verbatim — the C++ side loud-fails
|
|
136
|
+
* on it (that asymmetry is exercised by multi_branch_empty_branches.test).
|
|
137
|
+
*/
|
|
138
|
+
export declare function buildScanBranchesResult(branches: ScanBranchInput[], requiredExtensions?: string[]): {
|
|
139
|
+
branches: Uint8Array[];
|
|
140
|
+
required_extensions: string[];
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Catalog method return type — sync `T` or `Promise<T>`. The framework's
|
|
144
|
+
* dispatch handlers `await` every catalog call, so async overrides work
|
|
145
|
+
* out of the box. Default impls return sync values.
|
|
146
|
+
*/
|
|
147
|
+
type Awaitable<T> = T | Promise<T>;
|
|
148
|
+
export declare abstract class CatalogInterface {
|
|
149
|
+
abstract catalogs(): string[];
|
|
150
|
+
/**
|
|
151
|
+
* Attach this catalog. The framework already validates ATTACH options
|
|
152
|
+
* (name + type) against the specs the worker advertises in
|
|
153
|
+
* `catalogsInfo().attach_option_specs`, so `options` arrives as a
|
|
154
|
+
* validated, decoded `{name: value}` dict with typed column values.
|
|
155
|
+
* Use `{}` if no options were supplied.
|
|
156
|
+
*/
|
|
157
|
+
abstract attach(name: string, options?: Record<string, unknown>, dataVersionSpec?: string | null, implementationVersion?: string | null): Awaitable<CatalogAttachResult>;
|
|
158
|
+
/**
|
|
159
|
+
* List the catalogs this worker exposes with their version metadata. The
|
|
160
|
+
* `implementation_version` / `data_version_spec` come from the CatalogInfo
|
|
161
|
+
* returned by the read-only catalogs() signature below — a versioned worker
|
|
162
|
+
* overrides `catalogs()` / `catalogsInfo()` to advertise real values; the
|
|
163
|
+
* default derives them from the registered descriptor(s).
|
|
164
|
+
*/
|
|
165
|
+
catalogsInfo?(): Awaitable<import("../generated/vgi-client.js").CatalogInfo[]>;
|
|
166
|
+
abstract detach(attachOpaqueData: AttachOpaqueData): Awaitable<void>;
|
|
167
|
+
abstract version(attachOpaqueData: AttachOpaqueData, transactionOpaqueData?: TransactionOpaqueData): Awaitable<number>;
|
|
168
|
+
abstract schemas(attachOpaqueData: AttachOpaqueData, transactionOpaqueData?: TransactionOpaqueData): Awaitable<SchemaInfo[]>;
|
|
169
|
+
create(name: string, onConflict: string, options?: any): Awaitable<void>;
|
|
170
|
+
drop(name: string): Awaitable<void>;
|
|
171
|
+
schemaGet(attachOpaqueData: AttachOpaqueData, name: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<SchemaInfo | null>;
|
|
172
|
+
schemaCreate(attachOpaqueData: AttachOpaqueData, name: string, comment?: string | null, tags?: any, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
173
|
+
schemaDrop(attachOpaqueData: AttachOpaqueData, name: string, ignoreNotFound?: boolean, cascade?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
174
|
+
schemaContentsTables(attachOpaqueData: AttachOpaqueData, name: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<TableInfo[]>;
|
|
175
|
+
schemaContentsViews(attachOpaqueData: AttachOpaqueData, name: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<ViewInfo[]>;
|
|
176
|
+
schemaContentsFunctions(attachOpaqueData: AttachOpaqueData, name: string, type: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<FunctionInfo[]>;
|
|
177
|
+
tableGet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, atUnit?: string, atValue?: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<TableInfo | null>;
|
|
178
|
+
tableCreate(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columns: Uint8Array, onConflict: string, notNullConstraints?: number[], uniqueConstraints?: number[][], checkConstraints?: string[], transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
179
|
+
tableDrop(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
180
|
+
tableScanFunctionGet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, atUnit?: string, atValue?: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<any>;
|
|
181
|
+
/**
|
|
182
|
+
* Return the scan branches for a (possibly multi-source) table. Default
|
|
183
|
+
* delegates to `tableScanFunctionGet` and wraps the single result as a
|
|
184
|
+
* one-branch list, so every single-source catalog is compatible with the
|
|
185
|
+
* branches-aware C++ extension. Override for genuine multi-source tables.
|
|
186
|
+
*/
|
|
187
|
+
tableScanBranchesGet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, atUnit?: string, atValue?: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<any>;
|
|
188
|
+
/**
|
|
189
|
+
* Return serialized column statistics for a table, or null if none are
|
|
190
|
+
* available. The result is the IPC bytes of a ColumnStatistics RecordBatch
|
|
191
|
+
* (see src/util/statistics.ts for the schema) wrapped with an optional
|
|
192
|
+
* cache TTL. Callers typically override this to pull stats from a
|
|
193
|
+
* descriptor. Returning null signals "no stats" so DuckDB falls back to
|
|
194
|
+
* the function-level `table_function_statistics` path.
|
|
195
|
+
*/
|
|
196
|
+
tableColumnStatisticsGet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<{
|
|
197
|
+
bytes: Uint8Array;
|
|
198
|
+
cacheMaxAgeSeconds: number | null;
|
|
199
|
+
} | null>;
|
|
200
|
+
tableCommentSet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, comment?: string | null, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
201
|
+
tableRename(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, newName: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
202
|
+
tableColumnAdd(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columnName: string, columnType: string, defaultValue?: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
203
|
+
tableColumnDrop(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columnName: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
204
|
+
tableColumnRename(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columnName: string, newName: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
205
|
+
tableColumnDefaultSet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columnName: string, defaultValue: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
206
|
+
tableColumnDefaultDrop(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columnName: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
207
|
+
tableColumnTypeChange(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columnName: string, newType: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
208
|
+
tableNotNullSet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columnName: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
209
|
+
tableNotNullDrop(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columnName: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
210
|
+
viewGet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<ViewInfo | null>;
|
|
211
|
+
viewCreate(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, definition: string, onConflict: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
212
|
+
viewDrop(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
213
|
+
viewRename(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, newName: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
214
|
+
viewCommentSet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, comment?: string | null, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
215
|
+
macroGet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<MacroInfo | null>;
|
|
216
|
+
macroCreate(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, macroType: MacroType, parameters: string[], definition: string, onConflict: string, parameterDefaultValues?: Uint8Array | null,
|
|
217
|
+
/**
|
|
218
|
+
* Optional Arrow schema (one nullable field per parameter, in `parameters`
|
|
219
|
+
* order) serialized as IPC bytes, carrying per-parameter descriptions via the
|
|
220
|
+
* `vgi_doc` field metadata key. `null`/omitted when no per-parameter docs are
|
|
221
|
+
* supplied. Build with `macroArgumentsSchema` + `serializeSchema`.
|
|
222
|
+
*/
|
|
223
|
+
argumentsSchema?: Uint8Array | null, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
224
|
+
macroDrop(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
225
|
+
schemaContentsMacros(attachOpaqueData: AttachOpaqueData, name: string, type: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<MacroInfo[]>;
|
|
226
|
+
schemaContentsIndexes(attachOpaqueData: AttachOpaqueData, name: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<IndexInfo[]>;
|
|
227
|
+
indexGet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<IndexInfo | null>;
|
|
228
|
+
/**
|
|
229
|
+
* List custom `COPY ... FROM` formats advertised by this catalog. Catalog-level
|
|
230
|
+
* (not schema-scoped). The default returns an empty list, so catalogs that
|
|
231
|
+
* don't define COPY formats are unaffected. The VGI extension treats an empty
|
|
232
|
+
* list (or a not-implemented method) as "no custom formats". Mirrors
|
|
233
|
+
* vgi-python's `CatalogInterface.copy_from_formats`.
|
|
234
|
+
*/
|
|
235
|
+
copyFromFormats(attachOpaqueData: AttachOpaqueData, transactionOpaqueData?: TransactionOpaqueData): Awaitable<CopyFromFormatInfo[]>;
|
|
236
|
+
transactionBegin(attachOpaqueData: AttachOpaqueData): Awaitable<Uint8Array | null>;
|
|
237
|
+
transactionCommit(attachOpaqueData: AttachOpaqueData, transactionOpaqueData: TransactionOpaqueData): Awaitable<void>;
|
|
238
|
+
transactionRollback(attachOpaqueData: AttachOpaqueData, transactionOpaqueData: TransactionOpaqueData): Awaitable<void>;
|
|
239
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 } from "./interface.js";
|
|
2
|
+
import type { CatalogDescriptor } from "./descriptors.js";
|
|
3
|
+
import type { FunctionRegistry } from "../functions/registry.js";
|
|
4
|
+
export declare class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
5
|
+
private _descriptor;
|
|
6
|
+
private _registry;
|
|
7
|
+
private _attachments;
|
|
8
|
+
private _version;
|
|
9
|
+
constructor(descriptor: CatalogDescriptor, registry: FunctionRegistry);
|
|
10
|
+
catalogs(): string[];
|
|
11
|
+
catalogsInfo(): CatalogInfo[];
|
|
12
|
+
attach(name: string, options?: Record<string, unknown>, dataVersionSpec?: string | null, implementationVersion?: string | null): CatalogAttachResult | Promise<CatalogAttachResult>;
|
|
13
|
+
detach(attachOpaqueData: AttachOpaqueData): void;
|
|
14
|
+
version(attachOpaqueData: AttachOpaqueData, transactionOpaqueData?: TransactionOpaqueData): number | Promise<number>;
|
|
15
|
+
schemas(attachOpaqueData: AttachOpaqueData, transactionOpaqueData?: TransactionOpaqueData): SchemaInfo[];
|
|
16
|
+
private _estimatedObjectCount;
|
|
17
|
+
schemaGet(attachOpaqueData: AttachOpaqueData, name: string, transactionOpaqueData?: TransactionOpaqueData): SchemaInfo | null;
|
|
18
|
+
schemaContentsTables(attachOpaqueData: AttachOpaqueData, name: string, transactionOpaqueData?: TransactionOpaqueData): Promise<TableInfo[]>;
|
|
19
|
+
tableColumnStatisticsGet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, transactionOpaqueData?: TransactionOpaqueData): {
|
|
20
|
+
bytes: Uint8Array;
|
|
21
|
+
cacheMaxAgeSeconds: number | null;
|
|
22
|
+
} | null;
|
|
23
|
+
schemaContentsViews(attachOpaqueData: AttachOpaqueData, name: string, transactionOpaqueData?: TransactionOpaqueData): ViewInfo[];
|
|
24
|
+
schemaContentsFunctions(attachOpaqueData: AttachOpaqueData, name: string, type: string, transactionOpaqueData?: TransactionOpaqueData): FunctionInfo[];
|
|
25
|
+
schemaContentsMacros(attachOpaqueData: AttachOpaqueData, name: string, type: string, transactionOpaqueData?: TransactionOpaqueData): MacroInfo[];
|
|
26
|
+
schemaContentsIndexes(attachOpaqueData: AttachOpaqueData, name: string, transactionOpaqueData?: TransactionOpaqueData): IndexInfo[];
|
|
27
|
+
indexGet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, transactionOpaqueData?: TransactionOpaqueData): IndexInfo | null;
|
|
28
|
+
macroGet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, transactionOpaqueData?: TransactionOpaqueData): MacroInfo | null;
|
|
29
|
+
tableScanFunctionGet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, atUnit?: string, atValue?: string, transactionOpaqueData?: TransactionOpaqueData): any;
|
|
30
|
+
tableGet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, atUnit?: string, atValue?: string, transactionOpaqueData?: TransactionOpaqueData): Promise<TableInfo | null>;
|
|
31
|
+
viewGet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, transactionOpaqueData?: TransactionOpaqueData): ViewInfo | null;
|
|
32
|
+
copyFromFormats(attachOpaqueData: AttachOpaqueData, transactionOpaqueData?: TransactionOpaqueData): CopyFromFormatInfo[];
|
|
33
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { type VgiBatch } from "../arrow/index.js";
|
|
2
|
+
import { type RpcClient } from "@query-farm/vgi-rpc";
|
|
3
|
+
import { type SchemaInfo, type TableInfo, type ViewInfo, type FunctionInfo, type MacroInfo, type MacroType, type CatalogAttachResult, type AttachOpaqueData, type TransactionOpaqueData, type CatalogInfo, type ScanFunctionResult } from "../catalog/interface.js";
|
|
4
|
+
import { VgiClientError } from "./errors.js";
|
|
5
|
+
export { VgiClientError };
|
|
6
|
+
import type { VgiClientOptions, TableFunctionOptions, ScalarFunctionOptions, TableInOutFunctionOptions, OnCreateConflict, CatalogFunctionType, CatalogMacroType, CatalogAttachOptions, AttachOptionValue } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* High-level client for calling VGI worker functions and catalog API.
|
|
9
|
+
*
|
|
10
|
+
* Works with any RpcClient transport (subprocess or HTTP):
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { subprocessConnect } from "@query-farm/vgi-rpc";
|
|
13
|
+
* import { VgiClient, Arguments } from "vgi";
|
|
14
|
+
*
|
|
15
|
+
* const rpc = subprocessConnect(["./my-worker"]);
|
|
16
|
+
* const client = new VgiClient(rpc);
|
|
17
|
+
*
|
|
18
|
+
* for await (const rows of client.tableFunctionRows({
|
|
19
|
+
* functionName: "sequence",
|
|
20
|
+
* arguments: new Arguments([10]),
|
|
21
|
+
* })) {
|
|
22
|
+
* console.log(rows);
|
|
23
|
+
* }
|
|
24
|
+
* client.close();
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare class VgiClient {
|
|
28
|
+
private readonly rpc;
|
|
29
|
+
private readonly defaultAttachOpaqueData;
|
|
30
|
+
/**
|
|
31
|
+
* Construct a VgiClient wrapping an `RpcClient` transport.
|
|
32
|
+
*
|
|
33
|
+
* `options.attachOpaqueData` sets a client-wide default attach ID used by every
|
|
34
|
+
* function call that doesn't supply its own. Per-call `attachOpaqueData` on
|
|
35
|
+
* `TableFunctionOptions`/`ScalarFunctionOptions`/`TableInOutFunctionOptions`
|
|
36
|
+
* takes precedence — useful when a single client talks to multiple
|
|
37
|
+
* attached catalogs.
|
|
38
|
+
*/
|
|
39
|
+
constructor(rpc: RpcClient, options?: VgiClientOptions);
|
|
40
|
+
private _doBind;
|
|
41
|
+
private _doInit;
|
|
42
|
+
/** Call a table function, yielding output as RecordBatch instances. */
|
|
43
|
+
tableFunction(opts: TableFunctionOptions): AsyncGenerator<VgiBatch>;
|
|
44
|
+
/** Call a scalar function, yielding output as row objects. */
|
|
45
|
+
scalarFunctionRows(opts: ScalarFunctionOptions): AsyncGenerator<Record<string, any>[]>;
|
|
46
|
+
/** Call a scalar function, yielding output as RecordBatch instances. */
|
|
47
|
+
scalarFunction(opts: ScalarFunctionOptions): AsyncGenerator<VgiBatch>;
|
|
48
|
+
/** Call a table-in-out function, yielding output as row objects. */
|
|
49
|
+
tableInOutFunctionRows(opts: TableInOutFunctionOptions): AsyncGenerator<Record<string, any>[]>;
|
|
50
|
+
/** Call a table-in-out function, yielding output as RecordBatch instances. */
|
|
51
|
+
tableInOutFunction(opts: TableInOutFunctionOptions): AsyncGenerator<VgiBatch>;
|
|
52
|
+
/** Call a table function, yielding output as row objects. */
|
|
53
|
+
tableFunctionRows(opts: TableFunctionOptions): AsyncGenerator<Record<string, any>[]>;
|
|
54
|
+
/**
|
|
55
|
+
* List all catalogs with their advertised version metadata.
|
|
56
|
+
*
|
|
57
|
+
* Each entry has `{name, implementation_version?, data_version_spec?}`.
|
|
58
|
+
* Versioned workers populate the version fields; read-only workers
|
|
59
|
+
* leave both null.
|
|
60
|
+
*/
|
|
61
|
+
catalogsInfo(): Promise<CatalogInfo[]>;
|
|
62
|
+
/** List all available catalog names (shorthand for `catalogsInfo().map(c => c.name)`). */
|
|
63
|
+
catalogs(): Promise<string[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Attach a catalog by name. Returns connection details including the
|
|
66
|
+
* attachOpaqueData.
|
|
67
|
+
*
|
|
68
|
+
* `opts.options` is a plain key→value map; column types are inferred from
|
|
69
|
+
* the value at runtime (see AttachOptionValue for the mapping). Use
|
|
70
|
+
* `opts.optionsBytes` instead when you need Arrow types the inference
|
|
71
|
+
* can't express (Decimal, Timestamp, Int32 vs Int64, nested structs).
|
|
72
|
+
* Providing both throws.
|
|
73
|
+
*
|
|
74
|
+
* Versioned catalogs (see vgi-example-versioned-worker) validate
|
|
75
|
+
* `dataVersionSpec` / `implementationVersion` at attach time and echo
|
|
76
|
+
* back the resolved values on the result — callers can read those from
|
|
77
|
+
* `result.resolved_data_version` / `result.resolved_implementation_version`.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* const result = await client.catalogAttach("my_catalog", {
|
|
82
|
+
* options: { region: "us-east-1", maxCachedRows: 1000n, readOnly: true },
|
|
83
|
+
* dataVersionSpec: "1.0.0",
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
catalogAttach(name: string, opts?: CatalogAttachOptions): Promise<CatalogAttachResult>;
|
|
88
|
+
/** Detach a previously-attached catalog. */
|
|
89
|
+
catalogDetach(attachOpaqueData: AttachOpaqueData): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Create a new catalog.
|
|
92
|
+
*
|
|
93
|
+
* `options` is a plain key→value map; column types are inferred from the
|
|
94
|
+
* value at runtime (see AttachOptionValue). Use `optionsBytes` instead
|
|
95
|
+
* when you need Arrow types the inference can't express. Providing both
|
|
96
|
+
* throws.
|
|
97
|
+
*/
|
|
98
|
+
catalogCreate(name: string, onConflict: OnCreateConflict, options?: Uint8Array | {
|
|
99
|
+
options?: Record<string, AttachOptionValue>;
|
|
100
|
+
optionsBytes?: Uint8Array;
|
|
101
|
+
}): Promise<void>;
|
|
102
|
+
/** Drop a catalog by name. */
|
|
103
|
+
catalogDrop(name: string): Promise<void>;
|
|
104
|
+
/** Get the current catalog version number. */
|
|
105
|
+
catalogVersion(attachOpaqueData: AttachOpaqueData, transactionOpaqueData?: TransactionOpaqueData): Promise<number>;
|
|
106
|
+
/** Begin a new transaction. Returns the transaction ID. */
|
|
107
|
+
transactionBegin(attachOpaqueData: AttachOpaqueData): Promise<Uint8Array>;
|
|
108
|
+
/** Commit a transaction. */
|
|
109
|
+
transactionCommit(attachOpaqueData: AttachOpaqueData, transactionOpaqueData: TransactionOpaqueData): Promise<void>;
|
|
110
|
+
/** Rollback a transaction. */
|
|
111
|
+
transactionRollback(attachOpaqueData: AttachOpaqueData, transactionOpaqueData: TransactionOpaqueData): Promise<void>;
|
|
112
|
+
/** List schemas in an attached catalog. */
|
|
113
|
+
schemas(attachOpaqueData: AttachOpaqueData, transactionOpaqueData?: TransactionOpaqueData): Promise<SchemaInfo[]>;
|
|
114
|
+
/** Get a schema by name, or null if not found. */
|
|
115
|
+
schemaGet(attachOpaqueData: AttachOpaqueData, name: string, transactionOpaqueData?: TransactionOpaqueData): Promise<SchemaInfo | null>;
|
|
116
|
+
/** Create a new schema. */
|
|
117
|
+
schemaCreate(attachOpaqueData: AttachOpaqueData, name: string, opts?: {
|
|
118
|
+
onConflict?: OnCreateConflict;
|
|
119
|
+
comment?: string | null;
|
|
120
|
+
tags?: Record<string, string> | null;
|
|
121
|
+
transactionOpaqueData?: TransactionOpaqueData;
|
|
122
|
+
}): Promise<void>;
|
|
123
|
+
/** Drop a schema by name. */
|
|
124
|
+
schemaDrop(attachOpaqueData: AttachOpaqueData, name: string, ignoreNotFound?: boolean, cascade?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
125
|
+
/** List tables in a schema. */
|
|
126
|
+
schemaContentsTables(attachOpaqueData: AttachOpaqueData, name: string, transactionOpaqueData?: TransactionOpaqueData): Promise<TableInfo[]>;
|
|
127
|
+
/** List views in a schema. */
|
|
128
|
+
schemaContentsViews(attachOpaqueData: AttachOpaqueData, name: string, transactionOpaqueData?: TransactionOpaqueData): Promise<ViewInfo[]>;
|
|
129
|
+
/** List functions in a schema, filtered by type. */
|
|
130
|
+
schemaContentsFunctions(attachOpaqueData: AttachOpaqueData, name: string, type: CatalogFunctionType, transactionOpaqueData?: TransactionOpaqueData): Promise<FunctionInfo[]>;
|
|
131
|
+
/** Get a table by name, or null if not found. */
|
|
132
|
+
tableGet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, transactionOpaqueData?: TransactionOpaqueData): Promise<TableInfo | null>;
|
|
133
|
+
/** Create a new table. */
|
|
134
|
+
tableCreate(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columns: Uint8Array, onConflict: OnCreateConflict, notNullConstraints?: number[], uniqueConstraints?: number[][], checkConstraints?: string[], transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
135
|
+
/** Drop a table by name. */
|
|
136
|
+
tableDrop(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, ignoreNotFound?: boolean, cascade?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Get the scan function for a table — tells DuckDB which function to call
|
|
139
|
+
* to read the table data (e.g. `read_parquet` with a path argument). Used
|
|
140
|
+
* by the VGI extension during query planning.
|
|
141
|
+
*/
|
|
142
|
+
tableScanFunctionGet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, atUnit?: string | null, atValue?: string | null, transactionOpaqueData?: TransactionOpaqueData): Promise<ScanFunctionResult>;
|
|
143
|
+
/** Set or clear the comment on a table. */
|
|
144
|
+
tableCommentSet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, comment?: string | null, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
145
|
+
/** Rename a table. */
|
|
146
|
+
tableRename(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, newName: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
147
|
+
/** Add a column to a table. */
|
|
148
|
+
tableColumnAdd(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columnName: string, columnType: string, defaultValue?: string | null, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
149
|
+
/** Drop a column from a table. */
|
|
150
|
+
tableColumnDrop(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columnName: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
151
|
+
/** Rename a column in a table. */
|
|
152
|
+
tableColumnRename(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columnName: string, newName: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
153
|
+
/** Set the default value for a column. */
|
|
154
|
+
tableColumnDefaultSet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columnName: string, defaultValue: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
155
|
+
/** Remove the default value from a column. */
|
|
156
|
+
tableColumnDefaultDrop(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columnName: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* Change the type of a column.
|
|
159
|
+
*
|
|
160
|
+
* `columnDefinition` is a serialized Arrow Schema with a single field whose
|
|
161
|
+
* name identifies the target column and whose type is the new column type.
|
|
162
|
+
* `expression` is an optional SQL expression used to convert existing values.
|
|
163
|
+
*/
|
|
164
|
+
tableColumnTypeChange(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columnDefinition: Uint8Array, expression?: string | null, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
165
|
+
/** Set a NOT NULL constraint on a column. */
|
|
166
|
+
tableNotNullSet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columnName: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
167
|
+
/** Remove a NOT NULL constraint from a column. */
|
|
168
|
+
tableNotNullDrop(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, columnName: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
169
|
+
/** Get a view by name, or null if not found. */
|
|
170
|
+
viewGet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, transactionOpaqueData?: TransactionOpaqueData): Promise<ViewInfo | null>;
|
|
171
|
+
/** Create a new view. */
|
|
172
|
+
viewCreate(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, definition: string, onConflict: OnCreateConflict, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
173
|
+
/** Drop a view by name. */
|
|
174
|
+
viewDrop(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, ignoreNotFound?: boolean, cascade?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
175
|
+
/** Rename a view. */
|
|
176
|
+
viewRename(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, newName: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
177
|
+
/** Set or clear the comment on a view. */
|
|
178
|
+
viewCommentSet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, comment?: string | null, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
179
|
+
/** Get a macro by name, or null if not found. */
|
|
180
|
+
macroGet(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, transactionOpaqueData?: TransactionOpaqueData): Promise<MacroInfo | null>;
|
|
181
|
+
/** List macros in a schema, filtered by type. */
|
|
182
|
+
schemaContentsMacros(attachOpaqueData: AttachOpaqueData, name: string, type: CatalogMacroType, transactionOpaqueData?: TransactionOpaqueData): Promise<MacroInfo[]>;
|
|
183
|
+
/** Create a new macro. */
|
|
184
|
+
macroCreate(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, macroType: MacroType, parameters: string[], definition: string, onConflict: OnCreateConflict, parameterDefaultValues?: Uint8Array | null, argumentsSchema?: Uint8Array | null, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
185
|
+
/** Drop a macro by name. */
|
|
186
|
+
macroDrop(attachOpaqueData: AttachOpaqueData, schemaName: string, name: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Promise<void>;
|
|
187
|
+
/** Close the underlying RPC connection. */
|
|
188
|
+
close(): void;
|
|
189
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RpcError, type RpcClient } from "@query-farm/vgi-rpc";
|
|
2
|
+
/** Error thrown by VgiClient when an RPC call fails or returns unexpected data. */
|
|
3
|
+
export declare class VgiClientError extends Error {
|
|
4
|
+
/** Remote traceback from the worker, when an RpcError carried one. */
|
|
5
|
+
readonly remoteTraceback?: string;
|
|
6
|
+
/** Underlying error type from the worker (e.g. "ValueError"), when known. */
|
|
7
|
+
readonly errorType?: string;
|
|
8
|
+
constructor(message: string, options?: {
|
|
9
|
+
remoteTraceback?: string;
|
|
10
|
+
errorType?: string;
|
|
11
|
+
cause?: unknown;
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Build a VgiClientError from an underlying RpcError, preserving the
|
|
15
|
+
* remote error type, message, and traceback so the worker-raised exception
|
|
16
|
+
* shows up at the top of the stack rather than buried under VGI framing.
|
|
17
|
+
* Mirrors Python's ClientError.from_rpc_error.
|
|
18
|
+
*/
|
|
19
|
+
static fromRpcError(e: RpcError): VgiClientError;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Wrap an RpcClient so any RpcError thrown by call/stream is rethrown as a
|
|
23
|
+
* VgiClientError carrying the worker's remote traceback. Other errors
|
|
24
|
+
* propagate unchanged.
|
|
25
|
+
*/
|
|
26
|
+
export declare function wrapRpcWithErrorEnrichment(rpc: RpcClient): RpcClient;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deserialize a List<Binary> of serialized info batches into typed info objects.
|
|
3
|
+
*/
|
|
4
|
+
export declare function deserializeInfoList<T>(items: unknown, deserializeFn: (bytes: Uint8Array) => T): T[];
|
|
5
|
+
/**
|
|
6
|
+
* Deserialize Arrow Map entries into a plain Record<string, string>.
|
|
7
|
+
*/
|
|
8
|
+
export declare function deserializeTags(mapVal: unknown): Record<string, string>;
|
|
9
|
+
/**
|
|
10
|
+
* Convert sync/async iterable to async iterator.
|
|
11
|
+
*/
|
|
12
|
+
export declare function toAsyncIterator<T>(input: Iterable<T> | AsyncIterable<T>): AsyncIterator<T>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { toUint8Array } from "../util/bytes.js";
|
|
2
|
+
import type { VgiBatch } from "../arrow/index.js";
|
|
3
|
+
export { toUint8Array };
|
|
4
|
+
/**
|
|
5
|
+
* Wrap a RecordBatch as a { request: Uint8Array } dict for RPC params.
|
|
6
|
+
* DuckDB wraps ArrowSerializableDataclass params in a single "request" Binary column.
|
|
7
|
+
*/
|
|
8
|
+
export declare function wrapRequest(batch: VgiBatch): {
|
|
9
|
+
request: Uint8Array;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Unwrap a { result: Uint8Array } response dict.
|
|
13
|
+
* The "result" Binary column contains a serialized inner batch;
|
|
14
|
+
* returns its row 0 as a flat dict.
|
|
15
|
+
*/
|
|
16
|
+
export declare function unwrapResult(result: Record<string, any>): Record<string, any>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { VgiBatch } from "../arrow/index.js";
|
|
2
|
+
import type { Arguments } from "../arguments/arguments.js";
|
|
3
|
+
import type { AttachOptionValue } from "../catalog/attach-options.js";
|
|
4
|
+
import type { BindResponse } from "../protocol/types.js";
|
|
5
|
+
import { OrderByDirection, OrderByNullOrder } from "../protocol/types.js";
|
|
6
|
+
export type { AttachOptionValue };
|
|
7
|
+
export { OrderByDirection, OrderByNullOrder };
|
|
8
|
+
/** ORDER BY pushdown hint passed at init time. */
|
|
9
|
+
export interface OrderByPushdown {
|
|
10
|
+
columnName: string;
|
|
11
|
+
direction: OrderByDirection;
|
|
12
|
+
nullOrder: OrderByNullOrder;
|
|
13
|
+
/** Optional LIMIT to combine with ORDER BY. */
|
|
14
|
+
limit?: bigint | number | null;
|
|
15
|
+
}
|
|
16
|
+
/** TABLESAMPLE pushdown hint passed at init time. */
|
|
17
|
+
export interface TablesamplePushdown {
|
|
18
|
+
/** Sample percentage in [0, 100]. */
|
|
19
|
+
percentage: number;
|
|
20
|
+
/** Optional sampling seed. */
|
|
21
|
+
seed?: bigint | number | null;
|
|
22
|
+
}
|
|
23
|
+
/** Callback invoked after a successful bind, before init. */
|
|
24
|
+
export type BindResultCallback = (response: BindResponse) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Options bag for VgiClient.catalogAttach.
|
|
27
|
+
*
|
|
28
|
+
* Pass `options` as a plain key→value map — the client serializes to an
|
|
29
|
+
* Arrow RecordBatch with per-value type inference (see AttachOptionValue).
|
|
30
|
+
* For Arrow types that inference can't express (Decimal, Timestamp, exact
|
|
31
|
+
* int width, nested struct), use `optionsBytes` to supply pre-serialized
|
|
32
|
+
* bytes. Providing both throws.
|
|
33
|
+
*
|
|
34
|
+
* `dataVersionSpec` / `implementationVersion` are sent to versioned
|
|
35
|
+
* catalogs for attach-time validation; workers that aren't versioned
|
|
36
|
+
* ignore them.
|
|
37
|
+
*/
|
|
38
|
+
export interface CatalogAttachOptions {
|
|
39
|
+
options?: Record<string, AttachOptionValue>;
|
|
40
|
+
optionsBytes?: Uint8Array;
|
|
41
|
+
dataVersionSpec?: string | null;
|
|
42
|
+
implementationVersion?: string | null;
|
|
43
|
+
}
|
|
44
|
+
/** Conflict resolution strategy for create operations. */
|
|
45
|
+
export type OnCreateConflict = "error" | "ignore" | "replace";
|
|
46
|
+
/** DuckDB catalog function type filter (sent as uppercase wire values). */
|
|
47
|
+
export type CatalogFunctionType = "SCALAR_FUNCTION" | "TABLE_FUNCTION";
|
|
48
|
+
/** Macro type filter for schema contents listing (uppercase wire values). */
|
|
49
|
+
export type CatalogMacroType = "SCALAR_MACRO" | "TABLE_MACRO";
|
|
50
|
+
/** Options for constructing a VgiClient. */
|
|
51
|
+
export interface VgiClientOptions {
|
|
52
|
+
/** Pre-existing attach ID to bind this client to a specific catalog. */
|
|
53
|
+
attachOpaqueData?: Uint8Array;
|
|
54
|
+
}
|
|
55
|
+
/** Options for calling a table function. */
|
|
56
|
+
export interface TableFunctionOptions {
|
|
57
|
+
/** Name of the function to call. */
|
|
58
|
+
functionName: string;
|
|
59
|
+
/** Positional and named arguments. */
|
|
60
|
+
arguments?: Arguments;
|
|
61
|
+
/** Column indices to project (filter pushdown). */
|
|
62
|
+
projectionIds?: number[];
|
|
63
|
+
/** Filter pushdown batch. */
|
|
64
|
+
pushdownFilters?: VgiBatch;
|
|
65
|
+
/** DuckDB settings to pass to the function. */
|
|
66
|
+
settings?: VgiBatch;
|
|
67
|
+
/** Transaction ID for transactional catalogs. */
|
|
68
|
+
transactionOpaqueData?: Uint8Array;
|
|
69
|
+
/** Attach ID to bind this call to a specific catalog attach. Overrides the client-level attachOpaqueData. */
|
|
70
|
+
attachOpaqueData?: Uint8Array;
|
|
71
|
+
/** ORDER BY pushdown hint from DuckDB's RowGroupPruner. */
|
|
72
|
+
orderBy?: OrderByPushdown;
|
|
73
|
+
/** TABLESAMPLE pushdown hint from DuckDB's SamplingPushdown optimizer. */
|
|
74
|
+
tablesample?: TablesamplePushdown;
|
|
75
|
+
/** Join-key value batches, one per join-keys column. */
|
|
76
|
+
joinKeys?: VgiBatch[];
|
|
77
|
+
/** Invoked after bind, before init. Receives the bind response. */
|
|
78
|
+
onBind?: BindResultCallback;
|
|
79
|
+
}
|
|
80
|
+
/** Options for calling a scalar function. */
|
|
81
|
+
export interface ScalarFunctionOptions {
|
|
82
|
+
/** Name of the function to call. */
|
|
83
|
+
functionName: string;
|
|
84
|
+
/** Input batches to process. */
|
|
85
|
+
input: Iterable<VgiBatch> | AsyncIterable<VgiBatch>;
|
|
86
|
+
/** Positional and named arguments. */
|
|
87
|
+
arguments?: Arguments;
|
|
88
|
+
/** DuckDB settings to pass to the function. */
|
|
89
|
+
settings?: VgiBatch;
|
|
90
|
+
/** DuckDB secrets to pass to the function. */
|
|
91
|
+
secrets?: VgiBatch;
|
|
92
|
+
/** Transaction ID for transactional catalogs. */
|
|
93
|
+
transactionOpaqueData?: Uint8Array;
|
|
94
|
+
/** Attach ID to bind this call to a specific catalog attach. Overrides the client-level attachOpaqueData. */
|
|
95
|
+
attachOpaqueData?: Uint8Array;
|
|
96
|
+
/** Invoked after bind, before init. Receives the bind response. */
|
|
97
|
+
onBind?: BindResultCallback;
|
|
98
|
+
}
|
|
99
|
+
/** Options for calling a table-in-out function. */
|
|
100
|
+
export interface TableInOutFunctionOptions {
|
|
101
|
+
/** Name of the function to call. */
|
|
102
|
+
functionName: string;
|
|
103
|
+
/** Input batches to process. */
|
|
104
|
+
input: Iterable<VgiBatch> | AsyncIterable<VgiBatch>;
|
|
105
|
+
/** Positional and named arguments. */
|
|
106
|
+
arguments?: Arguments;
|
|
107
|
+
/** Column indices to project (filter pushdown). */
|
|
108
|
+
projectionIds?: number[];
|
|
109
|
+
/** Filter pushdown batch. */
|
|
110
|
+
pushdownFilters?: VgiBatch;
|
|
111
|
+
/** DuckDB settings to pass to the function. */
|
|
112
|
+
settings?: VgiBatch;
|
|
113
|
+
/** Transaction ID for transactional catalogs. */
|
|
114
|
+
transactionOpaqueData?: Uint8Array;
|
|
115
|
+
/** Attach ID to bind this call to a specific catalog attach. Overrides the client-level attachOpaqueData. */
|
|
116
|
+
attachOpaqueData?: Uint8Array;
|
|
117
|
+
/** ORDER BY pushdown hint from DuckDB's RowGroupPruner. */
|
|
118
|
+
orderBy?: OrderByPushdown;
|
|
119
|
+
/** TABLESAMPLE pushdown hint from DuckDB's SamplingPushdown optimizer. */
|
|
120
|
+
tablesample?: TablesamplePushdown;
|
|
121
|
+
/** Join-key value batches, one per join-keys column. */
|
|
122
|
+
joinKeys?: VgiBatch[];
|
|
123
|
+
/** Invoked after bind, before init. Receives the bind response. */
|
|
124
|
+
onBind?: BindResultCallback;
|
|
125
|
+
}
|