# Pipelines overview

A pipeline is how data gets into Solidafy and gets shaped once it is there. This page covers the pipeline YAML file you keep in git and push with the CLI, how steps run, how runs work, and where to look when one fails.

## What a pipeline is

A pipeline is a named set of **steps**. Each step runs one DSL query. Steps that read from an external system pull data into a table, steps that transform read your tables and write new ones, and alert steps send a message when something needs attention. You can also put dashboard charts and filters in the same file, so the pipeline that builds a table and the dashboard that shows it live together.

Every time a pipeline executes, that is a **run**. Runs start on a schedule, by hand, from a webhook, or when another pipeline finishes.

You can build pipelines in the portal (**Ingestion > Pipelines**) or as YAML files with the CLI. This page focuses on the YAML file, because it is what you review, keep in version control and push to each of your environments.

## The pipeline file

Here is a small but complete pipeline. It pulls pull requests from GitHub, builds a clean table from them, and posts to Slack when a run fails.

```yaml
name: GitHub Ingest
description: Pull requests from GitHub, deduplicated into gh.pull_requests
category: ingest
schedule: '0 */6 * * *'

steps:
  - name: extract_pull_requests
    type: connector
    data_source_id: 00000000-0000-0000-0000-000000000000
    dsl: |
      connector("github-graphql",
        access_token: "${ACCESS_TOKEN}",
        org: "${ORG}",
        start_date: "2025-01-01T00:00:00Z"
      )
        .stream("pull_requests", cursor: "updatedAt")
        .output("github_graphql.pull_requests",
          mode: append,
          partition_by: [_extracted_at.truncate(day)]
        )

  - name: pull_requests
    type: materialize
    depends_on:
      - extract_pull_requests
    dsl: |
      source("github_graphql.pull_requests")
        .dedupe([pr_id], keep: latest_by(_extracted_at))
        .select([pr_id, repo, author, pr_title, opened_at, status])
        .output("gh.pull_requests", mode: replace)

  - name: failure_notify
    type: alert
    trigger: on_failure
    dsl: |
      mock([{
        title: "Pipeline Failed",
        pipeline: "${run.name}",
        status: "Failed",
        status_emoji: ":x:",
        steps: "${run.completed_steps}/${run.total_steps}",
        duration: "${run.duration}",
        footer: "Step: ${run.failed_step}"
      }]).push("slack-push", action: "send_pipeline_status",
        webhook_path: "/services/YOUR/WEBHOOK/PATH")
```

### Top-level fields

