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.
| Source | Description | Formats | Ceiling |
|---|---|---|---|
upload_id | A file already placed in storage through an upload session. The primary path for anything of size. | Parquet, CSV, JSON (NDJSON) | 16 GiB per file |
data | CSV text inline in the request body, header row included. Types are inferred unless you declare columns. | CSV | 2 MiB |
result_id | A 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:
- 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. - 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.
- Finalize.
POST /v1/uploads/{upload_id}/finalizecommits the upload, after which the file can be loaded. - Load it. The endpoint above, with the
upload_idas 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
multipartsession, 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.
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:
- PUT the slices concurrently.
- Keep every
ETag. - 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.
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.
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.
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.
| Limit | Value | Notes |
|---|---|---|
Inline data | 2 MiB | Exceeding this returns 413 INLINE_DATA_TOO_LARGE |
| Maximum upload size | 16 GiB | Per file, whatever the format. Declare declared_size_bytes and an oversized file is refused at create, before any transfer |
| Sessions per batch call | 100 | Via POST /v1/uploads/batch |
| Presigned URL lifetime | 30 min | Re-mint rather than retrying a stale URL |
| Upload session lifetime | 24 h | Unfinalized sessions are removed |
Load modes
mode determines what happens to the rows already in the table.
replaceandappendrequire 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.
| Mode | Effect on existing rows | Key required | Typical use |
|---|---|---|---|
replace | All are discarded; the payload becomes the table's contents. | — | Full snapshots, and the first load into any new table. |
append | Retained; the new rows are added alongside them. | — | Immutable events, or combining several files into one table. |
upsert | Matching rows are replaced; unmatched payload rows are inserted. | yes | Incremental synchronisation. Supply full rows. |
update | Matching rows are replaced. Payload rows with no match are ignored. | yes | Corrections that must not create rows. |
delete | Rows whose keys appear in the payload are removed. | yes | Propagating 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:
INTEGERbecomesBIGINTwhen 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
INTEGERkey sent as aBIGINTstill matches. - A value that does not fit the target column returns a
400naming 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.
| Status | Code | Meaning | Action |
|---|---|---|---|
| 413 | INLINE_DATA_TOO_LARGE | Inline payload above 2 MiB. | Fall back to an upload session; this case is recoverable. |
| 501 | PRESIGN_UNSUPPORTED | Upload 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. |
| 400 | BAD_REQUEST | Two 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. |
| 404 | NOT_FOUND | Unknown database, or a table that has been deleted. | A deleted table is not recreated by a load; declare it again. |
| 429 | OVERLOADED | The workspace is busy. | Honour Retry-After. |
| 503 | CATALOG_BUSY | The 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
202with the run ticket andX-Result-Id. Read it fromGET /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.