mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 20:44:00 +00:00
feat(nodejs): add table delta streams (#5149)
Adds the Embedded `Table.delta` API to the Node.js bindings, matching the Rust/Python contract from #5135. `Table.delta(fromVersion, toVersion?)` accepts a positive safe-integer number, a positive lossless u64 `bigint`, or a same-branch tag string. `TableDelta` exposes `beginVersion`/`endVersion` as `bigint`, streaming `insertedRows()`, `updatedRows()`, `upsertedRows()`, `deletedRowIds()`, and `listTransactions()` with `readVersion` as `bigint`. Readers reuse the existing native Arrow IPC iterator adapter. They are lazy, single-use, serialize pulls, capture/cache the schema before polling, and release the native stream on completion, break, or error. Row readers retain the Rust contract: equal endpoints return empty streams with schemas, invalid/reversed/missing endpoints and cross-branch tags are rejected, and Restore or incomplete transaction history fail closed with full-rescan and range-end checkpoint guidance. Enterprise tables remain unsupported through the native Rust default. The abstract `Table` keeps a concrete unsupported `delta` default for custom subclasses; `LocalTable` overrides it. TypeDoc API docs and focused Node tests cover pinned targets, typed bigint values, transaction listing, lazy rejected readers, schema/decode failures, aliasing, and early drop. Refs OSS-2860
This commit is contained in:
@@ -552,6 +552,53 @@ containing the new version number of the table
|
||||
|
||||
***
|
||||
|
||||
### delta()
|
||||
|
||||
```ts
|
||||
delta(fromVersion, toVersion?): Promise<TableDelta>
|
||||
```
|
||||
|
||||
Compare two persisted versions or same-branch tags on an Embedded table.
|
||||
|
||||
`fromVersion` is exclusive and `toVersion` is inclusive. Omitting
|
||||
`toVersion` uses the version currently visible through this handle,
|
||||
including a checked-out version. The endpoints are fixed when the delta is
|
||||
created.
|
||||
|
||||
Row readers require stable row IDs at both endpoints. Create the table with
|
||||
`storageOptions: { new_table_enable_stable_row_ids: "true" }` to enable
|
||||
them. `listTransactions()` works without stable row IDs.
|
||||
|
||||
Row readers reject ranges containing a Restore, or ranges whose transaction
|
||||
history cannot prove they are restore-free. Recompute the checkpoint with a
|
||||
full rescan and reinitialize it at the range end version.
|
||||
|
||||
LanceDB Enterprise tables reject this operation.
|
||||
|
||||
#### Parameters
|
||||
|
||||
* **fromVersion**: [`DeltaVersion`](../type-aliases/DeltaVersion.md)
|
||||
|
||||
* **toVersion?**: [`DeltaVersion`](../type-aliases/DeltaVersion.md)
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`TableDelta`](TableDelta.md)>
|
||||
|
||||
#### Example
|
||||
|
||||
```ts
|
||||
const delta = await table.delta("baseline");
|
||||
const reader = delta.insertedRows();
|
||||
console.log((await reader.schema()).fields.map((field) => field.name));
|
||||
for await (const batch of reader) {
|
||||
console.log(batch.getChild("id")?.toJSON());
|
||||
}
|
||||
console.log(await delta.listTransactions());
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
### disableRTE()
|
||||
|
||||
```ts
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
||||
|
||||
***
|
||||
|
||||
[@lancedb/lancedb](../globals.md) / TableDelta
|
||||
|
||||
# Class: TableDelta
|
||||
|
||||
A handle for reading changes between two pinned table versions.
|
||||
|
||||
Created by [Table.delta](Table.md#delta). Endpoints are fixed at creation; later writes
|
||||
or tag moves do not change this delta.
|
||||
|
||||
## Accessors
|
||||
|
||||
### beginVersion
|
||||
|
||||
```ts
|
||||
get beginVersion(): bigint
|
||||
```
|
||||
|
||||
The exclusive start version, as an exact u64 bigint.
|
||||
|
||||
#### Returns
|
||||
|
||||
`bigint`
|
||||
|
||||
***
|
||||
|
||||
### endVersion
|
||||
|
||||
```ts
|
||||
get endVersion(): bigint
|
||||
```
|
||||
|
||||
The inclusive end version, as an exact u64 bigint.
|
||||
|
||||
#### Returns
|
||||
|
||||
`bigint`
|
||||
|
||||
## Methods
|
||||
|
||||
### deletedRowIds()
|
||||
|
||||
```ts
|
||||
deletedRowIds(): TableDeltaReader
|
||||
```
|
||||
|
||||
Stream deleted row IDs. Each batch has one `_rowid: uint64` column.
|
||||
|
||||
#### Returns
|
||||
|
||||
[`TableDeltaReader`](../interfaces/TableDeltaReader.md)
|
||||
|
||||
***
|
||||
|
||||
### insertedRows()
|
||||
|
||||
```ts
|
||||
insertedRows(): TableDeltaReader
|
||||
```
|
||||
|
||||
Stream rows inserted in `(beginVersion, endVersion]`.
|
||||
|
||||
#### Returns
|
||||
|
||||
[`TableDeltaReader`](../interfaces/TableDeltaReader.md)
|
||||
|
||||
***
|
||||
|
||||
### listTransactions()
|
||||
|
||||
```ts
|
||||
listTransactions(): Promise<TableDeltaTransaction[]>
|
||||
```
|
||||
|
||||
List readable transactions committed in `(beginVersion, endVersion]`.
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`TableDeltaTransaction`](../interfaces/TableDeltaTransaction.md)[]>
|
||||
|
||||
***
|
||||
|
||||
### updatedRows()
|
||||
|
||||
```ts
|
||||
updatedRows(): TableDeltaReader
|
||||
```
|
||||
|
||||
Stream rows updated in `(beginVersion, endVersion]`.
|
||||
|
||||
#### Returns
|
||||
|
||||
[`TableDeltaReader`](../interfaces/TableDeltaReader.md)
|
||||
|
||||
***
|
||||
|
||||
### upsertedRows()
|
||||
|
||||
```ts
|
||||
upsertedRows(): TableDeltaReader
|
||||
```
|
||||
|
||||
Stream inserted and updated rows in `(beginVersion, endVersion]`.
|
||||
|
||||
#### Returns
|
||||
|
||||
[`TableDeltaReader`](../interfaces/TableDeltaReader.md)
|
||||
@@ -49,6 +49,7 @@
|
||||
- [Session](classes/Session.md)
|
||||
- [StaticHeaderProvider](classes/StaticHeaderProvider.md)
|
||||
- [Table](classes/Table.md)
|
||||
- [TableDelta](classes/TableDelta.md)
|
||||
- [TagContents](classes/TagContents.md)
|
||||
- [Tags](classes/Tags.md)
|
||||
- [TakeQuery](classes/TakeQuery.md)
|
||||
@@ -158,6 +159,8 @@
|
||||
- [SplitRandomOptions](interfaces/SplitRandomOptions.md)
|
||||
- [SplitSequentialOptions](interfaces/SplitSequentialOptions.md)
|
||||
- [SsTableStats](interfaces/SsTableStats.md)
|
||||
- [TableDeltaReader](interfaces/TableDeltaReader.md)
|
||||
- [TableDeltaTransaction](interfaces/TableDeltaTransaction.md)
|
||||
- [TableNamesOptions](interfaces/TableNamesOptions.md)
|
||||
- [TableShardStats](interfaces/TableShardStats.md)
|
||||
- [TableStatistics](interfaces/TableStatistics.md)
|
||||
@@ -189,6 +192,7 @@
|
||||
- [Data](type-aliases/Data.md)
|
||||
- [DataLike](type-aliases/DataLike.md)
|
||||
- [DataTypeLike](type-aliases/DataTypeLike.md)
|
||||
- [DeltaVersion](type-aliases/DeltaVersion.md)
|
||||
- [ExprLike](type-aliases/ExprLike.md)
|
||||
- [FieldLike](type-aliases/FieldLike.md)
|
||||
- [IntoSql](type-aliases/IntoSql.md)
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
||||
|
||||
***
|
||||
|
||||
[@lancedb/lancedb](../globals.md) / TableDeltaReader
|
||||
|
||||
# Interface: TableDeltaReader
|
||||
|
||||
A streaming table-delta reader.
|
||||
|
||||
`schema()` is available before consuming the stream, including when the
|
||||
range is empty. The stream yields Arrow record batches without
|
||||
materializing the full result.
|
||||
|
||||
A reader owns one native cursor. It is single-use:
|
||||
`[Symbol.asyncIterator]()` returns the same iterator, concurrent pulls are
|
||||
serialized, and `return()` releases the native stream on early drop.
|
||||
|
||||
## Extends
|
||||
|
||||
- `AsyncIterable`<`RecordBatch`>.`AsyncIterator`<`RecordBatch`>
|
||||
|
||||
## Methods
|
||||
|
||||
### \[asyncIterator\]()
|
||||
|
||||
```ts
|
||||
asyncIterator: AsyncIterator<RecordBatch<any>, any, undefined>
|
||||
```
|
||||
|
||||
#### Returns
|
||||
|
||||
`AsyncIterator`<`RecordBatch`<`any`>, `any`, `undefined`>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
`AsyncIterable.[asyncIterator]`
|
||||
|
||||
***
|
||||
|
||||
### next()
|
||||
|
||||
```ts
|
||||
next(...args): Promise<IteratorResult<RecordBatch<any>, any>>
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
* ...**args**: [] \| [`undefined`]
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`IteratorResult`<`RecordBatch`<`any`>, `any`>>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
`AsyncIterator.next`
|
||||
|
||||
***
|
||||
|
||||
### return()?
|
||||
|
||||
```ts
|
||||
optional return(value?): Promise<IteratorResult<RecordBatch<any>, any>>
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
* **value?**: `any`
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`IteratorResult`<`RecordBatch`<`any`>, `any`>>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
`AsyncIterator.return`
|
||||
|
||||
***
|
||||
|
||||
### schema()
|
||||
|
||||
```ts
|
||||
schema(): Promise<Schema<any>>
|
||||
```
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`Schema`<`any`>>
|
||||
|
||||
***
|
||||
|
||||
### throw()?
|
||||
|
||||
```ts
|
||||
optional throw(e?): Promise<IteratorResult<RecordBatch<any>, any>>
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
* **e?**: `any`
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`IteratorResult`<`RecordBatch`<`any`>, `any`>>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
`AsyncIterator.throw`
|
||||
@@ -0,0 +1,51 @@
|
||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
||||
|
||||
***
|
||||
|
||||
[@lancedb/lancedb](../globals.md) / TableDeltaTransaction
|
||||
|
||||
# Interface: TableDeltaTransaction
|
||||
|
||||
A committed transaction in a table delta range.
|
||||
|
||||
## Properties
|
||||
|
||||
### operation
|
||||
|
||||
```ts
|
||||
operation: string;
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
### readVersion
|
||||
|
||||
```ts
|
||||
readVersion: bigint;
|
||||
```
|
||||
|
||||
The version the transaction was based on. Exact u64 value.
|
||||
|
||||
***
|
||||
|
||||
### tag?
|
||||
|
||||
```ts
|
||||
optional tag: string;
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
### transactionProperties?
|
||||
|
||||
```ts
|
||||
optional transactionProperties: Record<string, string>;
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
### uuid
|
||||
|
||||
```ts
|
||||
uuid: string;
|
||||
```
|
||||
@@ -0,0 +1,17 @@
|
||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
||||
|
||||
***
|
||||
|
||||
[@lancedb/lancedb](../globals.md) / DeltaVersion
|
||||
|
||||
# Type Alias: DeltaVersion
|
||||
|
||||
```ts
|
||||
type DeltaVersion: number | bigint | string;
|
||||
```
|
||||
|
||||
One endpoint of a table delta: a positive version number/bigint or a tag on
|
||||
the table handle's current branch.
|
||||
|
||||
Use a `bigint` when the version may exceed `Number.MAX_SAFE_INTEGER`.
|
||||
Strings are always tags.
|
||||
Reference in New Issue
Block a user