Skip to content

Temporal

Temporal workflow executions, histories, activities, schedules and task queues as SQL

Connector software
Free and open source
Service credentials
Required
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/temporal/index.md to help me query Temporal with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Find the oldest open workflows

Uses your connected account. Set up the connector and credentials to run it with your data.

SELECT workflow_id, start_time
FROM temporal.main.workflow_executions()
WHERE status = 'Running' AND task_queue = 'orders'
ORDER BY start_time
LIMIT 20

Quick start

Choose where to run Temporal, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the release directly

Downloads the latest release for your platform and caches it locally.

ATTACH 'temporal' AS temporal (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-temporal'
);

3. Add service credentials

After attaching, create the secret for the service you want to query in the same SQL session. Replace the placeholders with your service settings.

temporal credentials

Temporal frontend address, namespace and credentials: an API key (Temporal Cloud), mTLS client certificates, or none for a local dev server.

Get these credentials →
secret.sql
CREATE SECRET temporal (
    TYPE temporal,
    host        '<host>',
    namespace   '<namespace>',
    api_key     '<TEMPORAL_API_KEY>',  -- secret
    tls         '<tls>',
    ca_cert     '<ca_cert>',
    client_cert '<client_cert>',
    client_key  '<CLIENT_KEY>',  -- secret
    server_name '<server_name>',
    ui_url      '<ui_url>'
);
Credential fields and requirements →

4. Run a query

query.sql
SELECT workflow_id, start_time
FROM temporal.main.workflow_executions()
WHERE status = 'Running' AND task_queue = 'orders'
ORDER BY start_time
LIMIT 20
More example queries →
Technical details
Verified connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the release directly

Uses the verified release each time you attach the connector.

ATTACH 'temporal' AS temporal (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/[email protected]'
);

Overview

Temporal workflow executions, event histories, pending activities, schedules, task queues and batch operations as SQL, from self-hosted Temporal or Temporal Cloud. Read-only.

Catalog

Everything temporal exposes once attached — read straight from the worker's released build.

temporal 2 schemas
main 1 table · 9 functions

Temporal workflow executions, histories, activities, schedules, task queues and batch operations.

Schema examples (14)
Examples (14)

Failed or timed-out runs per workflow type since January (filters run server-side)

SELECT workflow_type, count(*) AS failures
FROM temporal.main.workflow_executions()
WHERE status IN ('Failed', 'TimedOut') AND start_time >= TIMESTAMPTZ '2026-01-01'
GROUP BY workflow_type
ORDER BY failures DESC;

The oldest open workflows on one task queue

SELECT workflow_id, start_time
FROM temporal.main.workflow_executions()
WHERE status = 'Running' AND task_queue = 'orders'
ORDER BY start_time
LIMIT 20;

How many executions are in each status

SELECT status, count
FROM temporal.main.count_workflow_executions()
ORDER BY count DESC;

Total runs of one workflow type

SELECT count
FROM temporal.main.count_workflow_executions(query := 'WorkflowType = ''OrderWorkflow''', group_by_status := false);
10 more examples

Walk the history of the latest run of one workflow

SELECT event_id, event_type, event_time, failure_message
FROM temporal.main.workflow_history('order-123')
ORDER BY event_id;

Each activity of a run with its final attempt and outcome

SELECT s.activity_type, st.attempt, c.event_type AS outcome
FROM temporal.main.workflow_history('order-123') s
JOIN temporal.main.workflow_history('order-123') c ON c.scheduled_event_id = s.event_id AND c.event_type LIKE 'ActivityTask%' AND c.event_type <> 'ActivityTaskStarted'
LEFT JOIN temporal.main.workflow_history('order-123') st ON st.scheduled_event_id = s.event_id AND st.event_type = 'ActivityTaskStarted'
WHERE s.event_type = 'ActivityTaskScheduled'
ORDER BY s.event_id;

Why is this workflow stuck?

