Docs menu

SHARED SOURCES OF TRUTH

Warm Queries

Goal: Save the query your team keeps re-deriving as a shared source of truth.

A warm query is a named, saved query against your data. One teammate (or one AI) writes the query - signups by campaign, deploys per day - saves it, deploys it, and it becomes the one everyone's AI calls.

WHY IT MATTERS

One query, one answer for everyone

Deploying a warm query makes it an API endpoint that people, dashboards and any AI can call (an AI calls it with call_api), and, once Provenance is set up, records who saved it. One deployed query becomes a shared source of truth your whole team - and any AI you connect - can use.

Build it

A warm query's address serves the version you last deployed, never your latest save. A saved change serves after Deploy, so a teammate's half-finished edit never changes what everyone's AI reads. The same goes for the tables a query reads and the warm queries it calls: a saved change to either serves after Deploy too. Connection settings, such as a database's name, are live: a change to one reaches the address at once. A query that was saved but never deployed answers 409 with the code WARM_QUERY_NOT_DEPLOYED and the remedy "Deploy to publish it" until you do. Beside its API Path, the Warm Query inspector says what the address serves, and the Deploy window lists the warm query addresses that change on that Deploy. The query runs when called - warm and ready, not constantly.

When a proposal is waiting on a saved query, from a teammate, Thinky or any AI, the Warm Query Manager says so above its tabs, with each field the proposal changes shown as saved and as proposed, and Open in Proposals brings the Proposals panel, where a person accepts it; until then the manager shows the saved query.

The Warm Query Manager opens from Manage Query in the node's Inspector, as a panel titled Query: and the node's name. It floats at first and docks anywhere, stays on its node when you select another, and comes back where you last had it. Two Warm Query nodes give two panels. See Node editors and work windows as panels.

Steps

A warm query is made of steps. Each step runs one query text on one engine and reads one source. The Warm Query Manager has a tab for them, beside Query, Parameters and Results: add a step with Add step, pick its engine, and write its text. Add step adds the step at once, with a name it picks for you: step2, then step3, the first one no step has. Nothing needs typing first.

Every step has a name, and the query's output points at the step whose rows come back. Step order means nothing, so there is no "last step": the output names the step.

To rename a step, change its name in the box on its row and press Enter, or click away. The rename moves every link to the step with it: the query's outputs, and every other step that reads the step or waits for it. A query you rename the only step of still returns that step's rows. A name that is blank, or that another step already has (capital letters do not make it a different name), is refused in a sentence under the step, and the step keeps its old name. The editor's back arrow undoes a rename in one go, with the links it moved. A query with a pending proposal cannot have a step renamed here until the proposal is accepted or rejected.

A step reads nothing from another step unless you say so, and steps that read nothing from each other run together.

Engines

Two engines are available today:

EngineRunsReads
kqlKQL on Azure Data ExplorerThe data connections wired to the query. The text is sent as written
cosmos-nosqlCosmos SQL on one containerOne container of a database wired to the query. One container per step

A query that reads only a database cannot have a kql step. To read two containers, write two steps and combine them, as below. Other kinds of step (writing, scripts) are not available yet and are refused.

Parameters

A warm query can take parameters, values a caller passes. On the Parameters tab, Add parameter gives each one a name, a type, whether it is Required, and a default. The types are string, long, real, bool, datetime, timespan, guid, dynamic, and lists of text or whole numbers (array<string>, array<long>), which can carry a most-items limit. A default is not allowed for dynamic or a list. A parameter name may not start with $.

A step reads a parameter by taking it as an input: it declares the value and its type, and says it comes from the request. In KQL the step uses the value by its name, and in Cosmos SQL as @name.

A caller passes a value the type does not fit and gets a refusal that names the parameter, never its value. When you call a saved query, its parameters are read from the query string; for a draft, send them as Arguments. Both are in the REST reference.

Combine steps, and push keys down

A step can read another step. Declare the value, then say where it comes from: a request parameter, a constant, or another step's column. Reading another step has three modes:

  • distinct takes the distinct values of one column.
  • scalar takes the one value of one column.
  • table takes the whole table.

This is how sources combine, and how a query stays fast on large data. With distinct, only the keys travel to the next step: the device ids of the first step become a list the second step filters by, so the first step's rows never enter the other engine's query. For example, a KQL step finds the devices seen in the last day, and a Cosmos step reads only the orders of those devices:

devices: kql           -> distinct DeviceID
orders:  cosmos-nosql  -> SELECT * FROM c WHERE ARRAY_CONTAINS(@deviceIds, c.deviceId)
                          with deviceIds bound to devices, column DeviceID, distinct

A long list of keys is sent in batches, four at a time. A query whose keys would need more than 50 batches is refused with BINDING_TOO_LARGE, naming the step, rather than run slowly. A step that waits on another waits for it to finish.

Draft runs and saved queries

A draft is a query you are still working on. Running a draft saves nothing and is held to small limits: 10,000 rows a step, 30 seconds, and a preview of the first 100 rows. You can also check a draft without running it: it is checked against the save rules and reads no data, and every refusal carries a remedy. Run a draft to try a saved change before you Deploy it. A deployed query runs as last deployed, with the engine's limits: 250,000 rows a step and about 200 seconds.

An AI works in this order, and says what it found at each step:

  1. Ask the inventory. retrieve_inventory with includeSample: true returns what each source holds: a connection's newest rows and the fields its devices send, a Cosmos container's documents, and the saved queries already trusted on the same sources. A Cosmos sample reads up to 25 documents of each container the query names, at most 5,000 RU a container, on your own account.
  2. Write the draft from those columns, fields and examples.
  3. Check, then compile it, as above.
  4. Run it small.
  5. Read the warnings back to you in plain words, below.
  6. Propose it, saying what it checked. You accept it, and Deploy it, yourself.

A step can also be compiled before it runs. Compiling a kql step asks Azure Data Explorer to plan the text against this workspace's real table. It reads no rows and answers the columns the step would return, or the engine's own words when the text names a column the table does not have. Compiling a cosmos-nosql step reads one document of its container, which costs request units (at most 5,000 RU, on your own Cosmos account), and answers that document's field names and JSON types, never their values. Cosmos holds no schema, so a wrong field name is not an error there: it reads as missing, and compiling says so in a note. An AI compiles each draft before it runs it.

A draft run says plainly when its answer looks wrong. It adds a warning, and never stops, when an output has no rows (NO_ROWS), when a column is null or blank text in every row the run shows (EMPTY_COLUMN, a hint from those few rows, often a field no device sends; it says how many rows it saw), and when a kql step uses take or limit with no order first (TAKE_WITHOUT_ORDER, so each run can answer other rows). Each warning has a remedy. The REST reference has the request and the answer.

Read it back

Once deployed, your warm query is reachable three ways: preview in the surface (a draft run of what is on screen); REST (GET /ox-api/warm-queries/{lookup}); or MCP (call_api from any AI). REST and MCP serve the deployed version, and list only deployed queries as routes of their own. Your queries are listed by get_workspace. The answer has an output for each output the query declares, with its columns and rows.

Build the next from it

Because any AI can both read (call_api) and propose (manage_proposals), one source of truth becomes the seed for the next. Accept proposals in the workspace and the workshop compounds.

What is remembered

Once Provenance is set up, a Save of the query, or an accepted proposal for it, is recorded: who did it, what changed, and when. Running the query is not recorded today; see what is and is not recorded and Ship with Confidence.

Next steps

On fathym.com: OpenX warm queries →

On this page