Skip to main content

Task

You can provide configuration to Snowflake Object Lifecycle Engine for the following operation with task:

  • Manage the lifecycle of new and existing tasks

Usage

note

We have introduced SOLE for Data Products as a new framework for SOLE to help you easily build an ecosystem of data products. Learn more about SOLE for Data Products which is currently available as a private preview.

databases:
<database-name>:
schemas:
<schema-name>:
tasks:
<task-name>:
<configuration-key>: <value>

Supported parameters

The engine supports the parameters listed below.

Configuration KeyRequired/OptionalData Types and ValuesDescription
sql_statementRequiredStringAny single SQL statement, or a call to a stored procedure, executed when the task runs
warehouseRequiredStringSpecifies the virtual warehouse that is used to execute the task
afterOptionalString/Object: See here for a definition of afterSpecifies the predecessor task for the current task. When a run of the predecessor task finishes successfully, it triggers this task after a brief lag.
commentOptionalStringSpecifies a comment for the task
deletedOptionalBoolean: True enables deletion prevention, False does nothingSpecifies what objects are allowed to be deleted
enabledOptionalBooleanSpecifies if the task should be started (enabled) after creation or should remain suspended (default)
grantsOptionalMap: See Supported Task Grants to RolesList of Privileges and Roles to which privileges are granted on the current task
manage_modeOptionalString: all (default), none, grantsConfigures what properties to manage for the task.
See Changing Manage Mode before changing the value.
scheduleOptionalStringSpecifies the schedule for periodically running the task. This can be a cron or interval in minutes
session_parametersOptionalMap of StringSpecifies session parameters to set for the session when the task runs. A task supports all session parameters.
user_task_managed_initial_warehouse_sizeOptionalStringSpecifies the size of the compute resources to allocate for the first run of the task, before a task history is available for Snowflake to determine an ideal size. Once a task has successfully completed a few runs, Snowflake ignores this parameter setting.
user_task_timeout_msOptionalNumberSpecifies the time limit on a single run of the task before it times out (in milliseconds)
whenOptionalStringSpecifies a Boolean SQL expression, multiple conditions joined with AND/OR are supported

after parameter

The after parameter supports the following parameters if explicitly provided:

Configuration KeyRequired/OptionalData Types and ValuesDescription
nameRequiredStringName of the task
databaseRequired - if the task is present in another databaseStringName of the database in which the task exists
schemaRequired - if the task is present in another database or another schemaStringName of the schema in which the task exists

Users can specify a task name in two ways:

  • as the value of the after key
  • in the name sub-key if the task is present in another database or another schema

See Database-Level Object Reference section for more information.

after: "mytask_minute"

Supported task grants to roles

Following are the privileges you can grant to roles in the task definition:

  • ALL PRIVILEGES
  • MONITOR
  • OPERATE
  • OWNERSHIP

Examples

databases:
PRODUCTS_RECORD:
schemas:
PRODUCTS:
tasks:
TASK_1:
sql_statement: "<sql_statement>"
warehouse: "<warehouse_name>"
comment: "<task_comment>"
after:
database: "DUMMY_DATABASE"
schema: "PUBLIC"
name: "mytask_minute"
enabled: "true|false"
schedule: "10 MINUTES"
session_parameters:
timestamp_output_format: "DD-MM-YYYY HH24:MI:SS.FF3 TZHTZM"
user_task_timeout_ms: 10000
when: "SYSTEM$STREAM_HAS_DATA('MYSTREAM')"
grants:
MONITOR:
- ANALYST