SELECT activity_type, state, attempt, last_failure_message
FROM temporal.main.pending_activities('order-123')
ORDER BY attempt DESC;

Every schedule with its next run

SELECT schedule_id, workflow_type, paused, next_action_times[1] AS next_run
FROM temporal.main.schedules()
ORDER BY schedule_id;

Recent runs started by schedules

SELECT schedule_id, a.workflow_id, a.status
FROM temporal.main.schedules(),
     UNNEST(recent_actions) AS r(a)
ORDER BY a.actual_time DESC;

Workers and backlog of one task queue

SELECT task_queue_type, poller_count, approximate_backlog_count
FROM temporal.main.task_queues('orders')
ORDER BY task_queue_type;

Custom search attributes of the namespace

SELECT name, type
FROM temporal.main.search_attributes()
WHERE is_custom
ORDER BY name;

Recent bulk actions and why they ran

SELECT job_id, operation_type, state, complete_operation_count, reason
FROM temporal.main.batch_operations()
ORDER BY start_time DESC;

Every namespace with its retention

SELECT name, retention_days, state
FROM temporal.main.namespaces
ORDER BY name;

Run counts per workflow type in the cross-orchestrator status vocabulary

SELECT workflow_type, temporal.main.unified_run_status(status) AS status,
  count(*) AS runs
FROM temporal.main.workflow_executions()
GROUP BY ALL
ORDER BY workflow_type, status;
Tables
namespaces 1 example12 cols

Namespaces of the cluster with retention, archival and replication settings

Columns
namenot null VARCHAR
Namespace name.
id VARCHAR
Namespace id (UUID).
state VARCHAR
Registered, Deprecated or Deleted.
description VARCHAR
Namespace description.
owner_email VARCHAR
Contact email of the team that owns the namespace.
retention_days DOUBLE
Workflow execution retention after close, in days.
history_archival_state VARCHAR
Enabled or Disabled.
visibility_archival_state VARCHAR
Enabled or Disabled.
is_global BOOLEAN
Whether the namespace is replicated across clusters.
active_cluster VARCHAR
Active cluster of a replicated namespace.
supports_schedules BOOLEAN
Whether the namespace supports schedules.
data JSON
Free-form namespace data (key/value map).
ConstraintsPRIMARY KEY (name)
Example

Every namespace with its retention

SELECT name, retention_days, state
FROM temporal.main.namespaces
ORDER BY name;
Link
Scalar functions
unified_run_status (status VARCHAR) 2 examples

Map a Temporal execution status (e.g. 'TimedOut') to queued/running/success/failed/cancelled

Arguments
status VARCHAR
Temporal execution status such as 'Failed' or 'ContinuedAsNew' (case-insensitive; the WORKFLOW_EXECUTION_STATUS_ prefix is accepted).
ReturnsVARCHAR
Examples (2)

Run counts per workflow type in the cross-orchestrator status vocabulary

SELECT workflow_type, temporal.main.unified_run_status(status) AS status,
  count(*) AS runs
FROM temporal.main.workflow_executions()
GROUP BY ALL
ORDER BY workflow_type, status;
SELECT s, temporal.main.unified_run_status(s) AS status
FROM (VALUES ('TimedOut'), ('ContinuedAsNew'), ('Canceled'), ('running'), ('WORKFLOW_EXECUTION_STATUS_TERMINATED'), ('bogus')) t(s)
ORDER BY s;
Link
Table functions
batch_operations (namespace := VARCHAR) 1 example

Batch operations (bulk terminate, cancel, signal, reset ...) of a namespace, read-only

Named arguments
namespace := VARCHAR
Namespace; default the secret's NAMESPACE.
Returns columns
namespace VARCHAR
Namespace of the batch operation.
job_id VARCHAR
Batch job id.
operation_type VARCHAR
Terminate, Cancel, Signal, Delete, Reset, UpdateExecutionOptions, ...
state VARCHAR
Running, Completed or Failed.
start_time TIMESTAMP WITH TIME ZONE
When the batch started.
close_time TIMESTAMP WITH TIME ZONE
When the batch finished.
total_operation_count BIGINT
Executions the batch targets.
complete_operation_count BIGINT
Executions processed successfully.
failure_operation_count BIGINT
Executions that failed.
identity VARCHAR
Who started the batch.
reason VARCHAR
Reason given when the batch was started.
query VARCHAR
Visibility query that selected the executions.
Example

