liveBook · Manning

TASK_HISTORY()

As explained in Snowflake Data Engineering

TASK_HISTORY() is a Snowflake table function that returns details about current, scheduled, and completed task executions.

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

How Snowflake Data Engineering covers it

How deep it goes
Explains a runnable history query and output fields, then applies states, errors, predecessors, and next schedules to troubleshooting.
Examples
Uses PROCESS_ORDERS to show executed SQL, status, errors, and scheduled, start, completion, and next-run timestamps.
What it assumes
Assumes a created Snowflake task and teaches history inspection after manual execution or scheduled operation.
What you can do after
Diagnose/debug with TASK_HISTORY() by confirming executions, reading failures, and investigating missing or skipped task runs.
How it connects
Connects task execution to INFORMATION_SCHEMA, EXECUTE TASK, task graphs, streams, SYSTEM$STREAM_HAS_DATA, and Snowsight.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Snowflake Data Engineering. The section links point to the parts of the book it draws on.