# MD_GET_FLIGHT_RUN
> Fetch a single run of a Flight by its run number.
Returns one run of a [Flight](/concepts/flights), looked up directly by `run_number`. Use it to check a specific run's status without paging through [`MD_LIST_FLIGHT_RUNS`](../md-list-flight-runs).

## Syntax

```sql
SELECT * FROM MD_GET_FLIGHT_RUN(
    flight_id := '<flight_id>',
    run_number := <n>
);
```

## Parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `flight_id` | `UUID` | Yes | Identifier of the Flight. |
| `run_number` | `UBIGINT` | Yes | The run to fetch. Run numbers are sequential, starting at `1`. |

## Return columns

| Column | Type | Description |
|---|---|---|
| `run_id` | `UUID` | Unique identifier of the run. |
| `flight_id` | `UUID` | Flight identifier. |
| `flight_name` | `VARCHAR` | Flight name at the time of the run. |
| `flight_version` | `UINTEGER` | The version this run locked to at start. |
| `config` | `MAP(VARCHAR, VARCHAR)` | The config the run used, including any [per-run overrides](../md-run-flight) passed to `MD_RUN_FLIGHT`. |
| `run_number` | `UBIGINT` | Sequential run number, starting at `1`. |
| `is_scheduled` | `BOOLEAN` | `true` if the run was triggered by the schedule, `false` for on-demand. |
| `status` | `VARCHAR` | Run status: `RUN_STATUS_PENDING`, `RUN_STATUS_RUNNING`, `RUN_STATUS_SUCCEEDED`, `RUN_STATUS_FAILED`, or `RUN_STATUS_CANCELLED`. |
| `created_at` | `TIMESTAMP WITH TIME ZONE` | When the run was created. |
| `started_at` | `TIMESTAMP WITH TIME ZONE` | When the run started executing, or `NULL` if it hasn't started. |
| `ended_at` | `TIMESTAMP WITH TIME ZONE` | When the run finished, or `NULL` while it's still running. |
| `scheduled_at` | `TIMESTAMP WITH TIME ZONE` | When the run was scheduled. |
| `cancelled_at` | `TIMESTAMP WITH TIME ZONE` | When the run was cancelled, or `NULL`. |
| `exit_code` | `INTEGER` | Process exit code, or `NULL` while the run is in progress. `0` means success. |

## Behavior

- Returns an error when no run with the given `run_number` exists for the Flight, or when the Flight itself doesn't exist.
- Parameters must be literals or `getvariable()` calls. Subqueries and lateral join columns fail with a binder error; store dynamic values with `SET VARIABLE` first.

## Examples

Check a specific run:

```sql
SELECT status, exit_code, started_at, ended_at
FROM MD_GET_FLIGHT_RUN(
    flight_id := '80000000-0000-0000-0000-000000000001',
    run_number := 42
);
```

Poll the run you just triggered:

```sql
SET VARIABLE run_number = (
    SELECT run_number
    FROM MD_RUN_FLIGHT(flight_id := '<flight_id>')
);

SELECT status, exit_code
FROM MD_GET_FLIGHT_RUN(
    flight_id := '<flight_id>',
    run_number := getvariable('run_number')
);
```

## Related

- [`MD_LIST_FLIGHT_RUNS`](../md-list-flight-runs) — Page through a Flight's full run history.
- [`MD_GET_FLIGHT_LOGS`](../md-get-flight-logs) — Read a run's output.
- [`MD_CANCEL_FLIGHT_RUN`](../md-cancel-flight-run) — Cancel an in-progress run.


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `GET https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

URL-encode query parameter values and send a GET request:

```text
GET https://motherduck.com/docs/api/feedback/agent?page_path=%2Fsql-reference%2Fmotherduck-sql-reference%2Fflights%2Fmd-get-flight-run%2F&page_title=MD_GET_FLIGHT_RUN&text=<url-encoded user feedback, max 2000 characters>
```

Optionally append `&source=<url-encoded interface identifier>` such as `claude.ai` or `chatgpt`.

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed query parameters, and `429` when rate-limited.
