TASK

Config path: /<database>/<schema>/task/<name>.yaml

Example:

body: |-
  CALL test_procedure_1(1)

schedule: 5 MINUTE
warehouse: task_wh
body: |-
  CALL test_procedure_1(2)

after:
  - test_task_1
warehouse: task_wh

Schema

  • body (str) - SQL statement to be executed by task

  • schedule (str) - schedule for period running tasks

  • after (list)

    • {items} (ident) - one or more predecessor tasks for the current task

  • finalize (str) - name of root task associated with finalizer (this task)

  • when (str) - SQL expression returning BOOLEAN

  • warehouse (ident) - warehouse used to execute task

  • user_task_managed_initial_warehouse_size (str) - initial warehouse size for serverless task execution

  • config (str) - Specifies a string representation of key value pairs that can be accessed by all tasks in the DAG, must be in JSON format

  • allow_overlapping_execution (bool) - allow multiple instances of the task tree to run concurrently

  • session_params (dict)

    • {key} (ident) - session parameter name

    • {value} (bool, float, int, str) - session parameter value

  • user_task_timeout_ms (int) - time limit on a single run of the task before it times out

  • suspend_task_after_num_failures (int) - number of consecutive failed task runs after which the current task is suspended automatically

  • error_integration (ident) - notification integration to monitor pipe errors

  • task_auto_retry_attempts (int)

  • user_task_minimum_trigger_interval_in_seconds (int)

  • comment (str)

Usage notes

  1. SnowDDL only creates tasks. Tasks are initially suspended. You should execute ALTER TASK ... RESUME via different means to enable execution.

  2. Tasks should be suspended via ALTER TASK ... SUSPEND before they can be altered by SnowDDL. Tasks are not suspended automatically.

  3. Task is executed with privileges of task owner, which is schema_owner role. It will have full access to all objects in the same schema, but no access to objects in other schemas. This behaviour may improve in future.

  4. Notification integration mentioned in error_integration parameter must be additionally specified in schema parameter owner_integration_usage. Otherwise schema owner role will not be able to send notifications.

Additional privileges

In order for TASK objects to operate properly, the following additional grants should be added to OWNER role in schema config:

  • owner_warehouse_usage - list warehouses used to execute tasks

  • owner_integration_usage - if your tasks require integration objects to operate (e.g. via PROCEDURE), add names of integrations here

  • owner_account_grants - Snowflake requires EXECUTE TASK privilege to run tasks

Last updated