@query-farm/vgi 0.48.3 → 0.48.4
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/dist/catalog/descriptors.d.ts +30 -0
- package/dist/catalog/interface.d.ts +28 -0
- package/dist/catalog/read-only.d.ts +16 -2
- package/dist/client-entry.js.map +2 -2
- package/dist/index.core.d.ts +2 -0
- package/dist/index.js +230 -34
- package/dist/index.js.map +12 -11
- package/dist/protocol/handlers/catalog/shared.d.ts +8 -0
- package/dist/serve-entry.js +43 -9
- package/dist/serve-entry.js.map +6 -6
- package/dist/worker-cf-entry.js +136 -19
- package/dist/worker-cf-entry.js.map +11 -10
- package/dist/write-results.d.ts +57 -0
- package/package.json +1 -1
- package/src/catalog/descriptors.ts +30 -0
- package/src/catalog/interface.ts +51 -0
- package/src/catalog/read-only.ts +123 -18
- package/src/index.core.ts +23 -0
- package/src/protocol/handlers/catalog/shared.ts +17 -0
- package/src/protocol/handlers/catalog/table.ts +37 -0
- package/src/protocol/handlers/function.ts +42 -14
- package/src/write-results.ts +174 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { VgiSchema, VgiDataType } from "../arrow/index.js";
|
|
2
2
|
import type { AttachCatalogInfo } from "./interface.js";
|
|
3
3
|
import type { AttachOptionSpec } from "./attach-option.js";
|
|
4
|
+
import type { WriteOperation, WriteResultMode } from "../write-results.js";
|
|
4
5
|
import type { VgiFunction } from "../functions/types.js";
|
|
5
6
|
import type { Arguments } from "../arguments/arguments.js";
|
|
6
7
|
import type { ColumnStatistics } from "../util/statistics.js";
|
|
@@ -33,6 +34,35 @@ export interface TableDescriptor {
|
|
|
33
34
|
columns?: VgiSchema;
|
|
34
35
|
function?: VgiFunction;
|
|
35
36
|
arguments?: Arguments;
|
|
37
|
+
/**
|
|
38
|
+
* Table in-out function backing `INSERT INTO <table>`. It receives the new
|
|
39
|
+
* rows (the table's user columns) and returns a `writeResultSchema` batch
|
|
40
|
+
* for the mode in its `write_options` (see `write-results.ts`). Omitted
|
|
41
|
+
* means the table does not accept INSERT.
|
|
42
|
+
*/
|
|
43
|
+
insertFunction?: VgiFunction;
|
|
44
|
+
/**
|
|
45
|
+
* Table in-out function backing `UPDATE <table>`. It receives the changed
|
|
46
|
+
* columns plus the row-id column (`rowIdField()`, which the scan
|
|
47
|
+
* `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`).
|
|
50
|
+
*/
|
|
51
|
+
updateFunction?: VgiFunction;
|
|
52
|
+
/**
|
|
53
|
+
* Table in-out function backing `DELETE FROM <table>`. It receives the
|
|
54
|
+
* row-id column of each deleted row. Requires `function`, with the same
|
|
55
|
+
* projection-pushdown conditions as `updateFunction`.
|
|
56
|
+
*/
|
|
57
|
+
deleteFunction?: VgiFunction;
|
|
58
|
+
/**
|
|
59
|
+
* The richest result mode each write function produces: `count` (plain
|
|
60
|
+
* DML), `rows` (`RETURNING`) or `changes` (old/new pairs). Ordered
|
|
61
|
+
* `count < rows < changes`; supporting one mode promises every lower one.
|
|
62
|
+
* An operation with a write function but no entry defaults to `count`.
|
|
63
|
+
* Mirrors vgi-python's `Table.write_result_modes`.
|
|
64
|
+
*/
|
|
65
|
+
writeResultModes?: Partial<Record<WriteOperation, WriteResultMode>>;
|
|
36
66
|
/** @deprecated Not sent under vgi.v3 (serving throws). Use `constraints: [constraintRecord({ kind: "NOT_NULL", ... })]`. */
|
|
37
67
|
notNull?: string[];
|
|
38
68
|
/** @deprecated Not sent under vgi.v3 (serving throws). Use `constraints: [constraintRecord({ kind: "UNIQUE", ... })]`. */
|
|
@@ -108,6 +108,18 @@ export interface ScanFunctionResult {
|
|
|
108
108
|
*/
|
|
109
109
|
schemaPath: string[] | null;
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* The `ScanFunctionResult` wire record as a catalog method returns it:
|
|
113
|
+
* `tableScanFunctionGet` (untyped, for history) and the write-function lookups
|
|
114
|
+
* `tableInsertFunctionGet` / `tableUpdateFunctionGet` / `tableDeleteFunctionGet`.
|
|
115
|
+
* `arguments` is the serialized inner arguments batch.
|
|
116
|
+
*/
|
|
117
|
+
export interface ScanFunctionResultRecord {
|
|
118
|
+
function_name: string;
|
|
119
|
+
arguments: Uint8Array;
|
|
120
|
+
required_extensions: string[];
|
|
121
|
+
schema_path: string[] | null;
|
|
122
|
+
}
|
|
111
123
|
/**
|
|
112
124
|
* Encode a ScanFunctionResult wire record — the single-row batch shape
|
|
113
125
|
* `{ function_name, arguments, required_extensions, schema_path }` that
|
|
@@ -405,6 +417,22 @@ export declare abstract class CatalogInterface {
|
|
|
405
417
|
tableConstraintsApply(request: ConstraintsApplyRequest): Promise<ConstraintSnapshot>;
|
|
406
418
|
tableDrop(attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, ignoreNotFound?: boolean, transactionOpaqueData?: TransactionOpaqueData): Awaitable<void>;
|
|
407
419
|
tableScanFunctionGet(attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, atUnit?: string, atValue?: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<any>;
|
|
420
|
+
/**
|
|
421
|
+
* The table in-out function backing `INSERT INTO` this table. Default:
|
|
422
|
+
* the table is read-only. `writableBranchFunctionName` names the writable
|
|
423
|
+
* arm of a multi-branch table (null for a single-branch one).
|
|
424
|
+
*/
|
|
425
|
+
tableInsertFunctionGet(attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, transactionOpaqueData?: TransactionOpaqueData, writableBranchFunctionName?: string | null): Awaitable<ScanFunctionResultRecord>;
|
|
426
|
+
/**
|
|
427
|
+
* The table in-out function backing `UPDATE` of this table. Its input is the
|
|
428
|
+
* changed columns plus the row-id column. Default: the table is read-only.
|
|
429
|
+
*/
|
|
430
|
+
tableUpdateFunctionGet(attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<ScanFunctionResultRecord>;
|
|
431
|
+
/**
|
|
432
|
+
* The table in-out function backing `DELETE FROM` this table. Its input is
|
|
433
|
+
* the row-id column. Default: the table is read-only.
|
|
434
|
+
*/
|
|
435
|
+
tableDeleteFunctionGet(attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, transactionOpaqueData?: TransactionOpaqueData): Awaitable<ScanFunctionResultRecord>;
|
|
408
436
|
/**
|
|
409
437
|
* Return the scan branches for a (possibly multi-source) table. Default
|
|
410
438
|
* delegates to `tableScanFunctionGet` and wraps the single result as a
|
|
@@ -1,4 +1,4 @@
|
|
|
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";
|
|
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
2
|
import { type CatalogDescriptor } from "./descriptors.js";
|
|
3
3
|
import type { FunctionRegistry } from "../functions/registry.js";
|
|
4
4
|
import { type AttachOptionSpec } from "./attach-option.js";
|
|
@@ -93,7 +93,16 @@ export declare class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
93
93
|
* `constraints`; override when tables are served outside the descriptor.
|
|
94
94
|
*/
|
|
95
95
|
catalogReadProfiles(): string[];
|
|
96
|
-
/**
|
|
96
|
+
/**
|
|
97
|
+
* Write profiles this catalog implements. A table that carries constraint
|
|
98
|
+
* records AND has a write function makes the catalog advertise
|
|
99
|
+
* `vgi.constraint.enforce.v1`: DuckDB only writes to a constrained table
|
|
100
|
+
* when the provider promises to keep its ENFORCED constraints, so such a
|
|
101
|
+
* table's write functions must reject rows that would violate them (for
|
|
102
|
+
* instance by refusing to change key columns).
|
|
103
|
+
*/
|
|
104
|
+
catalogWriteProfiles(): string[];
|
|
105
|
+
/** The descriptor's profiles: records are served, never mutated here; writable constrained tables enforce. */
|
|
97
106
|
catalogCapabilities(_attachOpaqueData: AttachOpaqueData): CatalogCapabilities | null;
|
|
98
107
|
detach(attachOpaqueData: AttachOpaqueData): void;
|
|
99
108
|
version(attachOpaqueData: AttachOpaqueData, transactionOpaqueData?: TransactionOpaqueData): number | Promise<number>;
|
|
@@ -143,6 +152,11 @@ export declare class ReadOnlyCatalogInterface extends CatalogInterface {
|
|
|
143
152
|
indexGet(attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, transactionOpaqueData?: TransactionOpaqueData): IndexInfo | null;
|
|
144
153
|
macroGet(attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, transactionOpaqueData?: TransactionOpaqueData): MacroInfo | null;
|
|
145
154
|
tableScanFunctionGet(attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, atUnit?: string, atValue?: string, transactionOpaqueData?: TransactionOpaqueData): any;
|
|
155
|
+
/** The write function for `operation`, or a read-only / not-found error. */
|
|
156
|
+
private _writeFunctionGet;
|
|
157
|
+
tableInsertFunctionGet(_attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, _transactionOpaqueData?: TransactionOpaqueData, _writableBranchFunctionName?: string | null): ScanFunctionResultRecord;
|
|
158
|
+
tableUpdateFunctionGet(_attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, _transactionOpaqueData?: TransactionOpaqueData): ScanFunctionResultRecord;
|
|
159
|
+
tableDeleteFunctionGet(_attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, _transactionOpaqueData?: TransactionOpaqueData): ScanFunctionResultRecord;
|
|
146
160
|
tableGet(attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, atUnit?: string, atValue?: string, transactionOpaqueData?: TransactionOpaqueData): Promise<TableInfo | null>;
|
|
147
161
|
viewGet(attachOpaqueData: AttachOpaqueData, schemaPath: string[], name: string, transactionOpaqueData?: TransactionOpaqueData): ViewInfo | null;
|
|
148
162
|
copyFromFormats(attachOpaqueData: AttachOpaqueData, transactionOpaqueData?: TransactionOpaqueData): CopyFromFormatInfo[];
|