@sixb/ducklake 0.1.8 → 0.1.9
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/README.md +59 -4
- package/dist/ducklake-storage.d.ts +1 -0
- package/dist/ducklake-storage.d.ts.map +1 -1
- package/dist/index.js +1817 -511
- package/dist/index.js.map +24 -14
- package/dist/internal/dataset-row-commit.d.ts +10 -0
- package/dist/internal/dataset-row-commit.d.ts.map +1 -1
- package/dist/internal/dataset-row-merge.d.ts.map +1 -1
- package/dist/internal/ducklake-dataset-catalog.d.ts +20 -3
- package/dist/internal/ducklake-dataset-catalog.d.ts.map +1 -1
- package/dist/internal/ducklake-dataset-table-ref.d.ts +13 -0
- package/dist/internal/ducklake-dataset-table-ref.d.ts.map +1 -1
- package/dist/internal/ducklake-maintenance.d.ts +21 -1
- package/dist/internal/ducklake-maintenance.d.ts.map +1 -1
- package/dist/internal/ducklake-snapshot-reader.d.ts +63 -16
- package/dist/internal/ducklake-snapshot-reader.d.ts.map +1 -1
- package/dist/internal/ducklake-sql-executor.d.ts +9 -1
- package/dist/internal/ducklake-sql-executor.d.ts.map +1 -1
- package/dist/internal/ducklake-version-transaction.d.ts +54 -0
- package/dist/internal/ducklake-version-transaction.d.ts.map +1 -0
- package/dist/internal/ducklake-write-coordinator.d.ts +30 -3
- package/dist/internal/ducklake-write-coordinator.d.ts.map +1 -1
- package/dist/internal/lineage-encoding.d.ts +8 -0
- package/dist/internal/lineage-encoding.d.ts.map +1 -0
- package/dist/internal/sql-lineage/analysis.d.ts +32 -0
- package/dist/internal/sql-lineage/analysis.d.ts.map +1 -0
- package/dist/internal/sql-lineage/expressions.d.ts +9 -0
- package/dist/internal/sql-lineage/expressions.d.ts.map +1 -0
- package/dist/internal/sql-lineage/plan-json.d.ts +34 -0
- package/dist/internal/sql-lineage/plan-json.d.ts.map +1 -0
- package/dist/internal/sql-lineage/plan-relation.d.ts +28 -0
- package/dist/internal/sql-lineage/plan-relation.d.ts.map +1 -0
- package/dist/internal/sql-lineage/plan-walker.d.ts +18 -0
- package/dist/internal/sql-lineage/plan-walker.d.ts.map +1 -0
- package/dist/internal/sql-lineage/rejection.d.ts +11 -0
- package/dist/internal/sql-lineage/rejection.d.ts.map +1 -0
- package/dist/internal/sql-lineage/statement-gate.d.ts +21 -0
- package/dist/internal/sql-lineage/statement-gate.d.ts.map +1 -0
- package/dist/internal/sql-lineage/table-functions.d.ts +6 -0
- package/dist/internal/sql-lineage/table-functions.d.ts.map +1 -0
- package/dist/internal/sql-transform-relations.d.ts +20 -5
- package/dist/internal/sql-transform-relations.d.ts.map +1 -1
- package/dist/internal/versions.d.ts +10 -1
- package/dist/internal/versions.d.ts.map +1 -1
- package/dist/types.d.ts +10 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/ducklake-storage.ts +9 -2
- package/src/internal/dataset-row-commit.ts +28 -2
- package/src/internal/dataset-row-merge.ts +4 -0
- package/src/internal/ducklake-dataset-catalog.ts +162 -49
- package/src/internal/ducklake-dataset-table-ref.ts +75 -17
- package/src/internal/ducklake-maintenance.ts +110 -48
- package/src/internal/ducklake-snapshot-reader.ts +352 -304
- package/src/internal/ducklake-sql-executor.ts +214 -14
- package/src/internal/ducklake-version-transaction.ts +224 -0
- package/src/internal/ducklake-write-coordinator.ts +226 -148
- package/src/internal/lineage-encoding.ts +136 -0
- package/src/internal/sql-lineage/analysis.ts +257 -0
- package/src/internal/sql-lineage/expressions.ts +208 -0
- package/src/internal/sql-lineage/plan-json.ts +130 -0
- package/src/internal/sql-lineage/plan-relation.ts +59 -0
- package/src/internal/sql-lineage/plan-walker.ts +727 -0
- package/src/internal/sql-lineage/rejection.ts +16 -0
- package/src/internal/sql-lineage/statement-gate.ts +164 -0
- package/src/internal/sql-lineage/table-functions.ts +11 -0
- package/src/internal/sql-transform-relations.ts +90 -40
- package/src/internal/versions.ts +37 -14
- package/src/types.ts +11 -1
package/README.md
CHANGED
|
@@ -86,9 +86,15 @@ Or run it directly against the provider:
|
|
|
86
86
|
const report = await lakeStorage.runMaintenance({
|
|
87
87
|
dryRun: true,
|
|
88
88
|
expireOlderThan: "7 days",
|
|
89
|
+
protect: [{ datasetId: "invoices", versionId: "ducklake:42" }],
|
|
89
90
|
})
|
|
90
91
|
```
|
|
91
92
|
|
|
93
|
+
Expiring a snapshot removes the version it holds. Two kinds of versions are kept whatever their
|
|
94
|
+
age, and the snapshots holding them are reported as `keptSnapshots`: each dataset's latest
|
|
95
|
+
version, so a dataset idle longer than the retention stays readable, and the versions passed as
|
|
96
|
+
`protect`. `sixb lake cleanup` protects the version each projection applied.
|
|
97
|
+
|
|
92
98
|
### Read and Write Concurrency
|
|
93
99
|
|
|
94
100
|
Large reads stream through dedicated connections in the same DuckDB engine, sharing its memory
|
|
@@ -193,12 +199,36 @@ Explicit `expectedLatestVersionId` guards are never relaxed.
|
|
|
193
199
|
See [source ordering](../../docs/datasets/source-ordering.md).
|
|
194
200
|
|
|
195
201
|
Local catalogs serialize commits within one process. PostgreSQL catalogs support concurrent
|
|
196
|
-
writer processes
|
|
197
|
-
|
|
202
|
+
writer processes. DuckLake commits a transaction on top of versions committed since it began
|
|
203
|
+
unless one of them altered the table or deleted rows it touches, so a write that missed a
|
|
204
|
+
concurrent version could keep that version's rows but record what it read before them. Such a
|
|
205
|
+
version claims its table, an idempotent comment update that makes any later concurrent write
|
|
206
|
+
conflict:
|
|
207
|
+
|
|
208
|
+
- a version whose lineage carries dependencies on other datasets, or is unknown, so no later
|
|
209
|
+
write records a lineage without them;
|
|
210
|
+
- a keyed append or merge, because DuckLake has no primary key and two writes of one new key
|
|
211
|
+
would both commit;
|
|
212
|
+
- a write into an empty dataset, because a snapshot that also read it empty would keep its rows;
|
|
213
|
+
- a version that changes no rows (new provenance), which also gives it a DuckLake snapshot.
|
|
214
|
+
|
|
215
|
+
Each claim bumps DuckLake's catalog-wide schema version, which every connection then reloads. On
|
|
216
|
+
PostgreSQL with two writers appending 100 rows each, claiming every commit cut throughput by a
|
|
217
|
+
quarter to a third in our measurements, writers to two different datasets included. Snapshots that
|
|
218
|
+
replace rows conflict through their deletes and do not claim, nor do unkeyed appends to a dataset
|
|
219
|
+
that holds only its own columns, such as a sync target: those commit concurrently.
|
|
220
|
+
|
|
221
|
+
A version that changes no rows, a schema change, a merge that only advances source ordering, and
|
|
222
|
+
an unkeyed append guarded on `expectedLatestVersionId` also fail on a concurrent commit to any
|
|
223
|
+
dataset of the catalog. The writer that loses reruns its whole commit from the retained staging
|
|
224
|
+
table: up to 16 attempts, the first rerun at once, later ones after a random wait in a window
|
|
225
|
+
that doubles from 20 ms up to 1 s (at most 9.3 s of waiting in all). A merge's
|
|
226
|
+
`commit({ signal })` also stops the wait, and a writer that runs out of attempts fails with
|
|
227
|
+
`LakeConcurrencyError`. Other provider/connection failures propagate without an automatic retry.
|
|
198
228
|
|
|
199
229
|
SQLite reads commit metadata before the write transaction, then verifies the native snapshot
|
|
200
|
-
has not changed
|
|
201
|
-
The catalog's existing journal mode is preserved.
|
|
230
|
+
has not changed; a race reruns the commit the same way, and data writes are applied once per
|
|
231
|
+
attempt. The catalog's existing journal mode is preserved.
|
|
202
232
|
|
|
203
233
|
Snapshot, append, and SQL-transform writes to keyed datasets also enforce unique keys so a later
|
|
204
234
|
merge never starts from an ambiguous baseline. Application authors normally use
|
|
@@ -284,6 +314,31 @@ new rows to the existing target. Omitting a source `versionId` resolves the late
|
|
|
284
314
|
committed version at execution time; providing a `versionId` pins that source for
|
|
285
315
|
repeatable transforms.
|
|
286
316
|
|
|
317
|
+
A source can pick the columns a transform may read with `columns`. The relation then exposes only
|
|
318
|
+
those columns, in that order, and referencing any other column fails:
|
|
319
|
+
|
|
320
|
+
```ts
|
|
321
|
+
sources: {
|
|
322
|
+
orders: { dataset: rawOrdersDataset, columns: ["customerId", "total"] },
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
The committed version records its lineage in `DatasetVersion.lineage`: which columns each output
|
|
327
|
+
column was computed from, and which ones decide the result's rows and their order, traced through
|
|
328
|
+
what the source versions read record themselves. An append also keeps the lineage of the rows it
|
|
329
|
+
keeps. `analyze(...)` returns the SQL's own lineage, by source name, without reading any data or
|
|
330
|
+
requiring a committed source version. The provider binds the SQL in an isolated DuckDB instance
|
|
331
|
+
against empty tables shaped like the sources. SQL it cannot analyze exactly, such as `PIVOT`, still
|
|
332
|
+
executes. When its parse tree reads nothing but the sources and calls only functions by names DuckDB
|
|
333
|
+
defines, every column the sources expose is recorded as deciding its rows, so each output column
|
|
334
|
+
carries the markings of all of them. A `PIVOT` needs an explicit `IN` list for that.
|
|
335
|
+
|
|
336
|
+
Lineage only covers the sources. SQL that may read anything else, such as a lake table by its name,
|
|
337
|
+
a table function that reads files or other tables (`read_parquet`, `read_csv`, `query_table`), or a
|
|
338
|
+
macro the lake's setup defines, records no lineage for a pipeline version, and an unknown lineage
|
|
339
|
+
for any other one. Either way, the version is classified with every marking. Read data only through
|
|
340
|
+
the sources.
|
|
341
|
+
|
|
287
342
|
DuckDB promotes `sum(BIGINT)` results to `HUGEINT`. When the matching target column is a Sixb
|
|
288
343
|
`int64`, the executor applies a checked conversion back to `BIGINT` before comparing or writing
|
|
289
344
|
rows. Values outside the signed 64-bit range fail the transform instead of being truncated.
|
|
@@ -14,6 +14,7 @@ export declare class DuckLakeStorage implements LakeStorageWithSql<"duckdb"> {
|
|
|
14
14
|
readonly id: "ducklake";
|
|
15
15
|
readonly version: "1.0";
|
|
16
16
|
};
|
|
17
|
+
readonly recordsLineage = true;
|
|
17
18
|
readonly sql: DuckLakeSqlExecutor;
|
|
18
19
|
private readonly connections;
|
|
19
20
|
private readonly datasets;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ducklake-storage.d.ts","sourceRoot":"","sources":["../src/ducklake-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACnF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