SYSTEM$TASK_COMPLETION_STATE

functionsupportedUDFs, procedures, tasks, alerts, scriptingpreview

docs.snowflake.com ↗

System functions

Returns the state that a specified task in the current task graph run completed in. Use this function in the WHEN clause of a task to branch on the outcome of a specific task rather than on the outcome of all of the current task’s predecessors. To evaluate the states of all of the current task’s predecessors at once, use SYSTEM$PREDECESSORS_STATE.

Syntax

SYSTEM$TASK_COMPLETION_STATE('<task_name>')

Parameters

NameRequiredDescription
'task_name'requiredIdentifier for the task whose completion state you want to retrieve. The task name only, without the database name or schema name. All tasks in a task graph must be in the same schema, so there’s no need to reference a task in a different schema. For example, use MYTASK rather than MYDATABASE.MYSCHEMA.MYTASK. The task must be in the same task graph as the task that calls the function. If the task isn’t in the graph, the call fails. For a deterministic result, the task must be a direct or indirect predecessor of the calling task. For details, see Task ordering and determinism.

Returns

Returns one of the following states. Except for NOT_EXECUTED, these states match the STATE values that the TASK_HISTORY view view reports for a completed task run:

Usage notes