- Schema:
TASK_HISTORY View¶
This Account Usage view enables you to retrieve the history of task usage within the last 365 days (1 year). The view displays one row for each run of a task in the history.
Columns¶
Column Name |
Data Type |
Description |
---|---|---|
NAME |
TEXT |
Name of the task. |
QUERY_TEXT |
TEXT |
Text of the SQL statement. |
CONDITION_TEXT |
TEXT |
Text of WHEN condition the task evaluates when determining whether to run. |
SCHEMA_NAME |
TEXT |
Name of the schema that contains the task. |
TASK_SCHEMA_ID |
NUMBER |
Internal/system-generated identifier for the schema that contains the task. |
DATABASE_NAME |
TEXT |
Name of the database that contains the task. |
TASK_DATABASE_ID |
NUMBER |
Internal/system-generated identifier for the database that contains the task. |
SCHEDULED_TIME |
TIMESTAMP_LTZ |
Time when the task is/was scheduled to start running. Note that we make a best effort to ensure absolute precision, but only guarantee that tasks do not execute before the scheduled time. |
COMPLETED_TIME |
TIMESTAMP_LTZ |
Time when the task completed. |
STATE |
TEXT |
Status of the completed task: SUCCEEDED, FAILED, CANCELLED, or SKIPPED. Note that the view does not return SCHEDULED or EXECUTING task runs. To retrieve the task history details for runs in a scheduled or executing state, query the TASK_HISTORY table function in the Information Schema. |
RETURN_VALUE |
TEXT |
Value set for the predecessor task in a DAG of tasks. The return value is explicitly set by calling the SYSTEM$SET_RETURN_VALUE function by the predecessor task. |
QUERY_ID |
TEXT |
ID of the SQL statement executed by the task. Can be joined with the QUERY_HISTORY view for additional details about the execution of the statement or stored procedure. |
QUERY_START_TIME |
TIMESTAMP_LTZ |
Time when the query in the task definition started to run. This timestamp aligns with the start time for the query returned by QUERY_HISTORY. |
ERROR_CODE |
NUMBER |
Error code, if the statement returned an error. |
ERROR_MESSAGE |
TEXT |
Error message, if the statement returned an error. |
GRAPH_VERSION |
NUMBER |
Integer identifying the version of the DAG that was run, or is scheduled to be run. Each incremental increase in the value represents one or more modifications to tasks in the DAG. If the root task is recreated (using CREATE OR REPLACE TASK), then the version number restarts from 1. |
RUN_ID |
NUMBER |
Time when the standalone or root task in a DAG is/was originally scheduled to start running. Format is epoch time (in milliseconds). The combination of the ROOT_TASK_ID and RUN_ID values identifies a specific run of a DAG. . Original scheduled time refers to rare instances when the system may reschedule the same task to run at a different time to retry it or rebalance the load. If that happens, RUN_ID shows the original scheduled run time and SCHEDULED_TIME shows the rescheduled run time. |
ROOT_TASK_ID |
TEXT |
Unique identifier for the root task in a DAG. This ID matches the ID column value in the SHOW TASKS output for the same task. |
SCHEDULED_FROM |
TEXT |
Mechanism that prompted the task run: SCHEDULE indicates that the task run was initiated by the schedule in the task definition. EXECUTE TASK indicates that the task run was initiated by an EXECUTE TASK statement execution. For runs of child tasks in a DAG, the column returns the same value as the root task run. |
Usage Notes¶
Latency for the view may be up to 45 minutes.
For increased performance, filter queries on the COMPLETED_TIME or SCHEDULED_TIME column. See the Examples section (in this topic).
Examples¶
Retrieve records for the 10 most recent completed task runs:
SELECT query_text, completed_time FROM snowflake.account_usage.task_history LIMIT 10;
Retrieve records for task runs completed in the past hour:
SELECT query_text, completed_time FROM snowflake.account_usage.task_history WHERE COMPLETED_TIME > DATEADD(hours, -1, CURRENT_TIMESTAMP());