Recent bulk actions and why they ran

SELECT job_id, operation_type, state, complete_operation_count, reason
FROM temporal.main.batch_operations()
ORDER BY start_time DESC;
Link
count_workflow_executions (namespace := VARCHAR, query := VARCHAR, group_by_status := BOOLEAN) 2 examples

Server-side count of workflow executions, grouped by execution status

Named arguments
namespace := VARCHAR
Namespace to count; default the secret's NAMESPACE.
query := VARCHAR
Temporal visibility query selecting the executions to count, e.g. 'WorkflowType = ''Order'''; default all.
group_by_status := BOOLEAN
true (default) for one row per execution status; false for one total row. · default true
Returns columns
namespace VARCHAR
Namespace counted.
status VARCHAR
Execution status of the group (Running, Completed, ...); NULL when group_by_status is false.
count BIGINT
Number of executions matching the query in this group.
Examples (2)

How many executions are in each status

SELECT status, count
FROM temporal.main.count_workflow_executions()
ORDER BY count DESC;

Total runs of one workflow type

SELECT count
FROM temporal.main.count_workflow_executions(query := 'WorkflowType = ''OrderWorkflow''', group_by_status := false);
Link
pending_activities (workflow_id VARCHAR, run_id := VARCHAR, namespace := VARCHAR) 1 example

In-flight activities of one workflow run, with attempt, backoff and last failure

Positional arguments
workflow_id VARCHAR
Workflow id whose event history to read.
Named arguments
run_id := VARCHAR
Run id; default the latest run of the workflow id.
namespace := VARCHAR
Namespace; default the secret's NAMESPACE.
Returns columns
workflow_id VARCHAR
Workflow id.
run_id VARCHAR
Run id (the latest run when run_id was not given).
activity_id VARCHAR
Activity id.
activity_type VARCHAR
Activity type name.
state VARCHAR
Scheduled (waiting for a worker or a retry), Started, CancelRequested, Paused or PauseRequested.
attempt INTEGER
Current attempt number (1 = first try).
maximum_attempts INTEGER
Retry policy maximum attempts; 0 means unlimited.
scheduled_time TIMESTAMP WITH TIME ZONE
When the current attempt was scheduled.
last_started_time TIMESTAMP WITH TIME ZONE
When the last attempt started.
last_heartbeat_time TIMESTAMP WITH TIME ZONE
Last heartbeat from the worker.
expiration_time TIMESTAMP WITH TIME ZONE
When the activity gives up (schedule-to-close timeout).
next_attempt_schedule_time TIMESTAMP WITH TIME ZONE
When the next retry is scheduled, while waiting between attempts.
current_retry_interval_seconds DOUBLE
Current backoff between attempts, in seconds.
last_failure_message VARCHAR
Message of the last failed attempt.
last_failure_type VARCHAR
Application error type of the last failure (e.g. CardDeclined), when set.
last_worker_identity VARCHAR
Identity of the worker that ran the last attempt.
paused BOOLEAN
Whether the activity is paused.
heartbeat_details JSON
Last heartbeat details, decoded.
Example

Why is this workflow stuck?

SELECT activity_type, state, attempt, last_failure_message
FROM temporal.main.pending_activities('order-123')
ORDER BY attempt DESC;
Link
schedules (namespace := VARCHAR) 2 examples

Schedules of a namespace with their spec, recent actions, upcoming times and policies

