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. The major difference is in how you define Snowflake objects in the configuration file. Rather than having a grouped collection of objects, SOLE for Data Products goes for modular, self-describing, and explicit object definition.
Learn more about SOLE for Data Products, currently available as a public preview.

We have also introduced Data products as an extra layer on top of the data product platform capabilities making managing data products easier than ever. Learn more about Data Products, 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
ALL PRIVILEGES handling

When you define ALL PRIVILEGES in the SOLE configuration file, you grant all the privileges listed above to roles on this object except OWNERSHIP. However, the management of ALL PRIVILEGES in SOLE differs from its handling in Snowflake. See Handling ALL PRIVILEGES in SOLE for more information.

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