Getting Started›Push Data

Push Data

You can push data into Hotdata through the API. This page covers the loading model, the upload sequence, and the write modes for publishing to a table; for data Hotdata pulls from systems you connect, see Pull Data.

The loading model

Data is loaded by publishing it: you supply a file, and it becomes the contents of a table.

  • Tables are created on first publish, so there is no migration step.
  • Every publish is atomic. Readers see the previous contents or the new ones, never a partially written table.

INSERT and CREATE TABLE also work (see Writing data with SQL), but Hotdata is built for bulk loads: send one call with ten million rows, not ten million single-row calls. Integrations that write row-at-a-time should batch upstream.

Every publish, regardless of size, goes through one endpoint:

POST /v1/databases/{database_id}/schemas/{schema}/tables/{table}/loads

The body carries a mode (see Load modes) and exactly one source. More than one source, or an unknown field name, returns a 400.

SourceDescriptionFormatsCeiling
upload_idA file already placed in storage through an upload session. The primary path for anything of size.Parquet, CSV, JSON (NDJSON)16 GiB per file
dataCSV text inline in the request body, header row included. Types are inferred unless you declare columns.CSV2 MiB
result_idA persisted query result, copied into a table so the data outlives the result.——

The upload sequence

File contents do not travel through the API: the bytes go straight to object storage, and the load names the file by id.

The clients already do this. upload_file opens the session, transfers the bytes — one PUT or many, concurrently — and finalizes, in one call:

upload = uploads_api.upload_file("orders.csv", content_type="text/csv")

databases_api.load_database_table(
    database_id, "public", "orders",
    hotdata.LoadManagedTableRequest(
        mode="replace",
        upload_id=upload.upload_id,
        format="csv",
    ),
)

The Python and Rust clients both carry it, for Parquet, CSV, or NDJSON. From the command line, hotdata databases load --file orders.csv does the same. The rest of this section is the protocol they implement.

Writing your own client

Every upload is the same three steps, with a fourth call to publish what arrived:

  1. Request an upload session. POST /v1/uploads — declare the approximate size, and the response returns an upload id, one or more URLs to write to, and a finalize token.
  2. PUT the bytes to the URL. They are written directly to object storage, so a 12 GB transfer does not hold an API connection open for its duration.
  3. Finalize. POST /v1/uploads/{upload_id}/finalize commits the upload, after which the file can be loaded.
  4. Load it. The endpoint above, with the upload_id as its source.

Only the second step varies with file size: a single PUT or several. The choice need not be made in advance — open a session and read mode from the response.

POST /v1/uploads
{ "filename": "orders.csv", "declared_size_bytes": 10485760, "content_type": "text/csv" }

# => { "upload_id": "upld7k2m9q4rx8vt3wnb5cyzhdfjs0", "mode": "multipart",
#      "part_size": 8388608, "part_urls": ["https://…", "https://…"],
#      "headers": {}, "finalize_token": "…" }

PUT <part_urls[0]>             # bytes [0, part_size); keep the response's ETag
PUT <part_urls[1]>             # the remainder

POST /v1/uploads/upld7k2m9q4rx8vt3wnb5cyzhdfjs0/finalize
X-Upload-Finalize-Token: <finalize_token>
{ "parts": [{ "part_number": 1, "e_tag": "\"9f8c1e5b7a2d4f60b3c8e1a9d7f4b206\"" },
            { "part_number": 2, "e_tag": "\"4b2af0c73d1e5a89f60b2c4e8d1a7f35\"" }] }

POST /v1/databases/dbid6lguax1dxn9y1xj5gxnameyywl/schemas/public/tables/orders/loads
{ "mode": "replace", "upload_id": "upld7k2m9q4rx8vt3wnb5cyzhdfjs0", "format": "csv" }

A session that comes back single carries a url instead: PUT the whole file to it, and finalize with no body. format is optional — it is detected from the Content-Type and the contents — and overrides that detection.

