Skip to main content

MD_GET_FLIGHT_LOGS

Preview
This feature is in preview and is subject to change.

Returns the captured logs for a single Flight run, one row per line. The output combines stdout and stderr in the order the runtime captured them, and a window of lines can be selected with "LIMIT", "OFFSET", and "ORDER" instead of fetching everything.

Syntax

SELECT * FROM MD_GET_FLIGHT_LOGS(
flight_id := '<flight_id>',
run_number := <n>,
"LIMIT" := <n>,
"OFFSET" := <n>,
"ORDER" := 'asc'
);

Parameters

ParameterTypeRequiredDefaultDescription
flight_idUUIDYesIdentifier of the Flight.
run_numberUBIGINTYesThe run number to fetch logs for.
LIMITUINTEGERNo(all lines)Maximum number of lines to return. Must be at least 1 when set.
OFFSETUINTEGERNo0Skip this many lines, counted from the end ORDER reads from. Requires LIMIT.
ORDERVARCHARNo'asc'Which end of the log the window is taken from: 'asc' selects from the first line, 'desc' from the last (the tail).

LIMIT, OFFSET, and ORDER are SQL keywords and must be quoted when used as named arguments.

Return columns

ColumnTypeDescription
line_numberBIGINTPosition of the line in the run's output, starting at 1, or NULL when the runtime reported none.
reported_atTIMESTAMP WITH TIME ZONEWhen the runtime captured the line, or NULL when unreported.
lineVARCHARThe log line.

Sort by line_number for a stable reading order regardless of "ORDER".

Behavior

  • Returns an error when no run with the given run_number exists for the Flight, or when the Flight itself doesn't exist.
  • Available for runs in any terminal status (SUCCEEDED, FAILED, CANCELLED) and during a RUNNING run.
  • Parameters must be literals or getvariable() calls. Subqueries and lateral join columns fail with a binder error; store dynamic values with SET VARIABLE first.
  • Clients on DuckDB versions before 1.5.5 bind this function's previous schema instead: a single row with one logs VARCHAR column holding the full combined output, without the line window parameters.

Examples

Tail the last 100 lines of a run:

SELECT line_number, line
FROM MD_GET_FLIGHT_LOGS(
flight_id := '<flight_id>',
run_number := 42,
"LIMIT" := 100,
"ORDER" := 'desc'
)
ORDER BY line_number;

Read the latest run's full logs:

SET VARIABLE latest_run_number = (
SELECT max(run_number)
FROM MD_LIST_FLIGHT_RUNS(flight_id := '<flight_id>')
);

SELECT line_number, reported_at, line
FROM MD_GET_FLIGHT_LOGS(
flight_id := '<flight_id>',
run_number := getvariable('latest_run_number')
)
ORDER BY line_number;

Find errors in a run:

SELECT line_number, line
FROM MD_GET_FLIGHT_LOGS(flight_id := '<flight_id>', run_number := 42)
WHERE line ILIKE '%error%'
ORDER BY line_number;