| Field | Required | What it does |
| --- | --- | --- |
| `name` | Yes | The pipeline's name. |
| `id` | No | Set by the CLI. Leave it out the first time you push; the CLI writes the new id into the file. While the file has an `id`, a push updates that pipeline. |
| `description` | No | Free text. |
| `category` | No | A free-form label, up to 100 characters, such as `ingest` or `dashboard`. Leaving it out keeps the stored value. |
| `schedule` | No | A cron expression, evaluated in UTC. Set it to `null` to remove a schedule; leaving it out keeps the stored value. See [Schedules](/docs/pipelines/triggers-and-webhooks#schedules). |
| `status` | No | `draft`, `active`, `paused` or `error`. A schedule only runs while the pipeline is `active`. Leaving it out keeps the stored value, and a new pipeline starts as `draft`. |
| `steps` | Yes, to do anything | The list of steps. A pipeline with no steps is valid but does nothing when it runs. |
| `filters`, `charts` | No | Dashboard filters and charts. See [Dashboards overview](/docs/dashboards/overview). |

> **Note:** A pipeline also has a `status`: `draft`, `active`, `paused` or `error`. A schedule only fires while the pipeline is `active`, so a scheduled pipeline's file sets `status: active`. See [Schedules](/docs/pipelines/triggers-and-webhooks#schedules).

### Write DSL as block scalars

Always write `dsl:` with a YAML block scalar (`|`), as in the examples. It keeps line breaks and quotes intact. The last statement in a step must be a plain query chain, not a variable assignment like `result = source(...)`, because an assignment produces nothing to run.

## Steps

Every step has a `name` that is unique within the pipeline, a `type`, and a `dsl`.

![The four step types. A connector step reads a stream from an external system and writes a table. A materialize step reads your tables, transforms them and writes a table. A seed step keeps a small lookup table people edit in the portal, which materialize steps can join in. An alert step checks for a condition and sends a message to Slack or Mattermost.](/illustrations/pipeline-steps.svg)

A connector step must contain `connector("...")`, `.stream(...)`, `.output(...)` and at least one `${...}` credential placeholder. A materialize step must contain `.output(...)`. Seed and alert steps need a `dsl`. Seed tables are edited in the portal under **Data Lake > Master Data**.

### Connector steps

A connector step pulls from a **data source**: a connector plus your credentials, stored in the environment. The step points at the data source with `data_source_id`, and the DSL refers to the stored fields with `${...}` placeholders, so credentials never appear in the file. See [Connectors](/docs/pipelines/connectors) for how to create a data source, find its id, and name the placeholders.

A connector step without `data_source_id` passes validation with a warning, but it cannot resolve credentials when it runs.

### Materialize steps

A materialize step is any read-transform-write query. Two rules matter here:

- Give it `depends_on` when it reads a table another step in the same pipeline writes. Without it, the step can start before that table is fresh. The validator warns when a step reads `source("...")` and has no `depends_on`.
- Don't use dashboard filter placeholders like `[%time_range%]` here. They are only filled in for dashboard charts. Use fixed values such as `"90d"` instead; the validator rejects a materialize step that contains one.

How a step writes (append, replace, upsert and so on) is set in its `.output(...)` call. See [Writing tables](/docs/dsl/output).

### Seed steps

A seed step keeps a small, hand-maintained lookup table, such as a team roster, in sync. People edit the rows in the portal under **Data Lake > Master Data**, where saving writes straight to the table. You can also export and import a seed table as CSV with `solidafy seeds`; see the [CLI command reference](/docs/cli/commands#solidafy-seeds).

```yaml
  - name: developers
    type: seed
    dsl: |
      source("enrich.developers").output("enrich.developers", mode: replace)
```

### Alert steps

An alert step detects a condition and sends a message, usually with `.push()`. With `trigger: on_success`, `on_failure` or `on_complete`, an alert step becomes a lifecycle hook that runs after the rest of the pipeline. See [Alerts](/docs/pipelines/alerts).

### Run order

Steps don't run in file order. Solidafy builds the order from `depends_on`:

- A step with no `depends_on` starts as soon as the run starts, in parallel with every other such step.
- A step with `depends_on` starts once all the steps it lists have completed.
- Lifecycle hooks (alert steps with a `trigger`) run after everything else has finished.

`depends_on` must name steps that exist in the same file; the validator rejects anything else.

When a step fails, Solidafy retries it automatically, up to three times by default, doubling the wait between attempts. If it still fails, the steps that haven't run yet are skipped and the run is marked `failed`. An `on_failure` hook is the way to hear about it; see [Lifecycle hooks](/docs/pipelines/alerts#lifecycle-hooks).

## Validate, push and run

The CLI commands all take the path to the YAML file. For the full list of options see the [CLI command reference](/docs/cli/commands#pipelines).

```bash
P=environments/sandbox/pipelines/github-ingest.yaml

solidafy validate "$P"              # check the file without pushing
solidafy pipelines push "$P"        # create or update the pipeline
solidafy pipelines run "$P" --watch # start a run and wait for the result
solidafy logs "$P"                  # the most recent runs
```

`solidafy pipelines push` runs the same validation first and refuses to push while there are errors. Warnings are printed but don't block. On the first push of a file without an `id`, the CLI creates the pipeline and writes the `id` at the top of the file. Commit that change, so the next push updates the same pipeline instead of creating another one.

To start from what already exists in your account, `solidafy pipelines pull <name>` (or `--all`) writes pipelines as YAML files into `environments/<env>/pipelines/`.

Validation checks structure: step names and types, dependencies, required DSL calls, and the dashboard sections. It does not prove that every query runs. Use `solidafy test` for charts, and a real run for steps.

## Runs

A run goes through these statuses:

| Status | Meaning |
| --- | --- |
| `pending`, `queued` | Waiting to start. |
| `running` | Steps are executing. |
| `completed` | Every step succeeded. |
| `failed` | A step failed after its retries. |
| `partial` | A step failed, but the run finished through a recovery step set up for that failure. |
| `cancelled` | Someone cancelled the run. |

Starting a run by hand, through the API or from a webhook is refused with a conflict error while another run of the same pipeline is queued or running.

You can start a run from the portal (the **Run Now** button on a pipeline's runs page), with `solidafy pipelines run <file>`, or through the [API](/docs/reference/api#pipeline-runs). Through the API you can also cancel a run, and create a **backfill**: one run per hour, day, week or month across a date range, up to 500 runs at a time.

### Run variables

Steps can use the date a run is for. Write these in any step's DSL; they are replaced before the step runs:

| Expression | Value |
| --- | --- |
| `${{ run_date }}` | The run's date, `YYYY-MM-DD` |
| `${{ run_datetime }}` | The run's date and time, ISO 8601 |
| `${{ run_year }}`, `${{ run_month }}`, `${{ run_day }}`, `${{ run_hour }}` | Parts of the run date (UTC) |
| `${{ last_run_date }}`, `${{ last_run_datetime }}` | When the pipeline last ran, or empty on the first run |
| `${{ pipeline_id }}`, `${{ run_id }}` | Ids of the pipeline and the run |
| `${{ date_sub(run_date, "7d") }}`, `${{ date_add(run_date, "1d") }}` | The run date moved by a duration in `d`, `h` or `m` |
| `${{ format(run_date, "%Y-%m") }}` | The run date formatted with `%Y %m %d %H %M %S` |

The run date is the time the run was requested, unless the run was given a date: a backfill sets one per run, and the run endpoint accepts a `run_date`. That makes these expressions the way to write a step that reprocesses one slice of history:

```dsl
source("raw.events")
  .filter(event_date == "${{ run_date }}")
  .output("silver.daily_events", mode: append)
```

For the `@` variables the DSL itself understands, such as `@today` and `@time`, see [Runtime variables](/docs/dsl/overview#runtime-variables).

## Logs and debugging a failed run

`solidafy logs <file>` prints the five most recent runs with their status, how many steps completed, how many records were written, and the error message of a failed run. In the portal, open the pipeline and go to its runs page to see each run and each step's status, rows written and error.

When a run fails:

1. Read the run's error. It names the step that failed after its retries.
2. Run that step's query yourself. For a read, paste the part before `.output()` into `solidafy dsl '...'`; this is the fastest way to find a typo or a missing column.
3. Fix the YAML, `solidafy validate` it, push, and run again.

Through the API, `GET /api/v1/visual-pipelines/{id}/runs/{runId}/steps` returns every step of a run with its status, rows written, output table and error message.

## Examples to start from

`solidafy init` copies three complete pipelines into your project's `examples/` folder. Copy one into `environments/<env>/pipelines/` and edit it.

| File | What it shows |
| --- | --- |
| `examples/ingest-pipeline.yaml` | GitHub and Jira connector steps with incremental cursors, materialize steps chained with `depends_on`, seed tables, a data-quality table, alert steps, and success and failure hooks. |
| `examples/dashboard-pipeline.yaml` | A materialize step that pre-computes scores, then a full dashboard: filters that depend on each other, KPI, timeseries, bar, donut, scatter, radar and table charts, each with a drilldown. |
| `examples/alert-pipeline.yaml` | Anomaly, breach and absence detection, one message built from several queries, every Slack message layout, and lifecycle hooks. |

Before you push a copy, replace every `data_source_id` with the id of your own data source and every `webhook_path` with your own Slack webhook path.
