MD_GET_FLIGHT_RUN
Preview
This feature is in preview and is subject to change.
Returns one run of a Flight, looked up directly by run_number. Use it to check a specific run's status without paging through MD_LIST_FLIGHT_RUNS.
Syntax
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 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_numberexists 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 withSET VARIABLEfirst.
Examples
Check a specific run:
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:
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— Page through a Flight's full run history.MD_GET_FLIGHT_LOGS— Read a run's output.MD_CANCEL_FLIGHT_RUN— Cancel an in-progress run.