TASK_HISTORY() is an INFORMATION_SCHEMA table function for inspecting task executions. Query it after a manual run or while a schedule is active to see execution code, state, errors, return values, and scheduling and completion timestamps. section 2.5 section 13.6
Listing 2.4 Viewing previous and scheduled task executions
select * from table(information_schema.task_history()) order by scheduled_time desc;
Use the table function in a FROM TABLE clause and order by scheduled time to review the newest scheduled and prior executions first. section 2.5
A history row identifies the task and its database and schema, then records QUERY_ID, QUERY_TEXT, STATE, ERROR_CODE, ERROR_MESSAGE, SCHEDULED_TIME, QUERY_START_TIME, NEXT_SCHEDULED_TIME, and COMPLETED_TIME. A SUCCEEDED state confirms completion; a FAILED state directs attention to the error fields and task body. section 2.5 section 13.5
Use task history as part of a repeatable pipeline check:
- Run a new or changed task manually with EXECUTE TASK, then inspect its progress and completion state before enabling its recurring schedule. section 13.6
- For a failed task, read the error message, validate the task definition body, correct errors, and rerun the task manually. section 13.5
- For a task that did not run, check history for its next scheduled execution or a predecessor’s status; also verify suspension, dependencies, overlapping runs, and available stream data. section 13.5
Checking an order-processing task
After executing PROCESS_ORDERS, its history can show the executed SQL block and a SUCCEEDED or FAILED state, together with start, completion, and next scheduled times. This makes the function useful for confirming that scheduled file loads and downstream processing are actually occurring. section 2.5
