tasks
Creates, updates, deletes, gets or lists a tasks
resource.
Overview
Name | tasks |
Type | Resource |
Id | snowflake.task.tasks |
Fields
Name | Datatype | Description |
---|---|---|
id | string | An ID for the current task. |
name | string | A Snowflake object identifier. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive. |
allow_overlapping_execution | boolean | Specifies whether to allow multiple instances of the DAG to run concurrently. |
comment | string | Specifies a comment for the task. |
condition | string | Specifies a Boolean SQL expression condition; multiple conditions joined with AND/OR are supported |
config | object | Task Config |
created_on | string | The time the task was created on. |
database_name | string | The name of the parent database for the task. |
definition | string | The SQL definition for the task. Any one of single SQL statement, call to stored procedure, or procedural logic using Snowflake scripting. |
error_integration | string | Specifies the name of the notification integration used to communicate with Amazon SNS, MS Azure Event Grid, or Google Pub/Sub. |
finalize | string | Specifies the name of the root task that the finalizer task is associated with. |
last_committed_on | string | The time the task was last committed on. |
last_suspended_on | string | The time the task was last suspended on. |
owner | string | The role that owns the task. |
owner_role_type | string | The role type of the task owner. |
predecessors | array | Specifies one or more predecessor tasks for the current task |
schedule | object | Specifies the schedule for periodically running the task. |
schema_name | string | The name of the parent schema for the task. |
serverless_task_max_statement_size | string | Specifies the maximum allowed warehouse size for the serverless task. Minimum XSMALL, Maximum XXLARGE. This parameter only applies to serverless tasks. |
serverless_task_min_statement_size | string | Specifies the minimum allowed warehouse size for the serverless task. Minimum XSMALL, Maximum XXLARGE. This parameter only applies to serverless tasks. |
session_parameters | object | Session Parameters for the task at runtime. |
state | string | The state of the task. Must be one of started or suspended. |
suspend_task_after_num_failures | integer | Specifies the number of consecutive failed task runs after which the current task is suspended automatically. |
target_completion_interval | object | A schedule for executing a task at specified intervals of minutes. |
task_auto_retry_attempts | integer | Root task settable only. Specifies the number of automatic task graph retry attempts. Valid range is 0 to 30. When not specified, no retry would happen. |
task_relations | string | Displays the relationship between the root task and its corresponding finalizer tasks. |
user_task_managed_initial_warehouse_size | string | Specifies the size of the compute resources to provision for the first run of the task. This parameter only applies to serverless tasks. |
user_task_timeout_ms | integer | Specifies the time limit on a single run of the task before it times out (in milliseconds). |
warehouse | string | A Snowflake object identifier. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive. |
Methods
Name | Accessible by | Required Params | Description |
---|---|---|---|
fetch_task | SELECT | database_name, name, schema_name, endpoint | Fetch a task using the describe command output. |
list_tasks | SELECT | database_name, schema_name, endpoint | Lists tasks under the database and schema, with show options as query parameters. |
create_task | INSERT | database_name, schema_name, data__definition, data__name, endpoint | Create a task, with standard create modifiers as query parameters. See the Task component definition for what is required to be provided in the request body. |
delete_task | DELETE | database_name, name, schema_name, endpoint | Delete a task with the task name. If ifExists is used, the operation will succeed even if the object does not exist. Otherwise, there will be a failure if the drop is unsuccessful. |
create_or_alter_task | REPLACE | database_name, name, schema_name, data__definition, data__name, endpoint | Create a (or alter an existing) task. Even if the operation is just an alter, the full property set must be provided. |
execute_task | EXEC | database_name, name, schema_name, endpoint | Execute a task -- this is equivalent to EXECUTE IMMEDIATE. |
resume_task | EXEC | database_name, name, schema_name, endpoint | Resumes a suspended task object. This is equivalento an ALTER TASK ... RESUME. |
suspend_task | EXEC | database_name, name, schema_name, endpoint | Suspends a running task. This is equivalent to an ALTER TASK ... SUSPEND. |
SELECT
examples
Lists tasks under the database and schema, with show options as query parameters.
SELECT
id,
name,
allow_overlapping_execution,
comment,
condition,
config,
created_on,
database_name,
definition,
error_integration,
finalize,
last_committed_on,
last_suspended_on,
owner,
owner_role_type,
predecessors,
schedule,
schema_name,
serverless_task_max_statement_size,
serverless_task_min_statement_size,
session_parameters,
state,
suspend_task_after_num_failures,
target_completion_interval,
task_auto_retry_attempts,
task_relations,
user_task_managed_initial_warehouse_size,
user_task_timeout_ms,
warehouse
FROM snowflake.task.tasks
WHERE database_name = '{{ database_name }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';
INSERT
example
Use the following StackQL query and manifest file to create a new tasks
resource.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO snowflake.task.tasks (
data__name,
data__warehouse,
data__schedule,
data__comment,
data__finalize,
data__task_auto_retry_attempts,
data__config,
data__session_parameters,
data__definition,
data__predecessors,
data__user_task_managed_initial_warehouse_size,
data__target_completion_interval,
data__serverless_task_min_statement_size,
data__serverless_task_max_statement_size,
data__user_task_timeout_ms,
data__suspend_task_after_num_failures,
data__condition,
data__allow_overlapping_execution,
data__error_integration,
database_name,
schema_name,
endpoint
)
SELECT
'{{ name }}',
'{{ warehouse }}',
'{{ schedule }}',
'{{ comment }}',
'{{ finalize }}',
'{{ task_auto_retry_attempts }}',
'{{ config }}',
'{{ session_parameters }}',
'{{ definition }}',
'{{ predecessors }}',
'{{ user_task_managed_initial_warehouse_size }}',
'{{ target_completion_interval }}',
'{{ serverless_task_min_statement_size }}',
'{{ serverless_task_max_statement_size }}',
'{{ user_task_timeout_ms }}',
'{{ suspend_task_after_num_failures }}',
'{{ condition }}',
'{{ allow_overlapping_execution }}',
'{{ error_integration }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}'
;
/*+ create */
INSERT INTO snowflake.task.tasks (
data__name,
data__definition,
database_name,
schema_name,
endpoint
)
SELECT
'{{ name }}',
'{{ definition }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}'
;
- name: tasks
props:
- name: database_name
value: string
- name: schema_name
value: string
- name: data__definition
value: string
- name: data__name
value: string
- name: endpoint
value: string
- name: name
value: string
- name: warehouse
value: string
- name: schedule
props:
- name: schedule_type
value: string
- name: comment
value: string
- name: finalize
value: string
- name: task_auto_retry_attempts
value: integer
- name: config
value: object
- name: session_parameters
value: object
- name: definition
value: string
- name: predecessors
value: array
- name: user_task_managed_initial_warehouse_size
value: string
- name: target_completion_interval
props:
- name: schedule_type
value: string
- name: serverless_task_min_statement_size
value: string
- name: serverless_task_max_statement_size
value: string
- name: user_task_timeout_ms
value: integer
- name: suspend_task_after_num_failures
value: integer
- name: condition
value: string
- name: allow_overlapping_execution
value: boolean
- name: error_integration
value: string
REPLACE
example
Replaces all fields in the specified tasks
resource.
/*+ update */
REPLACE snowflake.task.tasks
SET
name = '{{ name }}',
warehouse = '{{ warehouse }}',
schedule = '{{ schedule }}',
comment = '{{ comment }}',
finalize = '{{ finalize }}',
task_auto_retry_attempts = '{{ task_auto_retry_attempts }}',
config = '{{ config }}',
session_parameters = '{{ session_parameters }}',
definition = '{{ definition }}',
predecessors = '{{ predecessors }}',
user_task_managed_initial_warehouse_size = '{{ user_task_managed_initial_warehouse_size }}',
target_completion_interval = '{{ target_completion_interval }}',
serverless_task_min_statement_size = '{{ serverless_task_min_statement_size }}',
serverless_task_max_statement_size = '{{ serverless_task_max_statement_size }}',
user_task_timeout_ms = '{{ user_task_timeout_ms }}',
suspend_task_after_num_failures = '{{ suspend_task_after_num_failures }}',
condition = '{{ condition }}',
allow_overlapping_execution = true|false,
error_integration = '{{ error_integration }}'
WHERE
database_name = '{{ database_name }}'
AND name = '{{ name }}'
AND schema_name = '{{ schema_name }}'
AND data__definition = '{{ data__definition }}'
AND data__name = '{{ data__name }}'
AND endpoint = '{{ endpoint }}';
DELETE
example
Deletes the specified tasks
resource.
/*+ delete */
DELETE FROM snowflake.task.tasks
WHERE database_name = '{{ database_name }}'
AND name = '{{ name }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';