A new client also has to:

  • Cap the number of concurrent part PUTs.
  • Time out a part PUT that stalls.
  • Retry a failed part, and re-mint its URL on a 403.
  • For a multipart session, mint each part URL just before its PUT, so it cannot expire mid-transfer.

A single file

For a file small enough to send in one request, the sequence is four calls and a single transfer.

your serviceHotdataobject storage1POST /v1/uploads { declared_size_bytes }201 { upload_id, mode: "single", url, finalize_token }2PUT <url> — the file bodynever passes through the API3POST /v1/uploads/{upload_id}/finalizeheader: X-Upload-Finalize-TokenHEAD — did it arrive, is the size right4POST …/tables/orders/loads { "upload_id": … }
Finalize commits the upload, once. A second finalize returns 400. Loading is a separate call, so an upload can be held and loaded later, but only once. Presigned URLs last 30 minutes. The session lasts 24 hours.

A large file

Above the threshold, the session returns as multipart with a list of part URLs:

  1. PUT the slices concurrently.
  2. Keep every ETag.
  3. Submit the set at finalize.

When the total size is not known in advance, such as a stream, omit declared_size_bytes and mint part URLs as the transfer proceeds. The finalize call is unchanged, and no URL expires while waiting on a slow producer.

your serviceHotdataobject storage1POST /v1/uploads { declared_size_bytes: 40000000000 }201 { mode: "multipart", part_urls[], part_size, finalize_token }for each part, in parallel2PUT part_urls[i] — slice at part_size200 ETag — keep it2bPOST /v1/uploads/{upload_id}/partsstreaming only: mint the next URLs, 100 at a time3POST …/finalize { parts: [{ part_number, e_tag }, …] }4POST …/tables/orders/loads { "upload_id": … }
Slice by part_size, not by part count. Every part except the last must be at least 5 MiB. If finalize rejects the parts, it returns a 4xx and the session stays open. Fix the parts and finalize again.

Multiple files

Open all the sessions in a single call, then transfer them with whatever concurrency suits. Loads into the same table cannot run in parallel: a second concurrent load returns 409.

POST /v1/uploads/batchyour N filesup to 100N sessionsfinalize eachPUT → storagein paralleloneat a timeordersone tablefirst load "mode": "replace" · then "mode": "append" for the rest
One load takes one upload into one table. A directory of N files is N loads: there is no manifest, prefix, or glob ingest. Each load is atomic, and loading the same upload again returns the original result. To avoid N loads, concatenate the files and upload one.

Small payloads

Below 2 MiB, put CSV text directly in the load call's data field: one call, no session to finalize.

This suits a few thousand rows of reference data, a lookup table, or the remainder of a stream flushed on a timer.

{ "mode": "replace", "data": "id,total…" }POST …/tables/orders/loadsyour serviceHotdatadefault.main.orders200 { "row_count": 4812 }publishatomic
Same publish, one fewer round trip. Above 2 MiB the call returns 413 with the code INLINE_DATA_TOO_LARGE. Fall back to the upload sequence. Inline data is CSV with a header row. Declare columns to set types instead of inferring them.

Ingestion limits

These limits apply to every path above. For upload mode and part size, use the values in the session response.

LimitValueNotes
Inline data2 MiBExceeding this returns 413 INLINE_DATA_TOO_LARGE
Maximum upload size16 GiBPer file, whatever the format. Declare declared_size_bytes and an oversized file is refused at create, before any transfer
Sessions per batch call100Via POST /v1/uploads/batch
Presigned URL lifetime30 minRe-mint rather than retrying a stale URL
Upload session lifetime24 hUnfinalized sessions are removed

Load modes

mode determines what happens to the rows already in the table.

  • replace and append require nothing further.
  • The other three require a key: the columns that identify a row. Declare it on the table or supply it with the load.