Named arguments
namespace := VARCHAR
Namespace; default the secret's NAMESPACE.
Returns columns
namespace VARCHAR
Namespace of the schedule.
schedule_id VARCHAR
Schedule id.
workflow_type VARCHAR
Workflow type the schedule starts.
paused BOOLEAN
Whether the schedule is paused.
notes VARCHAR
Notes recorded with the last pause/unpause.
cron_expressions VARCHAR[]
Cron strings of the spec as written, when the server keeps them (most servers store them as calendars).
intervals STRUCT(every_seconds DOUBLE, offset_seconds DOUBLE)[]
Interval specs: every_seconds and offset_seconds.
calendars JSON
Structured calendar specs (seconds, minutes, hours, days of month/week, months, years as ranges), including those compiled from cron strings.
timezone VARCHAR
IANA time zone the calendars are evaluated in; NULL for UTC.
spec JSON
The full schedule spec as JSON.
recent_actions STRUCT of 5 fields[]
Most recent actions: schedule_time, actual_time, started workflow_id/run_id and its status.
STRUCT[] 5 fields
  • schedule_timeTIMESTAMP WITH TIME ZONE
  • actual_timeTIMESTAMP WITH TIME ZONE
  • workflow_idVARCHAR
  • run_idVARCHAR
  • statusVARCHAR
