Sources and snapshots

A source is where rows come from. Each file uploaded to it, each batch of rows posted to it and each pull of its query is kept whole as a snapshot, numbered from 1 and never changed. A graph reads a snapshot, never the source live, so a run can be done again on the same data.

kinda snapshot istaken when
uploada parsed CSV fileeach upload to it
pushrows an application or an agent posts, with where they came fromeach post
querya spec run on a deployed branch of the model, under the run’s contexta run pulls it

A new snapshot runs nothing. A dataset that reads the source changes on its next run, when your application sends one.

Upload a CSV

The body is the file, as bytes; the content type is not read. Everything else is in the query string:

curl -s -X POST "http://127.0.0.1:3699/projects/shop/sources?file_name=sales.csv&description=Q3%20export" \
  --data-binary @sales.csv
order_id,order_date,store_id,product,category,qty,unit_price
50001,2026-09-07,101, Whole milk ,dairy,4,4.19
50002,2026-07-05,102,Bananas,Produce,,0.59
50003,2026-08-24,201,Bananas,Produce,1,0.59
50003,2026-08-24,201,Bananas,Produce,1,0.59
50004,2026-09-19,999,Apples,produce,2,1.89

201, with the source and its first snapshot:

{
  "source": {
    "id": "src_be28bf24ae006946",
    "name": "sales",
    "description": "Q3 export",
    "kind": "upload",
    "created": "2026-11-28T19:25:23.261Z",
    "updated": "2026-11-28T19:25:23.350Z",
    "snapshot": 1,
    "columns": [
      {"name": "order_id", "role": "dimension", "type": "integer"},
      {"name": "order_date", "role": "dimension", "type": "date"},
      {"name": "store_id", "role": "dimension", "type": "integer"},
      {"name": "product", "role": "dimension", "type": "text"},
      {"name": "category", "role": "dimension", "type": "text"},
      {"name": "qty", "role": "measure", "type": "integer"},
      {"name": "unit_price", "role": "measure", "type": "decimal(2)"}
    ],
    "read": 1,
    "reads": [{"at": "2026-11-28T19:25:23.261Z", "version": 1}]
  },
  "snapshot": {
    "source": "src_be28bf24ae006946",
    "number": 1,
    "kind": "upload",
    "taken": "2026-11-28T19:25:23.350Z",
    "file_name": "sales.csv",
    "sha256": "2253e74f165394299c6ccab9eb6ec0f4e4777cf04e91a7bf644300f5b4b73649",
    "bytes": 2626,
    "rows": 5,
    "columns": ["... as on the source ..."],
    "parse": {
      "encoding": "utf-8", "bom": false,
      "delimiter": ",", "delimiter_detected": true,
      "quote": "\"",
      "header": true, "header_detected": true,
      "rows": 5, "bad_rows": 0
    }
  }
}
Query parameterDefaultDoes
kinduploadupload, push or query
namethe file name without .csv, else untitledat most 200 characters
descriptionnoneat most 2,000 characters
datasetfalsealso make a dataset over the source, as it is (Datasets); its answer is under dataset
file_namenonethe file’s name, kept in the snapshot and its lineage
delimiterdetectedone ASCII character; URL-encode it (%3B for ;, %09 for a tab)
quote"one ASCII character, not the delimiter
headerdetectedtrue or false
max_bad_rowsone row in a hundredhow many rows may fail to parse before the upload fails

An unknown parameter is 400 Invalid. A project with no deployed branch in the org is 404: no project nowhere is deployed; deploy a branch of it before adding sources.

The CSV contract