ModeEffect on existing rowsKey requiredTypical use
replaceAll are discarded; the payload becomes the table's contents.—Full snapshots, and the first load into any new table.
appendRetained; the new rows are added alongside them.—Immutable events, or combining several files into one table.
upsertMatching rows are replaced; unmatched payload rows are inserted.yesIncremental synchronisation. Supply full rows.
updateMatching rows are replaced. Payload rows with no match are ignored.yesCorrections that must not create rows.
deleteRows whose keys appear in the payload are removed.yesPropagating deletions. Supply keys only, not full rows.

Constraints

The first load into a new table must be replace. Every other mode needs an existing table, and returns a 400 on a table that was never loaded.

A key matches rows; it is not a uniqueness constraint. The key names the columns that upsert, update, and delete use to match incoming rows against existing ones.

  • Nothing checks that the key is unique, and duplicates are not rejected.
  • The key is resolved per load: from the request if supplied, otherwise from the table's declaration.
  • Keep it the same across loads, or the merge matches on different columns.

replace and append accept only lossless schema changes.

  • A new column is added.
  • A type widens without loss: INTEGER becomes BIGINT when the payload requires it.
  • A narrowing or cross-family change, such as text to number or a changed decimal scale, returns a 409. Nothing is written, and the table stays queryable.

The keyed modes keep the table's types. upsert, update, and delete read the payload at the types the table already has.

  • A payload column typed more widely than its target is narrowed to match, so an INTEGER key sent as a BIGINT still matches.
  • A value that does not fit the target column returns a 400 naming the column, and nothing is written.
  • To widen a column, use replace.

Error handling

Errors are returned as { "error": { "message", "code" } }. Branch on the code, never the message. Every response carries an X-Trace-Id; log it and quote it in support requests.

StatusCodeMeaningAction
413INLINE_DATA_TOO_LARGEInline payload above 2 MiB.Fall back to an upload session; this case is recoverable.
501PRESIGN_UNSUPPORTEDUpload sessions are not available.Send the data inline instead.
409—The table is busy, the upload is already being consumed, or an incompatible column type change was requested.Retry after a short delay. Nothing was written.
400BAD_REQUESTTwo sources supplied, a mode the table cannot accept, a keyed mode without a key, a value the target column cannot represent, malformed CSV, or — on POST /v1/uploads — a declared size above the maximum upload size.Correct the request. Request-shape errors are caught before any job is created, and an oversized upload is refused before any bytes are transferred.
404NOT_FOUNDUnknown database, or a table that has been deleted.A deleted table is not recreated by a load; declare it again.
429OVERLOADEDThe workspace is busy.Honour Retry-After.
503CATALOG_BUSYThe service is briefly busy.Transient. The load may already have committed if the timeout hit after the write, so check the table, or load with an idempotency key, before retrying after Retry-After.

Querying and result formats

One endpoint runs SQL. It responds in JSON with a preview of the rows and, for larger results, a result_id that can be retrieved in the format required.

POST /v1/query
X-Database-Id: dbid6lguax1dxn9y1xj5gxnameyywl

{ "sql": "SELECT status, count(*) FROM default.main.orders GROUP BY 1" }

# => { "query_run_id": …, "result_id": …, "columns": […], "rows": […], "truncated": false }

GET /v1/results/{result_id}?format=arrow   # or parquet, csv, md, json

Use Arrow or Parquet for large results; JSON is for convenience.

A query can also answer in Arrow directly. Send Accept: application/vnd.apache.arrow.stream on POST /v1/query:

  • An inline result comes back as an Arrow IPC stream, with the metadata in headers (X-Query-Run-Id, X-Result-Id, X-Total-Row-Count, X-Execution-Time-Ms).
  • A result too large to return inline answers 202 with the run ticket and X-Result-Id. Read it from GET /v1/results/{id}?format=arrow.
  • Async runs and errors keep their JSON bodies.

Large results paginate with offset and limit and return a Link header for the next page. Parquet is returned whole.

The query endpoint also runs INSERT, CREATE TABLE, CREATE TABLE AS and DROP TABLE for callers with the write permission. See Writing data with SQL.

UPDATE and DELETE are not supported in SQL yet. Use the load endpoint's keyed modes.

The dialect is HotSQL; see the SQL Reference.