next_action_times TIMESTAMP WITH TIME ZONE[]
Upcoming action times.
action_workflow_id VARCHAR
Workflow id prefix of started workflows (the action's workflow id; the start time is appended).
action_task_queue VARCHAR
Task queue of started workflows.
overlap_policy VARCHAR
What happens when a run is still open at the next action (Skip, BufferOne, AllowAll, ...).
catchup_window_seconds DOUBLE
How far back missed actions are caught up, in seconds.
action_count BIGINT
Number of actions taken so far.
missed_catchup_window BIGINT
Actions skipped because they were outside the catchup window.
overlap_skipped BIGINT
Actions skipped by the overlap policy.
running_workflow_ids VARCHAR[]
Workflow ids started by the schedule that are still running.
create_time TIMESTAMP WITH TIME ZONE
When the schedule was created.
update_time TIMESTAMP WITH TIME ZONE
When the schedule was last updated.
memo JSON
Schedule memo, decoded.
search_attributes JSON
Schedule search attributes, decoded.
Examples (2)

Every schedule with its next run

SELECT schedule_id, workflow_type, paused, next_action_times[1] AS next_run
FROM temporal.main.schedules()
ORDER BY schedule_id;

Recent runs started by schedules

SELECT schedule_id, a.workflow_id, a.status
FROM temporal.main.schedules(),
     UNNEST(recent_actions) AS r(a)
ORDER BY a.actual_time DESC;
Link
search_attributes (namespace := VARCHAR) 1 example

System and custom search attributes of a namespace with their types

Named arguments
namespace := VARCHAR
Namespace; default the secret's NAMESPACE.
Returns columns
namespace VARCHAR
Namespace the attributes are listed for.
name VARCHAR
Search attribute name, as used in visibility queries.
type VARCHAR
Keyword, Text, Int, Double, Bool, Datetime or KeywordList.
is_custom BOOLEAN
true for attributes registered by users; false for Temporal's system attributes.
Example

Custom search attributes of the namespace

SELECT name, type
FROM temporal.main.search_attributes()
WHERE is_custom
ORDER BY name;
Link
task_queues (task_queue VARCHAR, namespace := VARCHAR) 1 example

Pollers and backlog of one task queue, one row for its workflow and one for its activity side

Positional arguments
task_queue VARCHAR
Task queue name, e.g. the TaskQueue of a workflow execution.
Named arguments
namespace := VARCHAR
Namespace; default the secret's NAMESPACE.
Returns columns
namespace VARCHAR
Namespace of the task queue.
task_queue VARCHAR
Task queue name.
task_queue_type VARCHAR
Workflow, Activity or Nexus.
poller_count INTEGER
Number of workers that polled recently.
pollers STRUCT of 3 fields[]
Recent pollers: worker identity, last access time and rate limit.
STRUCT[] 3 fields
  • identityVARCHAR
  • last_access_timeTIMESTAMP WITH TIME ZONE
  • rate_per_secondDOUBLE
approximate_backlog_count BIGINT
Approximate number of tasks waiting (NULL when the server does not report stats).
approximate_backlog_age_seconds DOUBLE
Age of the oldest waiting task, in seconds (NULL when not reported).
tasks_add_rate DOUBLE
Tasks added per second (NULL when not reported).
tasks_dispatch_rate DOUBLE
Tasks dispatched per second (NULL when not reported).
Example

Workers and backlog of one task queue

SELECT task_queue_type, poller_count, approximate_backlog_count
FROM temporal.main.task_queues('orders')
ORDER BY task_queue_type;
Link
workflow_executions (namespace := VARCHAR, query := VARCHAR, page_size := BIGINT) 2 examples

Workflow executions from the Temporal visibility store, with WHERE filters translated into a visibility query

Named arguments
namespace := VARCHAR
Namespace to list; default the secret's NAMESPACE.
query := VARCHAR
Extra Temporal visibility query ANDed with the pushed-down WHERE filters, e.g. 'CustomKeywordField STARTS_WITH ''ab'''.
page_size := BIGINT
Executions requested per page (1 to 1000); default 100 for the first page and 1000 after.
Returns columns
namespace VARCHAR
Namespace the execution belongs to.
workflow_id VARCHAR
Workflow id (unique per namespace among open workflows). Pushed down as WorkflowId.
run_id VARCHAR
Run id of this execution. Pushed down as RunId.
workflow_type VARCHAR
Workflow type name. Pushed down as WorkflowType.
status VARCHAR
Execution status: Running, Completed, Failed, Canceled, Terminated, ContinuedAsNew or TimedOut. Pushed down as ExecutionStatus.
start_time TIMESTAMP WITH TIME ZONE
When the execution was started. Range filters push down as StartTime.
execution_time TIMESTAMP WITH TIME ZONE
When the first workflow task was scheduled (later than start_time for delayed and cron starts). Pushed down as ExecutionTime.
close_time TIMESTAMP WITH TIME ZONE
When the execution closed; NULL while running. Pushed down as CloseTime.
execution_duration_seconds DOUBLE
Seconds from execution_time to close_time; NULL while running.
task_queue VARCHAR
Task queue the workflow runs on. Pushed down as TaskQueue.
history_length BIGINT
Number of events in the history. Pushed down as HistoryLength.
history_size_bytes BIGINT
History size in bytes. Pushed down as HistorySizeBytes.
state_transition_count BIGINT
Number of state transitions. Pushed down as StateTransitionCount.
parent_workflow_id VARCHAR
Parent workflow id for a child workflow, else NULL. Pushed down as ParentWorkflowId.
parent_run_id VARCHAR
Parent run id for a child workflow, else NULL. Pushed down as ParentRunId.
root_workflow_id VARCHAR
Workflow id at the root of the child-workflow tree. Pushed down as RootWorkflowId.
root_run_id VARCHAR
Run id at the root of the child-workflow tree. Pushed down as RootRunId.
first_run_id VARCHAR
First run id of the workflow chain (continue-as-new, retries, cron).
scheduled_by_id VARCHAR
Schedule id that started this run (TemporalScheduledById), else NULL. Pushed down.
memo JSON
Memo fields with payloads decoded to JSON.
search_attributes JSON
All search attributes (system and custom) with decoded values.
url VARCHAR
Link to the run in the Temporal Web UI (NULL when the UI URL is unknown; set UI_URL in the secret).
Examples (2)

Failed or timed-out runs per workflow type since January (filters run server-side)

SELECT workflow_type, count(*) AS failures
FROM temporal.main.workflow_executions()
WHERE status IN ('Failed', 'TimedOut') AND start_time >= TIMESTAMPTZ '2026-01-01'
GROUP BY workflow_type
ORDER BY failures DESC;

The oldest open workflows on one task queue

SELECT workflow_id, start_time
FROM temporal.main.workflow_executions()
WHERE status = 'Running' AND task_queue = 'orders'
ORDER BY start_time
LIMIT 20;
Link
workflow_history (workflow_id VARCHAR, run_id := VARCHAR, namespace := VARCHAR, page_size := BIGINT) 2 examples

The event history of one workflow run, one row per event

Positional arguments
workflow_id VARCHAR
Workflow id whose event history to read.
Named arguments
run_id := VARCHAR
Run id; default the latest run of the workflow id.
namespace := VARCHAR
Namespace; default the secret's NAMESPACE.
page_size := BIGINT
Events requested per page (1 to 1000); default 1000.
Returns columns
workflow_id VARCHAR
Workflow id whose history this is.
run_id VARCHAR
Run id whose history this is (the latest run when run_id was not given).
event_id BIGINT
Event id, 1-based and increasing through the history.
event_type VARCHAR
Event type without prefix, e.g. WorkflowExecutionStarted, ActivityTaskScheduled, TimerFired.
event_time TIMESTAMP WITH TIME ZONE
When the event was recorded.
task_id BIGINT
Internal task id of the event.
activity_id VARCHAR
Activity id (ActivityTaskScheduled and, via scheduled_event_id, its later events: only set on Scheduled events).
activity_type VARCHAR
Activity type name (ActivityTaskScheduled events).
scheduled_event_id BIGINT
Event id of the matching *Scheduled / *Initiated event, for started/completed/failed/timed-out events.
started_event_id BIGINT
Event id of the matching *Started event, for completed/failed/timed-out events.
attempt INTEGER
Attempt number (ActivityTaskStarted, WorkflowTaskStarted, WorkflowExecutionStarted).
timer_id VARCHAR
Timer id (TimerStarted, TimerFired, TimerCanceled).
child_workflow_id VARCHAR
Child workflow id (StartChildWorkflowExecutionInitiated and ChildWorkflowExecution* events).
child_workflow_type VARCHAR
Child workflow type (child workflow events).
child_run_id VARCHAR
Child run id (ChildWorkflowExecutionStarted and later child events).
signal_name VARCHAR
Signal name (WorkflowExecutionSignaled, SignalExternalWorkflowExecutionInitiated).
task_queue VARCHAR
Task queue named by the event (workflow start, activity scheduling).
identity VARCHAR
Identity of the worker or client that caused the event.
failure_message VARCHAR
Failure message of a failed / timed-out event (activity, workflow task, child or workflow failure).
attributes JSON
The event's full attributes as JSON (payloads decoded), as in Temporal's JSON history export.
Examples (2)

Walk the history of the latest run of one workflow

SELECT event_id, event_type, event_time, failure_message
FROM temporal.main.workflow_history('order-123')
ORDER BY event_id;

Each activity of a run with its final attempt and outcome

SELECT s.activity_type, st.attempt, c.event_type AS outcome
FROM temporal.main.workflow_history('order-123') s
JOIN temporal.main.workflow_history('order-123') c ON c.scheduled_event_id = s.event_id AND c.event_type LIKE 'ActivityTask%' AND c.event_type <> 'ActivityTaskStarted'
LEFT JOIN temporal.main.workflow_history('order-123') st ON st.scheduled_event_id = s.event_id AND st.event_type = 'ActivityTaskStarted'
WHERE s.event_type = 'ActivityTaskScheduled'
ORDER BY s.event_id;
Link
unified 2 tables

runs and task_runs in the shape shared by every orchestrator worker.

Schema examples (2)
Examples (2)

Failure counts per workflow type in the shared shape

SELECT pipeline, count(*) FILTER (WHERE status = 'failed') AS failures,
  count(*) AS runs
FROM temporal.unified.runs
WHERE queued_at >= TIMESTAMPTZ '2026-01-01'
GROUP BY pipeline
ORDER BY failures DESC;

Activities of recent failed runs, most-retried first

SELECT t.task_name, t.attempt, t.status
FROM temporal.unified.task_runs t
WHERE t.run_id IN (SELECT run_id FROM temporal.unified.runs WHERE status = 'failed' AND queued_at >= TIMESTAMPTZ '2026-01-01')
ORDER BY t.attempt DESC;
Tables
runs 1 example11 cols

Temporal workflow runs in the cross-orchestrator runs shape

Columns
orchestrator VARCHAR
Always 'temporal'.
run_idnot null VARCHAR
Temporal run id (unique per execution).
pipeline VARCHAR
Workflow type name.
status VARCHAR
queued, running, success, failed, cancelled or skipped (Completed and ContinuedAsNew are success; Failed, TimedOut and Terminated are failed).
raw_status VARCHAR
Temporal execution status: Running, Completed, Failed, Canceled, Terminated, ContinuedAsNew or TimedOut.
trigger VARCHAR
schedule (started by a Temporal schedule), other (child workflow or continue-as-new/retry/cron chain), or api (started by a client).
queued_at TIMESTAMP WITH TIME ZONE
When the execution was created (StartTime).
started_at TIMESTAMP WITH TIME ZONE
When its first workflow task was scheduled (ExecutionTime; later than queued_at for delayed and cron starts).
ended_at TIMESTAMP WITH TIME ZONE
When the execution closed; NULL while running.
duration_seconds DOUBLE
Seconds from started_at to ended_at; NULL while running.
url VARCHAR
Link to the run in the Temporal Web UI (NULL when unknown; set UI_URL in the secret).
ConstraintsPRIMARY KEY (run_id)
Example

Failure counts per workflow type in the shared shape

SELECT pipeline, count(*) FILTER (WHERE status = 'failed') AS failures,
  count(*) AS runs
FROM temporal.unified.runs
WHERE queued_at >= TIMESTAMPTZ '2026-01-01'
GROUP BY pipeline
ORDER BY failures DESC;
Link
task_runs 1 example11 cols

Temporal activity executions in the cross-orchestrator task_runs shape, derived from event histories

Columns
orchestrator VARCHAR
Always 'temporal'.
run_id VARCHAR
Run id of the workflow execution the activity belongs to.
task_run_idnot null VARCHAR
'<run_id>:<event id of ActivityTaskScheduled>', unique per activity execution.
task_name VARCHAR
Activity type name.
status VARCHAR
queued, running, success, failed or cancelled.
raw_status VARCHAR
Completed, Failed, TimedOut or Canceled for finished activities; the pending state (Scheduled, Started, CancelRequested, Paused) for open ones; Unfinished when the workflow closed first.
attempt INTEGER
Attempt number of the last (or current) try; Temporal retries inside one activity execution.
started_at TIMESTAMP WITH TIME ZONE
When the last attempt started.
ended_at TIMESTAMP WITH TIME ZONE
When the activity completed, failed, timed out or was canceled.
duration_seconds DOUBLE
Seconds from started_at to ended_at (the last attempt).
url VARCHAR
Link to the workflow run in the Temporal Web UI.
ConstraintsPRIMARY KEY (task_run_id) · FOREIGN KEY (run_id) REFERENCES runs(run_id)
Example

Activities of recent failed runs, most-retried first

SELECT t.task_name, t.attempt, t.status
FROM temporal.unified.task_runs t
WHERE t.run_id IN (SELECT run_id FROM temporal.unified.runs WHERE status = 'failed' AND queued_at >= TIMESTAMPTZ '2026-01-01')
ORDER BY t.attempt DESC;
Link

Credentials

The secret type temporal declares, as reported by the worker itself.

temporal

How to get these credentials

Temporal frontend address, namespace and credentials: an API key (Temporal Cloud), mTLS client certificates, or none for a local dev server.

secret.sql
CREATE SECRET temporal (
    TYPE temporal,
    host        '<host>',
    namespace   '<namespace>',
    api_key     '<TEMPORAL_API_KEY>',  -- secret
    tls         '<tls>',
    ca_cert     '<ca_cert>',
    client_cert '<client_cert>',
    client_key  '<CLIENT_KEY>',  -- secret
    server_name '<server_name>',
    ui_url      '<ui_url>'
);
Key Type Required Description
host VARCHAR — Frontend gRPC address host:port, e.g. my-ns.a1b2c.tmprl.cloud:7233 or <region>.<cloud>.api.temporal.io:7233 (Temporal Cloud) or temporal.internal:7233. Default 127.0.0.1:7233.
namespace VARCHAR — Namespace queried by default, e.g. my-ns.a1b2c on Temporal Cloud. Default 'default'.
api_key secret VARCHAR — Temporal Cloud API key, sent as 'Authorization: Bearer <key>'. Turns TLS on unless TLS is 'false'.
tls VARCHAR — 'true' to connect with TLS (default 'false', or 'true' when API_KEY or CLIENT_CERT is set).
ca_cert VARCHAR — PEM CA bundle that signed the server certificate; default the system roots.
client_cert VARCHAR — PEM client certificate for mTLS (Temporal Cloud mTLS namespaces, self-hosted mTLS).
client_key secret VARCHAR — PEM private key of CLIENT_CERT.
server_name VARCHAR — TLS server name to verify, when it differs from the HOST name.
ui_url VARCHAR — Base URL of the Temporal Web UI used for the url columns, e.g. https://cloud.temporal.io or http://localhost:8233. Default: derived from HOST for Temporal Cloud and local dev servers, otherwise none.

The worker doesn't mark which keys are required.

Needed by batch_operationscount_workflow_executionspending_activitiesschedulessearch_attributestask_queuesworkflow_executionsworkflow_history

Create the secret in the same session, after attaching temporal — the worker registers its secret types at ATTACH. Keys marked secret are masked in duckdb_secrets(); angle-bracket values are placeholders. Read credentials from your environment or secret store in your application and pass them through your SQL client’s parameter bindings. Keep real values out of saved SQL and history. Native DuckDB and Haybarn do not provide a SQL getenv() function.

Try these queries

Failed or timed-out runs per workflow type since January (filters run server-side)

SELECT workflow_type, count(*) AS failures
FROM temporal.main.workflow_executions()
WHERE status IN ('Failed', 'TimedOut') AND start_time >= TIMESTAMPTZ '2026-01-01'
GROUP BY workflow_type
ORDER BY failures DESC

Uses workflow_executions

How many executions are in each status

SELECT status, count
FROM temporal.main.count_workflow_executions()
ORDER BY count DESC

Uses count_workflow_executions

Walk the history of the latest run of one workflow

SELECT event_id, event_type, event_time, failure_message
FROM temporal.main.workflow_history('order-123')
ORDER BY event_id

Uses workflow_history

Why is this workflow stuck?

SELECT activity_type, state, attempt, last_failure_message
FROM temporal.main.pending_activities('order-123')
ORDER BY attempt DESC

Uses pending_activities

Every schedule with its next run

SELECT schedule_id, workflow_type, paused, next_action_times[1] AS next_run
FROM temporal.main.schedules()
ORDER BY schedule_id

Uses schedules

Workers and backlog of one task queue

SELECT task_queue_type, poller_count, approximate_backlog_count
FROM temporal.main.task_queues('orders')
ORDER BY task_queue_type

Uses task_queues

10 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • Using the Temporal worker, which workflow ids in the default namespace failed? List them alphabetically.
  • How many Temporal workflow executions are there in each execution status?
  • Which activity type in workflow order-retry-1 needed more than one attempt, and how many attempts did it take?
  • How many workflow executions have the custom search attribute CustomerTier set to 'gold'?
  • Which activity is still pending in the running workflow order-running-1, and what was its last failure message?
  • In the cross-orchestrator unified shape, how many Temporal runs failed and how many succeeded?

Temporal is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.