The file is parsed by the server, in Rust, never by the engine that runs graphs. Every choice the parse made is in parse, so the same file parses the same way again and a reader can see why a column came out as it did.

  • Encoding is UTF-8, with a byte-order mark accepted and recorded (bom). A UTF-16 file is refused with 422: save it as UTF-8.
  • The delimiter is detected from the first 50 lines among , ; tab and |, unless delimiter says; delimiter_detected says which happened.
  • The header is detected: the first row is a header when some column below it has a type other than text that its first value is not. When every column is text, it is a header.
  • Column names are trimmed, an empty one becomes column_<n>, and a repeat (case aside: Region and region are the same) gets a suffix, _2. Each rename is listed under parse.renamed, {"from", "to"}.
  • A bad row (not UTF-8, or more or fewer fields than the first) is counted in bad_rows, and the first five are listed under bad_examples with their line and why. Past max_bad_rows the upload fails rather than quietly dropping data. A blank line is skipped, not counted.
  • Limits: ZSQL_DATASET_MAX_BYTES (256 MiB) and ZSQL_DATASET_MAX_ROWS (1,000,000), 4,096 columns, 1 MiB a field, 33,554,432 values in all.

Types and roles

Each column is given the narrowest type every value fits, empty values aside, which are null:

TypeA value like
booleantrue, false
integer42, -7 (64-bit)
decimal(s)4.19 is decimal(2); scale at most 18, precision always 38
double1.5e3, or more places than a decimal holds
date2026-09-07, a real day
timestamp2026-09-07 14:30, 2026-09-07T14:30:05.123456
textanything else

A column with a value like 007 or 02134 is text, so codes and postcodes keep their zeros. A date in any other form (07/09/2026, Sep 7 2026) stays text; a retype_column step with a format, or to_date() in a formula, reads it.

Each column also has a role. A number is a measure unless its name says it names things (id, key, code, year, month, quarter, week, day, zip, or a name ending in id, key, code, no, number or zip, storeId and store_id alike); everything else is a dimension. The role decides how a dataset blends. An output node sets it where the inference is wrong.

Locale numbers

1,5 with a decimal comma, $1,204.00 and (500) are text to the parse, never guessed. A formula reads them: to_number(amount, ','); see Steps and formulas.

A new snapshot

POST .../sources/{id}/snapshots with the next file. It takes file_name, delimiter, quote, header and max_bad_rows as an upload does:

curl -s -X POST "http://127.0.0.1:3699/projects/shop/sources/src_be28bf24ae006946/snapshots?file_name=sales_v2.csv" \
  --data-binary @sales_v2.csv

The second file has a new channel column and a price with three places. 201, with the source and the new snapshot; the snapshot says how its columns met the source’s:

{
  "snapshot": {
    "source": "src_be28bf24ae006946",
    "number": 2,
    "file_name": "sales_v2.csv",
    "rows": 6,
    "changes": [
      "column 'unit_price' widened from decimal(2) to decimal(3)",
      "column 'channel' is new, as text"
    ],
    "columns": [
      {"name": "order_id", "role": "dimension", "type": "integer"},
      {"name": "order_date", "role": "dimension", "type": "date"},
      {"name": "store_id", "role": "dimension", "type": "integer"},
      {"name": "product", "role": "dimension", "type": "text"},
      {"name": "category", "role": "dimension", "type": "text"},
      {"name": "qty", "role": "measure", "type": "integer"},
      {"name": "unit_price", "role": "measure", "type": "decimal(3)"},
      {"name": "channel", "role": "dimension", "type": "text"}
    ]
  }
}

Types evolve, never truncate

A new snapshot meets the source’s columns by name:

  • The same type, or one that fits (an integer arriving for a decimal column): cast to the established type.
  • A wider type (integer to decimal or double, a decimal to more places or to double, date to timestamp): the column widens, losing nothing.
  • Neither (text arriving for a date column): kept at the established type only if every value converts; otherwise the snapshot is refused and nothing changes.
  • A new column is added; a column not in the file is listed (column 'x' is not in this snapshot) and the graph that reads it says so on its next run.
{"error": {"class": "Unprocessable", "message": "column 'order_date' is date and arrived as text: 1 value(s) do not convert, such as 'soon'; nothing was changed"}}

A number never quietly becomes text.

How many are kept

A source keeps its 20 newest snapshots, and also every snapshot that a dataset output is as it is, that a dataset’s live version was made from, or that a run going now reads. One let go is removed from the backup too.

Push rows

