@malloy-publisher/server 0.17.3 → 0.18.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 (32) hide show
  1. package/dist/admin-api-doc.yaml +757 -22
  2. package/dist/app/api-doc.yaml +160 -28
  3. package/dist/app/assets/{EnvironmentPage-Cpetyfj1.js → EnvironmentPage-CsFUI8IX.js} +1 -1
  4. package/dist/app/assets/{HomePage-RlrpQRV8.js → HomePage-B_FVtnN-.js} +1 -1
  5. package/dist/app/assets/{MainPage-C1559_mQ.js → MainPage-wFF9nPEr.js} +1 -1
  6. package/dist/app/assets/{ModelPage-D8T03Bd7.js → ModelPage-CxenqDcz.js} +2 -2
  7. package/dist/app/assets/PackagePage-dcF6vrvw.js +1 -0
  8. package/dist/app/assets/PackageSplatRoute-CASBZk0k.js +2 -0
  9. package/dist/app/assets/{RenderedResult-Cm0Wwtek.es-CfBPkvGU.js → RenderedResult--fYcsY1h.es-DzOt5Lwv.js} +3 -3
  10. package/dist/app/assets/{RouteError-DRuMstfb.js → RouteError-CUIolYwb.js} +1 -1
  11. package/dist/app/assets/{ThemeEditorPage-ss_tmVWo.js → ThemeEditorPage-DgU2YYq6.js} +1 -1
  12. package/dist/app/assets/{ToggleButtonGroup-DA9EfQQB.js → ToggleButtonGroup-Dmr-hVlD.js} +1 -1
  13. package/dist/app/assets/{documentRoutes-_ma0jaCp.js → documentRoutes-Drv-WDwO.js} +1 -1
  14. package/dist/app/assets/{editPageMounted-DxNTqmFg.js → editPageMounted-C5yJiIVi.js} +2 -2
  15. package/dist/app/assets/{index-w1w5RvZI.js → index-BIoSdsU9.js} +1 -1
  16. package/dist/app/assets/{index-BL_7q21Q.js → index-BSyL0zds.js} +97 -97
  17. package/dist/app/assets/{index-BZA1HAyp.js → index-Dtw4eTxH.js} +1 -1
  18. package/dist/app/assets/{index-DrkXqbpl.js → index-DxF3kMLJ.js} +1 -1
  19. package/dist/app/assets/{index.es-XV_AUlWO.js → index.es-CX9m4CBD.js} +10 -10
  20. package/dist/app/assets/usePackageLinkNavigate-qNjcXPcY.js +1 -0
  21. package/dist/app/assets/{usePackageRoute-ev5b1KRn.js → usePackageRoute-wJGaZEiY.js} +1 -1
  22. package/dist/app/index.html +1 -1
  23. package/dist/instrumentation.mjs +31 -17
  24. package/dist/package_load_worker.mjs +528 -377
  25. package/dist/runtime/publisher.colorScheme.spec.ts +167 -0
  26. package/dist/runtime/publisher.js +173 -3
  27. package/dist/runtime/publisher_embed.spec.ts +108 -0
  28. package/dist/server.mjs +10361 -4009
  29. package/package.json +2 -1
  30. package/dist/app/assets/PackagePage-BIl1r9eP.js +0 -1
  31. package/dist/app/assets/PackageSplatRoute-DJlJXk6p.js +0 -2
  32. package/dist/app/assets/usePackageLinkNavigate-BKkPNdJ4.js +0 -1
@@ -7,7 +7,7 @@ info:
7
7
  description: |
8
8
  The operator's surface. It holds two kinds of thing, neither of which a user
9
9
  of a running server should call: the DuckLake catalogs in one Postgres
