# Stream graphs

> Land, model, send. A stream graph rebuilds what a stream in feeds as soon as its rows land, then sends the result out with your streams out.

A stream graph joins three things you already have, and runs them in order every time a stream in lands rows:

1. **Lands.** A [stream in](https://docs.sanda-os.com.au/streams/in) reads new and changed records into your warehouse.
2. **Models.** A [task](https://docs.sanda-os.com.au/modelling/tasks) rebuilds the views and tables those records feed.
3. **Sends.** Your [streams out](https://docs.sanda-os.com.au/streams/out) send the result to the systems your team works in, such as Salesforce.

Without a graph, each of the three keeps its own schedule, and a number can go out before the rows it is built on have been modelled. With one, the modelling starts as soon as the rows land, and the streams out start only once it has succeeded. A half-built number never leaves.

Stream graphs are on **Data · Streams**, on the **Graphs** tab. The other two tabs are **Streams in** and **Streams out**.

## Make a stream graph

You need a stream in first: its landing starts the graph. Only owners and admins make or change a graph.

:::steps
1. **Start it.** On the **Graphs** tab, press **New stream graph**.
2. **Name it**, and choose what it **Lands**: the stream in whose landing starts it.
3. **Choose what it Models.** A task of the warehouse the stream in lands in, run as soon as the rows land. Choose **Nothing: send what landed, as it landed** to send without modelling.
4. **Tick what it Sends**: the streams out it starts once the modelling succeeds. A graph can also send nothing, and only model what lands.
5. **Press Save graph.** It runs the next time its stream in lands rows, or now, with **Run now** on its page.
:::

A graph models, sends, or both: one with neither is refused. A stream out you tick that was set to run straight after the same stream in landed now waits for the graph instead, and saving says so, so it is never started twice for one landing.

## What happens each time

When a run of the stream in lands rows, each of its graphs makes a **pass**:

- **The task runs at once,** started by the landing rather than by its own schedule, and recorded with its other runs under **Modelling · Tasks**.
- **If the modelling succeeded,** each stream out starts, and sends only what changed, as it always does. Each one's run says it was started by the stream graph.
- **If it didn't,** nothing is sent. The pass says why, and the next landing models and sends.

A run of the stream in that finds nothing new lands nothing, and no pass is made.

A pass is **held**, and sends nothing, when its task is paused, has been deleted, or is already running. A stream out that can't run this time (paused, its credential to connect again, past what your edition runs, or still running from before) is passed over, and the pass says which.

## A graph's page

Open a graph to see its three stages, with each one's name, and its **Passes**: the last thirty, newest first. Each pass says what happened, such as "188 rows landed, modelled, then started 1 stream out.", with how the modelling went and each stream out's run.

![A stream graph's page: its Lands, Models and Sends stages, then its passes, one of them held because the task was already running.](https://docs.sanda-os.com.au/media/graphs-page.png "A stream graph that lands a shop's orders, refreshes revenue and sends it to Salesforce.")

| Pass | What it means |
|---|---|
| **running** | The modelling or the sending is under way |
| **succeeded** | The modelling succeeded, and the streams out were started |
| **held** | It modelled or sent nothing, and says why: the task was paused, deleted or already running, or the modelling didn't succeed |
| **failed** | sanda couldn't finish the pass. The stream in's run still landed what it landed |

- **Run now** runs the stream in. When it lands rows, the graph models and sends as it would on a schedule.
- **Pause** stops the graph: a landing starts nothing until it is resumed. The stream in, the task and the streams out keep their own schedules either way.
- **Edit** changes any of its three stages.
- **Delete graph**, at the foot of the page, stops it joining its streams. The streams and the task stay as they are, and its passes stay on record.

## What a graph costs

A graph costs nothing of its own. Its stream in's and streams out's runs are billed as any stream's are (see [what streams cost](https://docs.sanda-os.com.au/streams#what-streams-cost)), and its modelling is billed as the task's [compute](https://docs.sanda-os.com.au/billing/usage), as when the task runs on its own schedule.

:::links
- [Streams in](https://docs.sanda-os.com.au/streams/in): An app's records or a database's tables, landed in your warehouse.
- [Tasks](https://docs.sanda-os.com.au/modelling/tasks): The steps that rebuild what your data feeds.
- [Streams out](https://docs.sanda-os.com.au/streams/out): Your numbers, written into Salesforce fields.
:::