A push source takes rows as JSON: each row an object of column to value, and an origin kept as the pusher says it. It is how an agent or an application hands over what a tool or an API returned, without the server calling anything out:

curl -s -X POST "http://127.0.0.1:3699/projects/shop/sources?kind=push&name=promos" \
  -H "Content-Type: application/json" \
  -d '{"rows": [{"store_id": 101, "promo": "Fall harvest", "discount": 0.1},
                {"store_id": 201, "promo": "Back to school", "discount": 0.15}],
       "origin": {"system": "crm", "exported": "2026-11-28"}}'
{
  "source": {"id": "src_0704f5f45eade726", "name": "promos", "kind": "push", "snapshot": 1, "read": 1,
             "columns": [{"name": "discount", "role": "measure", "type": "decimal(2)"},
                         {"name": "promo", "role": "dimension", "type": "text"},
                         {"name": "store_id", "role": "dimension", "type": "integer"}],
             "reads": [{"at": "2026-11-28T19:25:32.766Z", "version": 1}],
             "created": "2026-11-28T19:25:32.766Z", "updated": "2026-11-28T19:25:32.851Z"},
  "snapshot": {"source": "src_0704f5f45eade726", "number": 1, "kind": "push", "rows": 2, "bytes": 1394,
               "origin": {"exported": "2026-11-28", "system": "crm"},
               "sha256": "73383a304f857406733e90b93edb748430cde920c6e74fd595a0d9f130ecc7af",
               "taken": "2026-11-28T19:25:32.851Z", "columns": ["... as on the source ..."]}
}

A column is every name any row has, its type inferred as a file’s is; a row without it has a null. As the answer shows, the columns come out in name order, not the order a row wrote them. Two names that differ only in case are refused. The next batch is POST .../sources/{id}/snapshots with the same body.

A query source

A query source keeps a spec, or an expr, on a branch of the model:

curl -s -X POST "http://127.0.0.1:3699/projects/shop/sources?kind=query&name=revenue%20by%20region" \
  -H "Content-Type: application/json" \
  -d '{"branch": "main", "expr": "region, revenue"}'
{"source": {"id": "src_ce9db02188609c4a", "name": "revenue by region", "kind": "query",
            "query": {"branch": "main", "expr": "region, revenue"},
            "snapshot": 0, "columns": [], "read": 1,
            "reads": [{"at": "2026-11-28T19:25:32.862Z", "version": 1}],
            "created": "2026-11-28T19:25:32.862Z", "updated": "2026-11-28T19:25:32.862Z"}}

It has no snapshot until a run pulls it, so dataset=true is refused for one. Give spec or expr, not both.

It keeps a spec, never a context. A run plans the spec under the context the run was sent with, runs it on the warehouse as /run does (with the run’s connection over the deployed credential), and keeps the rows as the next snapshot. Two applications that read the same query source each read it as their own caller.

A snapshot is read only by the statement that took it. Each records the key of the statement it ran, a hash of the datasource and the SQL. A later run reads the newest snapshot only when its spec plans to that same statement under the new run’s context; otherwise it pulls. On a branch with row-level security, a caller whose policies plan different SQL never reads another caller’s snapshot. With no policies two callers plan the same statement, and share it.

Columns that are fields of the model take their role from it: a measure is a measure. The snapshot says what made it:

{
  "source": "src_ce9db02188609c4a", "number": 1, "kind": "query", "rows": 2,
  "taken": "2026-11-28T19:26:45.920Z",
  "columns": [{"name": "Region", "role": "dimension", "type": "text"},
              {"name": "Revenue", "role": "measure", "type": "decimal(2)"}],
  "semantic": {
    "branch": "main",
    "deployed_at": "2026-11-28 19:25",
    "expr": "region, revenue",
    "spec": {"projections": [{"field": "region"}, {"field": "revenue"}]},
    "sql_sha256": "4781085bfb29633a63da788b54c1421b78f709c8baf4e0f2b52b9c470898c8bd",
    "context": "817a45e28928b042ca77056b982533fe7b54d390bc30ee329123a175ff9ffaca",
    "fields": {"Region": "region", "Revenue": "revenue"}
  }
}