10
- database, as resources (a catalog, the tables in its schemas, and its
10
+ database, as resources (a catalog, its schemas, the tables in them, and its
11
11
  snapshots), and controls of this server's own process that only an operator
12
12
  or a local developer uses (watch mode).
13
13
 
@@ -47,6 +47,8 @@ servers:
47
47
  tags:
48
48
  - name: catalogs
49
49
  description: DuckLake catalogs and their settings
50
+ - name: schemas
51
+ description: The schemas of a catalog
50
52
  - name: tables
51
53
  description: The tables in a catalog's schemas
52
54
  - name: snapshots
@@ -166,6 +168,115 @@ paths:
166
168
  "500":
167
169
  $ref: "#/components/responses/InternalServerError"
168
170
 
171
+ /catalogs/{catalogName}/schemas/{schemaName}:
172
+ parameters:
173
+ - $ref: "#/components/parameters/catalogName"
174
+ - $ref: "#/components/parameters/schemaName"
175
+ put:
176
+ tags: [schemas]
177
+ operationId: put-schema
178
+ summary: Create a schema
179
+ description: |
180
+ Creates the schema. The name is lowercase
181
+ (`[a-z_][a-z0-9_]*`) and not reserved (`main`, `memory`,
182
+ `information_schema`, `pg_catalog`, `temp`, `system`, or a name starting
183
+ `__ducklake_metadata_`: `400 SCHEMA_RESERVED`). The request has
184
+ no body; a body is `400 INVALID_REQUEST`. `201` when the schema is new,
185
+ `200` when it already existed; with `If-None-Match: *` an existing
186
+ schema, including one a concurrent request created first, is refused
187
+ with `412 SCHEMA_EXISTS`.
188
+ parameters:
189
+ - name: If-None-Match
190
+ in: header
191
+ required: false
192
+ description: "`*` to create only, refusing a schema that exists."
193
+ schema:
194
+ type: string
195
+ enum: ["*"]
196
+ responses:
197
+ "200":
198
+ description: The schema already existed
199
+ content:
200
+ application/json:
201
+ schema:
202
+ $ref: "#/components/schemas/Schema"
203
+ "201":
204
+ description: The schema, created
205
+ content:
206
+ application/json:
207
+ schema:
208
+ $ref: "#/components/schemas/Schema"
209
+ "400":
210
+ $ref: "#/components/responses/BadRequest"
211
+ "404":
212
+ $ref: "#/components/responses/NotFound"
213
+ "412":
214
+ description: "`If-None-Match: *` and the schema exists (`SCHEMA_EXISTS`)"
215
+ content:
216
+ application/json:
217
+ schema:
218
+ $ref: "#/components/schemas/Error"
219
+ "503":
220
+ $ref: "#/components/responses/NotConfigured"
221
+ "500":
222
+ $ref: "#/components/responses/InternalServerError"
223
+ delete:
224
+ tags: [schemas]
225
+ operationId: delete-schema
226
+ summary: Drop a schema and its tables
227
+ description: |
228
+ Drops the schema and every table in it. A schema that does not exist
229
+ answers 204 as well, so a retried drop is free. A reserved name is `400
230
+ SCHEMA_RESERVED`. The schema a storage destination builds into is `409
231
+ SCHEMA_IS_DESTINATION`, since dropping it would remove every table the
232
+ build wrote (a `DELETE` of one of its tables is allowed). Data files
233
+ stay until a snapshot delete reclaims them, as for a dropped table.
234
+ responses:
235
+ "204":
236
+ description: The schema is dropped, or did not exist
237
+ "400":
238
+ $ref: "#/components/responses/BadRequest"
239
+ "404":
240
+ $ref: "#/components/responses/NotFound"
241
+ "409":
242
+ description: The schema is the one a storage destination of an environment on this server builds into in this catalog (`SCHEMA_IS_DESTINATION`)
243
+ content:
244
+ application/json:
245
+ schema:
246
+ $ref: "#/components/schemas/Error"
247
+ "503":
248
+ $ref: "#/components/responses/NotConfigured"
249
+ "500":
250
+ $ref: "#/components/responses/InternalServerError"
251
+
252
+ /catalogs/{catalogName}/tables:
253
+ parameters:
254
+ - $ref: "#/components/parameters/catalogName"
255
+ get:
256
+ tags: [tables]
257
+ operationId: list-catalog-tables
258
+ summary: List the tables in every schema of a catalog
259
+ description: |
260
+ Every table of the catalog's schemas, in schema then name order, each
261
+ with the bytes its live files hold. The engine's own schemas are left out.
262
+ responses:
263
+ "200":
264
+ description: The tables
265
+ content:
266
+ application/json:
267
+ schema:
268
+ type: array
269
+ items:
270
+ $ref: "#/components/schemas/CatalogTableSummary"
271
+ "400":
272
+ $ref: "#/components/responses/BadRequest"
273
+ "404":
274
+ $ref: "#/components/responses/NotFound"
275
+ "503":
276
+ $ref: "#/components/responses/NotConfigured"
277
+ "500":
278
+ $ref: "#/components/responses/InternalServerError"
279
+
169
280
  /catalogs/{catalogName}/schemas/{schemaName}/tables:
170
281
  parameters:
171
282
  - $ref: "#/components/parameters/catalogName"
@@ -223,6 +334,9 @@ paths:
223
334
  operationId: put-table
224
335
  summary: Create or replace a table from a source
225
336
  description: |
337
+ The schema may not be the one a storage destination builds into
338
+ (`409 SCHEMA_IS_DESTINATION`, below); a copy's source may be in it.
339
+
226
340
  Writes the table from `source`: one CSV, Parquet, Excel or JSON object
227
341
  under the catalog's data path, the only location the session can read;
228
342
  or a table of a catalog in the same catalog database (a migration's
@@ -239,9 +353,19 @@ paths:
239
353
  in place and never left as rows in the catalog database, so an
240
354
  encrypted catalog stays encrypted. One DuckLake transaction:
241
355
  a reader sees the old table or the new one. A file the reader refuses
242
- (not the format it claims, a value it cannot convert) is `400
243
- INVALID_REQUEST` carrying the reader's own message, with the object
244
- named by its file name. `201` when the table is new,
356
+ (not the format it claims, a value it cannot convert, an Excel `sheet`
357
+ the workbook lacks or a sheet with no rows) or an object that does not
358
+ exist is `422 OBJECT_UNREADABLE` carrying the reader's own
359
+ message, with the object named by its file name: the request is
360
+ well-formed but the named data cannot be applied, so correct the
361
+ object, don't retry. A table too large for the write session's memory
362
+ or its spill cap is `422 LOAD_TOO_LARGE`: a retry fails the same way, so
363
+ raise `PUBLISHER_ADMIN_MEMORY_LIMIT` and `PUBLISHER_DUCKDB_MEMORY_LIMIT`
364
+ (the session uses the lower) or `PUBLISHER_ADMIN_MAX_TEMP_DIRECTORY_SIZE`,
365
+ or write less. A `500` is a
366
+ failure a retry may cure (storage unavailable or throttled, a refused
367
+ credential, a full spill disk), and a retry is safe: it writes the whole
368
+ table from the same object again. `201` when the table is new,
245
369
  `200` when it replaced one; with `If-None-Match: *` an existing table is
246
370
  refused with `412 TABLE_EXISTS`. Synchronous: it answers when the table
247
371
  is written.
@@ -277,7 +401,8 @@ paths:
277
401
  "404":
278
402
  $ref: "#/components/responses/NotFound"
279
403
  "409":
280
- description: A copy's source catalog is owned by a role the configured role cannot act as (`CATALOG_OWNER_UNSUPPORTED`)
404
+ description: |
405
+ A copy's source catalog is owned by a role the configured role cannot act as (`CATALOG_OWNER_UNSUPPORTED`), or the schema is the one a storage destination of an environment on this server builds into in this catalog (`SCHEMA_IS_DESTINATION`)
281
406
  content:
282
407
  application/json:
283
408
  schema:
@@ -288,8 +413,18 @@ paths:
288
413
  application/json:
289
414
  schema:
290
415
  $ref: "#/components/schemas/Error"
416
+ "422":
417
+ description: The source object is missing, is not the format it claims, or holds a value its column cannot (`OBJECT_UNREADABLE`), or the write outgrew the session's memory or spill cap (`LOAD_TOO_LARGE`); nothing was written, and a retry fails the same way
418
+ content:
419
+ application/json:
420
+ schema:
421
+ $ref: "#/components/schemas/Error"
291
422
  "503":
292
- $ref: "#/components/responses/NotConfigured"
423
+ description: No catalog database is configured (`CATALOG_DATABASE_NOT_CONFIGURED`), or this server is already running a load or copy (`LOAD_BUSY`); the write was refused, not queued, so retry
424
+ content:
425
+ application/json:
426
+ schema:
427
+ $ref: "#/components/schemas/Error"
293
428
  "500":
294
429
  $ref: "#/components/responses/InternalServerError"
295
430
  delete:
@@ -297,7 +432,8 @@ paths:
297
432
  operationId: delete-table
298
433
  summary: Drop a table
299
434
  description: |
300
- Drops the table. A table that does not exist answers 204 as well, so a
435
+ Drops the table, in a schema a storage destination builds into as in
436
+ any other, which is how a build's table is dropped. A table that does not exist answers 204 as well, so a
301
437
  retried drop is free. Its data files stay until a snapshot delete
302
438
  reclaims them, which is also the window in which the table can still be
303
439
  read at an earlier snapshot.
@@ -313,6 +449,277 @@ paths:
313
449
  "500":
314
450
  $ref: "#/components/responses/InternalServerError"
315
451
 
452
+ /catalogs/{catalogName}/schemas/{schemaName}/tables/{tableName}/loads:
453
+ parameters:
454
+ - $ref: "#/components/parameters/catalogName"
455
+ - $ref: "#/components/parameters/schemaName"
456
+ - $ref: "#/components/parameters/tableName"
457
+ post:
458
+ tags: [tables]
459
+ operationId: load-table
460
+ summary: Apply Parquet objects to a table by key
461
+ description: |
462
+ The schema may not be `main` (`400 SCHEMA_RESERVED`), nor the one a
463
+ storage destination builds into (`409 SCHEMA_IS_DESTINATION`, below).
464
+
465
+ Applies Parquet objects under the catalog's data path to the table,
466
+ creating it when it does not exist. `merge` upserts the objects' rows by
467
+ `key`; `replace` makes the table equal to the objects, by `key` when one
468
+ is given and as a whole table when not (a replace is the whole stream in
469
+ one call). A replace that would delete more rows than `maxDeletedRows`
470
+ is refused and writes nothing. A keyless replace compares the table's
471
+ rows with the objects' as a multiset, so it reads every column of both:
472
+ a full-width aggregate over the stored and the staged rows, on every
473
+ keyless replace, split into passes (by a hash of the whole row) that each
474
+ fit in half the session's memory; an empty extract or an empty table
475
+ needs no compare. A stored row with no identical row in the objects
476
+ counts in `rowsDeleted`, and an object row with no identical stored row
477
+ in `rowsInserted`; an edited row is one of each, and `maxDeletedRows`
478
+ guards `rowsDeleted`.
479
+
480
+ A load that changes no row and adds or widens no column, keyed or
481
+ keyless, writes nothing and takes no snapshot, so a load repeated after
482
+ it committed, with no other load of the same table committed in
483
+ between, finds nothing to do. It reports
484
+ the same `rowCount` and `cursorMax` as the first call, with every row
485
+ counted in `rowsUnchanged` and none inserted, replaced or deleted, and
486
+ answers `200` (below). A retry is safe because it finds nothing to
487
+ change. When some row does change, a keyed load rewrites only the rows
488
+ it changes, and a keyless replace rewrites the whole table, so there
489
+ `rowsUnchanged` counts the rows matched, not rows left in place.
490
+ Of two rows of one key, the later one wins: the later object in
491
+ `objects`, then the later row of an object. A key stored more than once
492
+ is rewritten once.
493
+
494
+ The objects are checked against the table's columns before anything is
495
+ written. A column the table lacks is added, even when no row changes.
496
+ A column it has keeps its type when the objects type it the same or
497
+ narrower, losslessly, and is widened to the objects' type when that is
498
+ a lossless widening of the table's: a wider integer, a decimal with no
499
+ fewer integer or fraction digits, an integer into a decimal or DOUBLE
500
+ that holds all its digits, FLOAT into DOUBLE, a longer varying text.
501
+ The widening is recorded in the same commit as the rows and rewrites no
502
+ file already written; a table's type never narrows. Objects that type one column differently
503
+ (BIGINT in one, DOUBLE in another) must each widen losslessly into the
504
+ type they are read together as. Every `key` column must be a column of
505
+ both; no key may be NULL; and `cursor`, when given, must be an integer,
506
+ DATE or TIMESTAMP column. A column of the table the objects lack is
507
+ written NULL for every row the load writes, whatever DEFAULT the table
508
+ gives it (a merge writes NULL for every key it touches), and a column
509
+ the table holds NOT NULL that the objects lack, or hold a NULL in, is
510
+ refused. A column typed NULL in every object (as a Parquet writer
511
+ writes an all-NULL column) is ignored, and objects that leave no column
512
+ are refused; as the `cursor` it reports `cursorMax: null`, and as a
513
+ `key` it is a NULL key. A column of the table named `__publisher_…` is
514
+ refused. Refusals are `422 LOAD_COLUMN_MISMATCH`, whose `detail` names
515
+ the column and why.
516
+
517
+ One table loads at a time, across every replica of this server (a
518
+ Postgres advisory lock in the catalog database), and one load runs at a
519
+ time on this server (the same slot a table PUT's load or copy takes). A
520
+ load that finds either busy is refused with `503 LOAD_BUSY` and nothing
521
+ written, never queued: retry it. A load whose lock is lost before it
522
+ commits rolls back and answers the same. The lock is checked just
523
+ before the commit, which narrows the window in which a lost lock goes
524
+ unnoticed but does not close it. The load reads the table inside
525
+ the transaction that writes it, so one that races a table PUT or DELETE
526
+ of the same table, or a schema drop, on another replica is refused by
527
+ DuckLake at its commit and answers `409 LOAD_CONFLICT`: nothing was
528
+ written, and a retry is safe. A schema dropped before that transaction
529
+ begins answers `404 SCHEMA_NOT_FOUND`.
530
+
531
+ A load runs in a session bounded to `PUBLISHER_ADMIN_MEMORY_LIMIT` of
532
+ memory (default 1.5 GB) or the operator's lower
533
+ `PUBLISHER_DUCKDB_MEMORY_LIMIT`, and `PUBLISHER_ADMIN_MAX_TEMP_DIRECTORY_SIZE`
534
+ of spill (default 6 GiB). A keyed load stays within the spill limit by
535
+ comparing columns in passes. A keyless replace compares in passes too,
536
+ each sized to half the session's memory, but every pass rereads both
537
+ sides, so it costs far more than a keyed load as the table grows: give a
538
+ large stream a `key`. A load that outgrows either limit anyway answers
539
+ `422 LOAD_TOO_LARGE` and writes nothing: a retry fails the same way, so
540
+ give it a `key`, split its objects across loads, or raise
541
+ `PUBLISHER_ADMIN_MEMORY_LIMIT` and `PUBLISHER_DUCKDB_MEMORY_LIMIT` (the
542
+ session uses the lower) or `PUBLISHER_ADMIN_MAX_TEMP_DIRECTORY_SIZE`. A full spill disk is a
543
+ `500`. A `500` before the commit writes nothing; one from the flush
544
+ after it may follow a committed load. Either way a retry after any
545
+ `500` is safe.
546
+
547
+ Synchronous: it answers once the rows are committed, with the counts of
548
+ what changed. **A load that committed is a resource**: it answers `201`
549
+ with its `id`, the `snapshotId` and `committedAt` of the snapshot it
550
+ committed (which carries the load's record, atomically with the rows),
551
+ and a `Location` of `loads/{id}`, which `GET` reads for as long as that
552
+ snapshot lasts. That includes a load that only added or widened a column.
553
+ A load that changed nothing committed nothing: it answers `200` with the
554
+ counts and `mode` alone, no `id` and no `Location`, and a `GET` finds
555
+ nothing of it.
556
+
557
+ **`Idempotency-Key`** makes the retry of a load that committed safe even
558
+ after another load of the table committed in between. A load that
559
+ repeats a key an earlier committed load of this table was sent under,
560
+ with the same body (`key` and `objects` in the order sent: the key's
561
+ order sets the leading columns of a table the load creates), writes
562
+ nothing and answers that load's `201`, `Location` and `Load` again
563
+ (after flushing any rows its table holds inlined in the catalog
564
+ database, so a retry still heals a load that failed after its commit).
565
+ The same key with a different body is `409 IDEMPOTENCY_KEY_REUSED`. A key
566
+ belongs to its table, and does not outlive a table DELETE or a PUT that
567
+ replaces the table. The server keeps a SHA-256 of the key, never the
568
+ key.
569
+
570
+ The key replays a load that committed, for as long as its snapshot is
571
+ kept. A load that changed nothing stores no record, and a key whose
572
+ snapshot a snapshot expiry removed has none, so either runs again: a
573
+ retry of such a load, sent after another load committed, can revert it.
574
+ A table with more than one writer therefore needs its loads serialized
575
+ by the caller. The key deviates from `Idempotency-Key` in
576
+ `api-doc.v1.yaml` in two further ways: a record lasts as long as its
577
+ snapshot, which may be shorter or longer than 24 hours (`DELETE
578
+ …/snapshots?olderThan` expires snapshots, and the key with them, as does
579
+ a storage destination's cleanup on the caller's `snapshotsOlderThan`);
580
+ and a duplicate that arrives while the first is running is refused `503
581
+ LOAD_BUSY`, not made to wait, and its retry replays.
582
+ parameters:
583
+ - $ref: "#/components/parameters/idempotencyKey"
584
+ requestBody:
585
+ required: true
586
+ content:
587
+ application/json:
588
+ schema:
589
+ $ref: "#/components/schemas/LoadRequest"
590
+ responses:
591
+ "201":
592
+ description: The load committed (or is the replay of one that did), with its id, snapshot and counts
593
+ headers:
594
+ Location:
595
+ description: The load, as a reference relative to this request's URL, `loads/{id}`, or `{id}` when the request's path ends in a slash
596
+ schema:
597
+ type: string
598
+ content:
599
+ application/json:
600
+ schema:
601
+ $ref: "#/components/schemas/Load"
602
+ "200":
603
+ description: The load changed nothing, so committed nothing; the counts, without an `id`
604
+ content:
605
+ application/json:
606
+ schema:
607
+ $ref: "#/components/schemas/LoadNoOp"
608
+ "400":
609
+ $ref: "#/components/responses/BadRequest"
610
+ "404":
611
+ $ref: "#/components/responses/NotFound"
612
+ "409":
613
+ description: |
614
+ DuckLake refused the commit because another request changed the table (replaced, dropped or created it) while the load ran (`LOAD_CONFLICT`); nothing was written, retry. Or the `Idempotency-Key` was used for a different request to this table (`IDEMPOTENCY_KEY_REUSED`). Or the schema is the one a storage destination of an environment on this server builds into in this catalog (`SCHEMA_IS_DESTINATION`)
615
+ content:
616
+ application/json:
617
+ schema:
618
+ $ref: "#/components/schemas/Error"
619
+ "422":
620
+ description: |
621
+ The load was refused, and nothing was written: the objects' columns do not
622
+ match the table's (`LOAD_COLUMN_MISMATCH`, with `detail`), a replace would delete more
623
+ rows than allowed (`LOAD_DELETE_LIMIT_EXCEEDED`, with `detail`), an object could
624
+ not be read (`OBJECT_UNREADABLE`, naming the object by its index, not its URI), or the
625
+ load outgrew the session's memory or spill cap (`LOAD_TOO_LARGE`)
626
+ content:
627
+ application/json:
628
+ schema:
629
+ $ref: "#/components/schemas/Error"
630
+ "503":
631
+ description: No catalog database is configured (`CATALOG_DATABASE_NOT_CONFIGURED`), or another load of this table or on this server is running (`LOAD_BUSY`); the load was refused, not queued, so retry
632
+ content:
633
+ application/json:
634
+ schema:
635
+ $ref: "#/components/schemas/Error"
636
+ "500":
637
+ $ref: "#/components/responses/InternalServerError"
638
+
639
+ get:
640
+ tags: [tables]
641
+ operationId: list-loads
642
+ summary: List a table's loads
643
+ description: |
644
+ The loads of the table that committed, newest first: each is the record
645
+ its snapshot carries, so a load is listed for as long as its snapshot is
646
+ kept, and one a snapshot expiry removed is gone. A load that changed
647
+ nothing is not listed. A table dropped and created again under the same
648
+ name shares one history.
649
+
650
+ This is the admin API's first list in the v1 grammar: `{items,
651
+ nextCursor}`, paged with `limit` and `after`, in a stable order. `nextCursor`
652
+ is absent on the last page. The error envelope is still this API's.
653
+ Only a missing catalog is a `404`: a table with no recorded loads, or
654
+ none yet, answers an empty list.
655
+ parameters:
656
+ - $ref: "#/components/parameters/limit"
657
+ - name: after
658
+ in: query
659
+ required: false
660
+ description: The `nextCursor` of the page before, given once; opaque
661
+ schema:
662
+ type: string
663
+ responses:
664
+ "200":
665
+ description: A page of the table's loads
666
+ content:
667
+ application/json:
668
+ schema:
669
+ $ref: "#/components/schemas/LoadList"
670
+ "400":
671
+ $ref: "#/components/responses/BadRequest"
672
+ "404":
673
+ description: No such catalog (`CATALOG_NOT_FOUND`). A missing schema or table is not a 404; it has no loads, so the list is empty
674
+ content:
675
+ application/json:
676
+ schema:
677
+ $ref: "#/components/schemas/Error"
678
+ "503":
679
+ $ref: "#/components/responses/NotConfigured"
680
+ "500":
681
+ $ref: "#/components/responses/InternalServerError"
682
+
683
+ /catalogs/{catalogName}/schemas/{schemaName}/tables/{tableName}/loads/{loadId}:
684
+ parameters:
685
+ - $ref: "#/components/parameters/catalogName"
686
+ - $ref: "#/components/parameters/schemaName"
687
+ - $ref: "#/components/parameters/tableName"
688
+ - name: loadId
689
+ in: path
690
+ required: true
691
+ description: The `id` a load answered
692
+ schema:
693
+ type: string
694
+ get:
695
+ tags: [tables]
696
+ operationId: get-load
697
+ summary: Read a load
698
+ description: |
699
+ A load that committed, as its create answered it, with the `author` and
700
+ `commitMessage` of its snapshot. It answers `404 LOAD_NOT_FOUND` when no
701
+ load of this table has that id, including a load whose snapshot has
702
+ been expired and a schema or table that does not exist.
703
+ responses:
704
+ "200":
705
+ description: The load
706
+ content:
707
+ application/json:
708
+ schema:
709
+ $ref: "#/components/schemas/LoadRead"
710
+ "400":
711
+ $ref: "#/components/responses/BadRequest"
712
+ "404":
713
+ description: No such catalog (`CATALOG_NOT_FOUND`), or no load of this table has that id (`LOAD_NOT_FOUND`)
714
+ content:
715
+ application/json:
716
+ schema:
717
+ $ref: "#/components/schemas/Error"
718
+ "503":
719
+ $ref: "#/components/responses/NotConfigured"
720
+ "500":
721
+ $ref: "#/components/responses/InternalServerError"
722
+
316
723
  /catalogs/{catalogName}/snapshots:
317
724
  parameters:
318
725
  - $ref: "#/components/parameters/catalogName"
@@ -320,17 +727,9 @@ paths:
320
727
  tags: [snapshots]
321
728
  operationId: list-snapshots
322
729
  summary: List a catalog's snapshots
323
- description: The newest first, each with its time and what it changed.
730
+ description: The newest first, each with its time, what it changed, and its author and commit message when it has them.
324
731
  parameters:
325
- - name: limit
326
- in: query
327
- required: false
328
- description: How many, from 1 to 1000.
329
- schema:
330
- type: integer
331
- minimum: 1
332
- maximum: 1000
333
- default: 100
732
+ - $ref: "#/components/parameters/limit"
334
733
  responses:
335
734
  "200":
336
735
  description: The snapshots
@@ -471,6 +870,34 @@ components:
471
870
  description: A table in the schema.
472
871
  schema:
473
872
  $ref: "#/components/schemas/Identifier"
873
+ limit:
874
+ name: limit
875
+ in: query
876
+ required: false
877
+ description: How many, from 1 to 1000.
878
+ schema:
879
+ type: integer
880
+ minimum: 1
881
+ maximum: 1000
882
+ default: 100
883
+ idempotencyKey:
884
+ name: Idempotency-Key
885
+ in: header
886
+ required: false
887
+ description: |
888
+ Makes the retry of a load that committed safe: a load of this table
889
+ that repeats a key an earlier committed load was sent under, with the
890
+ same body, answers that load again and writes nothing; the same key with
891
+ another body is `409 IDEMPOTENCY_KEY_REUSED`. A load that changed
892
+ nothing, or whose snapshot has expired, has no record, so it runs again.
893
+ Use a fresh UUID per logical load. Unlike `Idempotency-Key` in the v1
894
+ API, a record lasts as long as its snapshot, which may be shorter or
895
+ longer than 24 hours, and a duplicate that arrives while the first runs
896
+ is `503 LOAD_BUSY` (not made to wait).
897
+ schema:
898
+ type: string
899
+ minLength: 1
900
+ maxLength: 255
474
901
 
475
902
  responses:
476
903
  BadRequest:
@@ -480,7 +907,7 @@ components:
480
907
  schema:
481
908
  $ref: "#/components/schemas/Error"
482
909
  NotFound:
483
- description: No such catalog (`CATALOG_NOT_FOUND`), schema (`SCHEMA_NOT_FOUND`) or table (`TABLE_NOT_FOUND`), or no such source for a table write (`SOURCE_NOT_FOUND`)
910
+ description: No such catalog (`CATALOG_NOT_FOUND`), schema (`SCHEMA_NOT_FOUND`) or table (`TABLE_NOT_FOUND`), no such source for a table write (`SOURCE_NOT_FOUND`), or no such load (`LOAD_NOT_FOUND`)
484
911
  content:
485
912
  application/json:
486
913
  schema:
@@ -567,8 +994,9 @@ components:
567
994
  schemas:
568
995
  type: array
569
996
  items:
570
- $ref: "#/components/schemas/Identifier"
571
- description: Schemas to create beside `main`
997
+ type: string
998
+ pattern: "^[a-z_][a-z0-9_]*$"
999
+ description: Schemas to create beside `main`, named as for a schema PUT (a reserved name is `400 SCHEMA_RESERVED`)
572
1000
 
573
1001
  CatalogUpdate:
574
1002
  type: object
@@ -580,6 +1008,22 @@ components:
580
1008
  type: string
581
1009
  description: An interval like `1 day` or `12 hours`
582
1010
 
1011
+ Schema:
1012
+ type: object
1013
+ required: [name]
1014
+ properties:
1015
+ name:
1016
+ type: string
1017
+
1018
+ CatalogTableSummary:
1019
+ allOf:
1020
+ - type: object
1021
+ required: [schema]
1022
+ properties:
1023
+ schema:
1024
+ type: string
1025
+ - $ref: "#/components/schemas/TableSummary"
1026
+
583
1027
  TableSummary:
584
1028
  type: object
585
1029
  required: [name, sizeBytes]
@@ -684,6 +1128,166 @@ components:
684
1128
  $ref: "#/components/schemas/Identifier"
685
1129
  additionalProperties: false
686
1130
 
1131
+ LoadRequest:
1132
+ type: object
1133
+ required: [mode, objects]
1134
+ description: |
1135
+ A merge needs `key` and refuses `maxDeletedRows`; a replace needs
1136
+ `maxDeletedRows` and is keyless when `key` is omitted.
1137
+ properties:
1138
+ commitMessage:
1139
+ type: string
1140
+ minLength: 1
1141
+ maxLength: 1024
1142
+ pattern: '^[^\u0000]*$'
1143
+ description: |
1144
+ The message of the snapshot the load commits, listed by
1145
+ `GET /snapshots` beside the author `publisher-admin`. `load
1146
+ <schema>.<table>` when absent. A load that changes nothing writes no
1147
+ snapshot, so records nothing. A message holding Malloy's statement
1148
+ separator (`-- hack: split on this`) is refused.
1149
+ mode:
1150
+ type: string
1151
+ enum: [merge, replace]
1152
+ description: |
1153
+ `merge` upserts by `key`. `replace` makes the table equal to this
1154
+ call's rows, by `key` when given, otherwise as a whole table.
1155
+ key:
1156
+ type: array
1157
+ minItems: 1
1158
+ maxItems: 16
1159
+ uniqueItems: true
1160
+ items:
1161
+ type: string
1162
+ pattern: "^[a-z_][a-z0-9_]*$"
1163
+ description: The columns that identify a row; they are never NULL
1164
+ objects:
1165
+ type: array
1166
+ minItems: 1
1167
+ maxItems: 1000
1168
+ uniqueItems: true
1169
+ items:
1170
+ type: string
1171
+ description: |
1172
+ Parquet objects under the catalog's data path. Their order decides
1173
+ which of two rows of one key is later: the later object's.
1174
+ cursor:
1175
+ type: string
1176
+ pattern: "^[a-z_][a-z0-9_]*$"
1177
+ description: An integer, DATE or TIMESTAMP column whose greatest value among the rows loaded is reported
1178
+ maxDeletedRows:
1179
+ type: integer
1180
+ minimum: 0
1181
+ description: |
1182
+ The most stored rows a replace may delete; more is refused with
1183
+ `LOAD_DELETE_LIMIT_EXCEEDED`. For a keyless replace these are the
1184
+ stored rows with no identical row in the objects, so an edited row
1185
+ counts as one deleted row
1186
+ additionalProperties: false
1187
+
1188
+ LoadNoOp:
1189
+ type: object
1190
+ required:
1191
+ [
1192
+ mode,
1193
+ rowsInserted,
1194
+ rowsReplaced,
1195
+ rowsUnchanged,
1196
+ rowsDeleted,
1197
+ rowCount,
1198
+ cursorMax,
1199
+ ]
1200
+ description: |
1201
+ What a load that changed nothing did, in rows: counts alone. It committed
1202
+ no snapshot, so it has no `id` and is not a resource. `rowCount` is the
1203
+ table's rows after the load, which is its rows before, plus
1204
+ `rowsInserted`, less `rowsDeleted`.
1205
+ properties:
1206
+ mode:
1207
+ type: string
1208
+ enum: [merge, replace]
1209
+ description: The request's `mode`
1210
+ rowsInserted:
1211
+ type: integer
1212
+ format: int64
1213
+ description: Rows of keys the table did not have; for a keyless replace, the object rows with no identical stored row
1214
+ rowsReplaced:
1215
+ type: integer
1216
+ format: int64
1217
+ description: Rows written over a stored row of the same key, because a column differed. Always 0 for a keyless replace, which has no key to match on
1218
+ rowsUnchanged:
1219
+ type: integer
1220
+ format: int64
1221
+ description: Rows the objects held that the table already held. A keyed load leaves them in place; a keyless replace that changes any row rewrites the whole table, and this counts the rows matched
1222
+ rowsDeleted:
1223
+ type: integer
1224
+ format: int64
1225
+ description: |
1226
+ Stored rows removed: the rows of keys a replace's objects lack, and
1227
+ the copies beyond one of a key that was stored more than once; for a
1228
+ keyless replace, the stored rows with no identical object row
1229
+ rowCount:
1230
+ type: integer
1231
+ format: int64
1232
+ cursorMax:
1233
+ type: ["string", "null"]
1234
+ description: |
1235
+ The greatest value of the request's `cursor` over the rows the load
1236
+ kept, as text: an integer in decimal, exact past 2^53; a DATE as
1237
+ `YYYY-MM-DD`; a TIMESTAMP as ISO 8601, in UTC with a `Z` when it has
1238
+ a time zone. Null when no `cursor` was given or every value is NULL.
1239
+ cursorType:
1240
+ type: string
1241
+ description: The cursor column's type as DuckDB names it (`BIGINT`, `DATE`, `TIMESTAMP WITH TIME ZONE`); present when a `cursor` was given, except for a cursor every object types NULL on a table's first load, which has no type
1242
+
1243
+ Load:
1244
+ description: |
1245
+ A load that committed: its counts, and the `id`, `snapshotId` and
1246
+ `committedAt` of the snapshot that carries its record.
1247
+ allOf:
1248
+ - $ref: "#/components/schemas/LoadNoOp"
1249
+ - type: object
1250
+ required: [id, snapshotId, committedAt]
1251
+ properties:
1252
+ id:
1253
+ type: string
1254
+ format: uuid
1255
+ description: The load's id, for `GET …/loads/{id}`
1256
+ snapshotId:
1257
+ type: integer
1258
+ format: int64
1259
+ description: The snapshot the load committed; the one `GET /snapshots` lists with this load's `commitMessage`
1260
+ committedAt:
1261
+ type: string
1262
+ format: date-time
1263
+ description: When that snapshot was taken
1264
+
1265
+ LoadRead:
1266
+ description: A load as a read answers it, with who committed its snapshot and the message it carries.
1267
+ allOf:
1268
+ - $ref: "#/components/schemas/Load"
1269
+ - type: object
1270
+ required: [author, commitMessage]
1271
+ properties:
1272
+ author:
1273
+ type: ["string", "null"]
1274
+ description: Who committed the snapshot (`publisher-admin`)
1275
+ commitMessage:
1276
+ type: ["string", "null"]
1277
+ description: The message the snapshot carries, the request's `commitMessage` or `load <schema>.<table>`
1278
+
1279
+ LoadList:
1280
+ type: object
1281
+ required: [items]
1282
+ properties:
1283
+ items:
1284
+ type: array
1285
+ items:
1286
+ $ref: "#/components/schemas/LoadRead"
1287
+ nextCursor:
1288
+ type: string
1289
+ description: Opaque position; send it back as `after` for the next page. Absent on the last page
1290
+
687
1291
  Snapshot:
688
1292
  type: object
689
1293
  required: [id, time, changes]
@@ -698,6 +1302,12 @@ components:
698
1302
  type: object
699
1303
  additionalProperties: true
700
1304
  description: What it changed, as DuckLake records it (e.g. `tables_created`)
1305
+ author:
1306
+ type: ["string", "null"]
1307
+ description: Who committed it, as DuckLake records it (`publisher-admin` for a load); null when none was set
1308
+ commitMessage:
1309
+ type: ["string", "null"]
1310
+ description: The message the commit carried, such as a load's `commitMessage`; null when none was set
701
1311
 
702
1312
  SnapshotDeletion:
703
1313
  type: object
@@ -746,5 +1356,130 @@ components:
746
1356
  CATALOG_DATABASE_NOT_CONFIGURED, CATALOG_OWNER_UNSUPPORTED,
747
1357
  CATALOG_SETTING_UNREADABLE, SCHEMA_NOT_FOUND, TABLE_NOT_FOUND,
748
1358
  SOURCE_NOT_FOUND, TABLE_EXISTS, OBJECT_OUTSIDE_DATA_PATH,
749
- INVALID_REQUEST. Treat an
750
- unrecognized value as absent.
1359
+ INVALID_REQUEST, SCHEMA_EXISTS, SCHEMA_RESERVED,
1360
+ SCHEMA_IS_DESTINATION, LOAD_BUSY,
1361
+ LOAD_CONFLICT, LOAD_COLUMN_MISMATCH, LOAD_DELETE_LIMIT_EXCEEDED,
1362
+ LOAD_TOO_LARGE, OBJECT_UNREADABLE, LOAD_NOT_FOUND,
1363
+ IDEMPOTENCY_KEY_REUSED.
1364
+ `SCHEMA_EXISTS`: a create-only schema PUT found the schema.
1365
+ `SCHEMA_RESERVED`: the schema name is one the engine owns, `main`,
1366
+ or a name starting `__ducklake_metadata_`; also refused as the
1367
+ target of a load, because every managed connection reads `main` and
1368
+ a storage destination with no `destinationSchema` builds there (a
1369
+ table PUT or DELETE may write `main`).
1370
+ `SCHEMA_IS_DESTINATION` (409): a table PUT, a load or a schema
1371
+ DELETE targets the schema (`destinationSchema`, or `main` when it
1372
+ sets none) that a storage destination of an environment on this
1373
+ server builds into in this catalog, which Publisher builds; the
1374
+ message names the environment and the destination, and tables you
1375
+ write belong in another schema. A table DELETE there is allowed, and
1376
+ a copy may read its source from it. A connection's
1377
+ `destinationSchema` is not a destination's. The check reads the
1378
+ environments the server has loaded, so an admin-only listener, with
1379
+ no environments, a server still loading its environments, and an
1380
+ environment that failed to load refuse nothing. `LOAD_BUSY` (503): another load of the table, or another
1381
+ load on this server, is running; nothing was written, retry.
1382
+ `LOAD_CONFLICT` (409): DuckLake refused the commit because
1383
+ another request (a table PUT or DELETE, a schema drop) changed
1384
+ the table while the load ran; nothing was written, retry. A schema
1385
+ dropped before the load's transaction began is `SCHEMA_NOT_FOUND` (404).
1386
+ `LOAD_NOT_FOUND` (404): no load of the table has the id, or its
1387
+ snapshot was expired. `IDEMPOTENCY_KEY_REUSED` (409): a load's
1388
+ `Idempotency-Key` was used for a different request to the table.
1389
+ `LOAD_COLUMN_MISMATCH` (422): the objects' columns do not match
1390
+ the table's; `detail` is a `ColumnMismatchDetail`.
1391
+ `LOAD_DELETE_LIMIT_EXCEEDED` (422): a replace would delete more rows than
1392
+ `maxDeletedRows`; `detail` is a `DeleteLimitDetail`.
1393
+ `LOAD_TOO_LARGE` (422, a table PUT or a load): the write ran out of
1394
+ the session's memory or its spill cap (`admin.memoryLimit`, which a
1395
+ lower `duckdb.memoryLimit` overrides, and
1396
+ `admin.maxTempDirectorySize`). It is 422 because the work outgrew the
1397
+ session, not because the request body was too large (the v1 API's
1398
+ request-cap overrun is 413). A retry fails the same way: give the
1399
+ load a `key`, split its objects across loads, or raise the limit.
1400
+ `OBJECT_UNREADABLE` (422, a table PUT or a load): an object is
1401
+ missing, not in the format it claims, or holds a value its column's
1402
+ type cannot. The request is well-formed but the named data cannot
1403
+ be applied: correct the object, don't retry. The message is
1404
+ DuckDB's, with each URI replaced by `objects[i]` (a file name on a
1405
+ PUT), and a load's `detail` is an `ObjectUnreadableDetail`.
1406
+ A storage failure (unavailable, throttled, a refused credential)
1407
+ or a full spill disk is a `500` instead, to retry.
1408
+ Treat an unrecognized value as absent.
1409
+ detail:
1410
+ description: Present on the refusals that carry what a caller can act on; its shape is per `reason`
1411
+ oneOf:
1412
+ - $ref: "#/components/schemas/ColumnMismatchDetail"
1413
+ - $ref: "#/components/schemas/DeleteLimitDetail"
1414
+ - $ref: "#/components/schemas/ObjectUnreadableDetail"
1415
+
1416
+ ColumnMismatchDetail:
1417
+ type: object
1418
+ description: The `detail` of `LOAD_COLUMN_MISMATCH`, naming the column that breaks the table's contract and how
1419
+ required: [column, tableType, loadType, violation]
1420
+ properties:
1421
+ column:
1422
+ type: string
1423
+ description: The offending column; the folded name for a `case_collision`, and `""` for `no_columns`
1424
+ tableType:
1425
+ type: ["string", "null"]
1426
+ description: The table's type of the column; null when the table has no such column
1427
+ loadType:
1428
+ type: ["string", "null"]
1429
+ description: The objects' type of the column; null when the objects have no such column
1430
+ violation:
1431
+ type: string
1432
+ enum:
1433
+ - null_key
1434
+ - missing_key
1435
+ - missing_cursor
1436
+ - cursor_type
1437
+ - type_change
1438
+ - reserved_name
1439
+ - case_collision
1440
+ - no_columns
1441
+ - not_null
1442
+ description: |
1443
+ `null_key`: a `key` column is NULL in a row of the objects, or
1444
+ typed NULL in every object.
1445
+ `missing_key`: a `key` column is not a column of the objects, or of
1446
+ the table when it exists. `missing_cursor`:
1447
+ the `cursor` is not a column of the objects. `cursor_type`: the
1448
+ `cursor` is not an integer, DATE or TIMESTAMP column.
1449
+ `type_change`: a type that does not widen losslessly, against the
1450
+ table's column, or between two objects (`tableType` is then null).
1451
+ `reserved_name`: a column name starting `__publisher_` (in the
1452
+ objects, or in the table), or `file_row_number`, `rowid` or one
1453
+ holding a NUL. `case_collision`: two names, in one object or two,
1454
+ that differ only by case, or one name twice in an object.
1455
+ `no_columns`: the objects leave no column. `not_null`: a column the
1456
+ table holds NOT NULL is missing from the objects (`loadType` is
1457
+ null) or has a NULL among the rows the load writes.
1458
+
1459
+ DeleteLimitDetail:
1460
+ type: object
1461
+ description: The `detail` of `LOAD_DELETE_LIMIT_EXCEEDED`
1462
+ required: [wouldDelete, rowsBefore, maxDeletedRows]
1463
+ properties:
1464
+ wouldDelete:
1465
+ type: integer
1466
+ format: int64
1467
+ description: The stored rows the replace would delete
1468
+ rowsBefore:
1469
+ type: integer
1470
+ format: int64
1471
+ description: The table's rows before the load
1472
+ maxDeletedRows:
1473
+ type: integer
1474
+ format: int64
1475
+ description: The request's limit
1476
+
1477
+ ObjectUnreadableDetail:
1478
+ type: object
1479
+ description: The `detail` of a load's `OBJECT_UNREADABLE`. Absent when the reader's message names no object of the request
1480
+ required: [object]
1481
+ properties:
1482
+ object:
1483
+ type: integer
1484
+ minimum: 0
1485
+ description: The index of the unreadable object in the request's `objects`