context is the statement’s key, not the security context, which is never kept; nor is the run’s result id, which expires with the cache.

Read options

PATCH .../sources/{id} changes the name, the description, or the types its columns are read as. A wrong inference is fixed here, once, for every graph that reads the source:

curl -s -X PATCH http://127.0.0.1:3699/projects/shop/sources/src_496cb47f693068fc \
  -H "Content-Type: application/json" \
  -d '{"description": "store list from ops", "types": {"store_id": "text"}}'
{
  "id": "src_496cb47f693068fc", "name": "stores", "description": "store list from ops", "kind": "upload",
  "snapshot": 1,
  "types": {"store_id": "text"},
  "read": 2,
  "reads": [{"at": "2026-11-28T19:25:23.365Z", "version": 1},
            {"at": "2026-11-28T19:25:46.103Z", "types": {"store_id": "text"}, "version": 2}],
  "columns": ["... as the snapshot has them ..."]
}

A change of types is a new version of how the source is read (read), applied by every graph on its next run and recorded in each output’s lineage. "types": {} goes back to the types as they arrive, as version 3. A graph can also read a source with types of its own, for itself only: types on its source node.

Types are boolean, integer (or int, bigint), decimal(s) (decimal alone is decimal(2)), double (or float), date, timestamp and text (or string, varchar).

Read a snapshot

curl -s "http://127.0.0.1:3699/projects/shop/sources/src_be28bf24ae006946/rows?snapshot=1&limit=3&sort=order_id:desc"
{
  "snapshot": 1,
  "columns": [{"name": "order_id", "role": "dimension", "type": "integer"}, "..."],
  "total": 5,
  "offset": 0,
  "rows": [[50004, "2026-09-19", 999, "Apples", "produce", 2, "1.89"],
           [50003, "2026-08-24", 201, "Bananas", "Produce", 1, "0.59"],
           [50003, "2026-08-24", 201, "Bananas", "Produce", 1, "0.59"]]
}
ParameterDefaultDoes
snapshotthe newestwhich snapshot
offset0rows to skip
limit1001 to 10,000
sortthe order the rows camecolumn, or column:desc, comma-separated
filternonea formula, true for the rows shown

A decimal comes back as a string, so no digit is lost; a date as YYYY-MM-DD. total counts the rows the filter keeps:

curl -s -G http://127.0.0.1:3699/projects/shop/sources/src_be28bf24ae006946/rows \
  --data-urlencode "filter=category = 'Produce' and qty is null"
{"snapshot": 1, "total": 1, "offset": 0, "rows": [[50002, "2026-07-05", 102, "Bananas", "Produce", null, "0.59"]], "columns": ["..."]}

The other reads:

RouteAnswers
GET .../sources{"sources": [...]}, every source of the project
GET .../sources/{id}the source
GET .../sources/{id}/snapshots{"snapshots": [...]}, the manifests kept, the newest first
GET .../sources/{id}/snapshots/{n}one manifest; 404 when it was let go or is not a number

Delete a source

curl -s -X DELETE http://127.0.0.1:3699/projects/shop/sources/src_496cb47f693068fc
{"removed": "src_496cb47f693068fc", "datasets_given_their_rows": ["ds_aad92d187e281d13"]}

A delete removes every snapshot. A dataset output that was one of its snapshots as it is gets a copy of those rows first, so it keeps answering; those datasets are listed. A graph that reads the source fails its next run, saying so:

{"error": {"class": "Refused", "message": "node stores: it reads source src_496cb47f693068fc, which is not in this project"},
 "problems": [{"code": "not_found", "message": "it reads source src_496cb47f693068fc, which is not in this project", "node": "stores"}]}

While a run is reading the source the delete is 409:

{"error": {"class": "Conflict", "message": "source src_496cb47f693068fc is read by a run going now; delete it when that is done"}}

Which graphs read a source is your application’s to know: it keeps the graphs.

Next steps