CREATE TASK
statementsupportedUDFs, procedures, tasks, alerts, scriptingCreates a new task in the current/specified schema or replaces an existing task. This command supports the following variants: - CREATE OR ALTER TASK: Creates a task if it doesn’t exist or alters an existing task. - DEFINE TASK: Declarative definition of a task, including its desired state, inside a DCM project. - CREATE TASK … CLONE: Creates a clone of an existing task. Important Newly created or cloned tasks are created suspended. For information about running suspended tasks, see ALTER TASK … RESUME or EXECUTE TASK.
Syntax
supportedpartialnot supportednot scored
CREATE [ OR REPLACE ] TASK [ IF NOT EXISTS ] <name>
[ WITH TAG ( <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' , ... ] ) ]
[ WITH CONTACT ( <purpose> = <contact_name> [ , <purpose> = <contact_name> ... ] ) ]
[ { WAREHOUSE = <string> }
| { USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE = <string> } ]
[ SCHEDULE = { '<num> { HOURS | MINUTES | SECONDS }'
| 'USING CRON <expr> <time_zone>' } ]
[ CONFIG = <configuration_string> ]
[ OVERLAP_POLICY = { NO_OVERLAP | ALLOW_CHILD_OVERLAP | ALLOW_ALL_OVERLAP } ]
[ <session_parameter> = <value>
[ , <session_parameter> = <value> ... ] ]
[ USER_TASK_TIMEOUT_MS = <num> ]
[ SUSPEND_TASK_AFTER_NUM_FAILURES = <num> ]
[ ERROR_INTEGRATION = <integration_name> ]
[ SUCCESS_INTEGRATION = <integration_name> ]
[ LOG_LEVEL = '<log_level>' ]
[ COMMENT = '<string_literal>' ]
[ FINALIZE = <string> ]
[ TASK_AUTO_RETRY_ATTEMPTS = <num> ]
[ USER_TASK_MINIMUM_TRIGGER_INTERVAL_IN_SECONDS = <num> ]
[ TARGET_COMPLETION_INTERVAL = '<num> { HOURS | MINUTES | SECONDS }' ]
[ SERVERLESS_TASK_MIN_STATEMENT_SIZE = '{ XSMALL | SMALL
| MEDIUM | LARGE | XLARGE | XXLARGE }' ]
[ SERVERLESS_TASK_MAX_STATEMENT_SIZE = '{ XSMALL | SMALL
| MEDIUM | LARGE | XLARGE | XXLARGE }' ]
[ AFTER <string> [ , <string> , ... ] ]
[ EXECUTE AS USER <user_name> ]
[ WHEN <boolean_expr> ]
AS
<sql>
For more information, see CREATE OR ALTER TASK usage notes and CREATE OR ALTER <object>.
CREATE OR ALTER TASK <name>
[ { WAREHOUSE = <string> }
| { USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE = <string> } ]
[ SCHEDULE = { '<num> { HOURS | MINUTES | SECONDS }'
| 'USING CRON <expr> <time_zone>' } ]
[ CONFIG = <configuration_string> ]
[ OVERLAP_POLICY = { NO_OVERLAP | ALLOW_CHILD_OVERLAP | ALLOW_ALL_OVERLAP } ]
[ USER_TASK_TIMEOUT_MS = <num> ]
[ <session_parameter> = <value>
[ , <session_parameter> = <value> ... ] ]
[ SUSPEND_TASK_AFTER_NUM_FAILURES = <num> ]
[ ERROR_INTEGRATION = <integration_name> ]
[ SUCCESS_INTEGRATION = <integration_name> ]
[ COMMENT = '<string_literal>' ]
[ FINALIZE = <string> ]
[ TASK_AUTO_RETRY_ATTEMPTS = <num> ]
[ AFTER <string> [ , <string> , ... ] ]
[ EXECUTE AS USER <user_name> ]
[ WHEN <boolean_expr> ]
AS
<sql>
DEFINE TASK also accepts a STARTED or SUSPENDED desired state keyword that isn’t part of CREATE OR ALTER TASK syntax. Place the keyword immediately before AS
DEFINE TASK MY_DB.MY_SCHEMA.TSK_INGEST_DAILY_ORDERS
WAREHOUSE = 'MY_WH'
SCHEDULE = 'USING CRON 0 5 * * * UTC'
STARTED
AS
SELECT 1
;
Creates a new task with the same parameter values
CREATE [ OR REPLACE ] TASK <name> CLONE <source_task>
[ ... ]
Parameters
| Name | Required | Description |
|---|---|---|
name | required | String that specifies the identifier for the task; must be unique for the schema in which the task is created. In addition, the identifier must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes, such as "My object". Identifiers enclosed in double quotes are also case-sensitive. For more details, see Identifier requirements. |
sql | required | Any one of the following: Single SQL statement Call to a stored procedure Procedural logic using Snowflake Scripting The SQL code is executed when the task runs. Verify that the sql executes as expected before using it in a task. |
WAREHOUSE = string | optional | Specifies the virtual warehouse that provides compute resources for task runs. Omit this parameter to use serverless compute resources for runs of this task. Snowflake automatically resizes and scales serverless compute resources as required for each workload. When a schedule is specified for a task, Snowflake adjusts the resource size to complete future runs of the task within the specified time frame. To specify the initial warehouse size for the task, set the USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE = string parameter. |
USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE = string | optional | Applied only to serverless tasks. Specifies the size of the compute resources to provision 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. Note that if the task history is unavailable for a given task, the compute resources revert to this initial size. Note If a WAREHOUSE = string parameter value is specified, then setting this parameter produces a user error. The size is equivalent to the compute resources available when creating a warehouse (using CREATE WAREHOUSE), such as SMALL, MEDIUM, or LARGE. The largest size supported by the parameter is XXLARGE. If the parameter is omitted, the first runs of the task are executed using a medium-sized (MEDIUM) warehouse. You can change the initial size (using ALTER TASK) after the task is created but before it has run successfully once. Changing the parameter after the first run of this task starts has no effect on the compute resources for current or future task runs. Note that suspending and resuming a task doesn’t remove the task history used to size the compute resources. The task history is only removed if the task is recreated (using the CREATE OR REPLACE TASK syntax). For more information about this parameter, see USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE. |
SCHEDULE = ... | optional | Specifies the schedule for periodically running the task: Note For Triggered tasks, a schedule is not required. For other tasks, a schedule must be defined for a standalone task or the root task in a task graph; otherwise, the task only runs if manually executed using EXECUTE TASK. A schedule cannot be specified for child tasks in a task graph. 'expr': The cron expression consists of the following fields: Copy code # __________ minute (0-59) # | ________ hour (0-23) # | | ______ day of month (1-31, or L) # | | | ____ month (1-12, JAN-DEC) # | | | | __ day of week (0-6, SUN-SAT, or L) # | | | | | # | | | | | * * * * * |
'USING CRON expr time_zone' | Specifies a cron expression and time zone for periodically running the task. Supports a subset of standard cron utility syntax. | |
OVERLAP_POLICY = { NO_OVERLAP | ALLOW_CHILD_OVERLAP | ALLOW_ALL_OVERLAP } | optional | Specifies the overlap policy for task graph runs, controlling whether multiple instances of the task graph can run concurrently and the level of parallelism allowed. Note You can only set this parameter on a root task. The setting applies to all tasks in the task graph. NO_OVERLAP: Executes tasks serially with no parallelism. Snowflake schedules the next run of a root task only after all child tasks in the task graph finish running. If the cumulative time to run all tasks in the task graph exceeds the scheduled interval defined for the root task, Snowflake skips at least one task graph run. ALLOW_CHILD_OVERLAP: Allows child task parallelism. When the next scheduled run time for the root task occurs while any child task is still running, Snowflake starts a new instance of the task graph. If the root task itself is still running when the next scheduled run time occurs, Snowflake skips that scheduled run. ALLOW_ALL_OVERLAP: Allows unlimited true parallelism. Multiple instances of the entire task graph, including the root task, can run concurrently. When the next scheduled run time occurs, Snowflake starts a new instance of the task graph immediately, regardless of whether any task (including the root task) is still running. Default: NO_OVERLAP |
session_parameter = value [ , session_parameter = value ... ] | optional | Specifies a comma-separated list of session parameters to set for the session when the task runs. A task supports all session parameters. For the complete list, see Session parameters. Note The following session parameter configurations aren’t supported for tasks: SEARCH_PATH set to any value. AUTOCOMMIT = FALSE. |
USER_TASK_TIMEOUT_MS = num | optional | Specifies the time limit on a single run of the task before it times out (in milliseconds). Note Before you increase the time limit on a task significantly, consider whether the SQL statement initiated by the task could be optimized (either by rewriting the statement or using a stored procedure) or the warehouse size should be increased. When both STATEMENT_TIMEOUT_IN_SECONDS and USER_TASK_TIMEOUT_MS are set, the timeout is the lowest non-zero value of the two parameters. When both STATEMENT_QUEUED_TIMEOUT_IN_SECONDS and USER_TASK_TIMEOUT_MS are set, the value of USER_TASK_TIMEOUT_MS takes precedence. For more information about this parameter, see USER_TASK_TIMEOUT_MS. Values: 0 - 604800000 (7 days). A value of 0 specifies that the maximum timeout value is enforced. Default: 3600000 (1 hour) |
SUSPEND_TASK_AFTER_NUM_FAILURES = num | optional | Specifies the number of consecutive failed task runs after which the current task is suspended automatically. Failed task runs include runs in which the SQL code in the task body either produces a user error or times out. Task runs that are skipped, canceled, or that fail due to a system error are considered indeterminate and aren’t included in the count of failed task runs. Set the parameter on a standalone task or the root task in a task graph. When the parameter is set to a value greater than 0, the following behavior applies to runs of the standalone task or task graph: Standalone tasks are automatically suspended after the specified number of consecutive task runs either fail or time out. The root task is automatically suspended after the run of any single task in a task graph fails or times out the specified number of times in consecutive runs. When the parameter is set to 0, failed tasks aren’t automatically suspended. The setting applies to tasks that rely on either serverless compute resources or virtual warehouse compute resources. For more information about this parameter, see SUSPEND_TASK_AFTER_NUM_FAILURES. Values: 0 - No upper limit. Default: 10 |
ERROR_INTEGRATION = 'integration_name' | optional | Required only when configuring a task to send error notifications using Amazon Simple Notification Service (SNS), Microsoft Azure Event Grid, or Google Pub/Sub. Specifies the name of the notification integration used to communicate with Amazon SNS, MS Azure Event Grid, or Google Pub/Sub. For more information, see Set up alerts and notifications for tasks. |
SUCCESS_INTEGRATION = 'integration_name' | optional | Required only when configuring a task to send success notifications using Amazon Simple Notification Service (SNS), Microsoft Azure Event Grid, or Google Pub/Sub. Specifies the name of the notification integration used to communicate with Amazon SNS, MS Azure Event Grid, or Google Pub/Sub. For more information, see Set up alerts and notifications for tasks. |
LOG_LEVEL = 'log_level' | optional | Specifies the severity level of events for this task that are ingested and made available in the active event table. Events at the specified level (and at more severe levels) are ingested. For more information about levels, see LOG_LEVEL. For information about setting the log level, see Setting levels for logging, metrics, and tracing. |
COMMENT = 'string_literal' | optional | Specifies a comment for the task. Default: No value |
AFTER string [ , string , ... ] | optional | Specifies one or more predecessor tasks for the current task. Use this option to create a task graph or add this task to an existing task graph. A task graph is a series of tasks that starts with a scheduled root task and is linked together by dependencies. Note that the structure of a task graph can be defined after all of its component tasks are created. Execute ALTER TASK … ADD AFTER statements to specify the predecessors for each task in the planned task graph. A task runs after all of its predecessor tasks have finished their own runs successfully (after a brief lag). Note The root task should have a defined schedule. Each child task must have one or more defined predecessor tasks, specified using the AFTER parameter, to link the tasks together. A single task is limited to 100 predecessor tasks and 100 child tasks. In addition, a task graph is limited to a maximum of 1000 tasks total (including the root task) in either a resumed or suspended state. Accounts are currently limited to a maximum of 30000 resumed tasks. All tasks in a task graph must have the same task owner. A single role must have the OWNERSHIP privilege on all of the tasks in the task graph. All tasks in a task graph must exist in the same schema. The root task must be suspended before any task is recreated (using the CREATE OR REPLACE TASK syntax) or a child task is added (using CREATE TASK … AFTER or ALTER TASK … ADD AFTER) or removed (using ALTER TASK … REMOVE AFTER). If any task in a task graph is cloned, the role that clones the task becomes the owner of the clone by default. If the owner of the original task creates the clone, then the task clone retains the link between the task and the predecessor task. This means the same predecessor task triggers both the original task and the task clone. If another role creates the clone, then the task clone can have a schedule but not a predecessor. Current limitations: Snowflake guarantees that at most one instance of a task with a defined schedule is running at a given time; however, we cannot provide the same guarantee for tasks with a defined predecessor task. |
WHEN boolean_expr | optional | Specifies a Boolean SQL expression; multiple conditions joined with AND/OR are supported. When a task is triggered (based on its SCHEDULE or AFTER setting), it validates the conditions of the expression to determine whether to execute. If the conditions of the expression are not met, then the task skips the current run. Any tasks that identify this task as a predecessor also don’t run, unless the task graph uses advanced branching. In a task graph that uses advanced branching, every task is scheduled and evaluates its own WHEN clause, whatever state its predecessors completed in. The following are supported in a task WHEN clause: SYSTEM$STREAM_HAS_DATA is supported for evaluation in the SQL expression. This function indicates whether a specified stream contains change tracking data. You can use this function to evaluate whether the specified stream contains change data before starting the current run. If the result is FALSE, then the task doesn’t run. Note SYSTEM$STREAM_HAS_DATA is designed to avoid returning a FALSE value even when the stream contains change data. However, this function isn’t guaranteed to avoid returning a TRUE value when the stream contains no change data. SYSTEM$GET_PREDECESSOR_RETURN_VALUE is supported for evaluation in the SQL expression. This function retrieves the return value for the predecessor task in a task graph. The return value can be used as part of a boolean expression. When using SYSTEM$GET_PREDECESSOR_RETURN_VALUE, you can cast the returned value to the appropriate numeric, string, or boolean type if required. Simple examples include: Copy code WHEN NOT SYSTEM$GET_PREDECESSOR_RETURN_VALUE('task_name')::BOOLEAN Copy code WHEN SYSTEM$GET_PREDECESSOR_RETURN_VALUE('task_name') != 'VALIDATION' Copy code WHEN SYSTEM$GET_PREDECESSOR_RETURN_VALUE('task_name')::FLOAT < 0.2 Note Use of PARSE_JSON in TASK … WHEN expressions isn’t supported as it requires warehouse based compute resources. SYSTEM$PREDECESSORS_STATE is supported for evaluation in the SQL expression. This function indicates whether the predecessors of the task completed in the states described by a specified condition, such as ALL_FAILED or ALL_DONE. Use it to run a task on outcomes other than “all predecessors succeeded.” A task graph that calls this function uses advanced branching, which changes how Snowflake schedules every task in the graph. Preview Feature — Open SYSTEM$PREDECESSORS_STATE is a public preview feature, available to all accounts. Simple example that runs a task only when all of its predecessors failed: Copy code CREATE TASK my_task WAREHOUSE = my_warehouse AFTER task_a, task_b WHEN SYSTEM$PREDECESSORS_STATE('ALL_FAILED') AS SELECT CURRENT_TIMESTAMP; SYSTEM$TASK_COMPLETION_STATE is supported for evaluation in the SQL expression. This function returns the state that a specified task in the current task graph run completed in, such as SUCCEEDED, FAILED, or SKIPPED. Use it to branch on the outcome of one specific task rather than on the outcome of all of the task’s predecessors. A task graph that calls this function uses advanced branching. Preview Feature — Open SYSTEM$TASK_COMPLETION_STATE is a public preview feature, available to all accounts. Simple example that runs a task only when a specific predecessor failed: Copy code CREATE TASK my_task WAREHOUSE = my_warehouse AFTER task_a, task_b WHEN SYSTEM$TASK_COMPLETION_STATE('TASK_A') = 'FAILED' AS SELECT CURRENT_TIMESTAMP; Note Task names are case-sensitive. Because tasks created without quotes are stored and resolved in uppercase, pass the uppercase form of the task name. Boolean operators such as AND, OR, NOT, and others. Simple example that runs whenever data changes in either of two streams: Copy code CREATE TASK my_task WAREHOUSE = my_warehouse WHEN SYSTEM$STREAM_HAS_DATA('my_customer_stream') OR SYSTEM$STREAM_HAS_DATA('my_order_stream') AS SELECT CURRENT_TIMESTAMP; Casts between numeric, string, and boolean types. Comparison operators such as equal, not equal, greater than, less than, and others. Validating the conditions of the WHEN expression does not require compute resources. The validation is instead processed in the cloud services layer. A nominal charge accrues each time a task evaluates its WHEN condition and doesn’t run. The charges accumulate each time the task is triggered until it runs. At that time, the charge is converted to Snowflake credits and added to the compute resource usage for the task run. Generally the compute time to validate the condition is insignificant compared to task execution time. As a best practice, align scheduled and actual task runs as closely as possible. Avoid task schedules that don’t align with task runs. For example, if data is inserted into a table with a stream roughly every 24 hours, don’t schedule a task that checks for stream data every minute. The charge to validate the WHEN expression with each run is generally insignificant, but the charges are cumulative. Note that daily consumption of cloud services that falls below the 10% quota of the daily usage of the compute resources accumulates no cloud services charges. |
TAG ( tag_name = 'tag_value' [ , tag_name = 'tag_value' , ... ] ) | optional | Specifies the tag name and the tag string value. The tag value is always a string, and the maximum number of characters for the tag value is 256. For information about specifying tags in a statement, see Tag quotas. This parameter is not supported by the CREATE OR ALTER variant syntax. |
WITH CONTACT ( purpose = contact [ , purpose = contact ...] ) | optional | Associate the new object with one or more contacts. |
FINALIZE = string | optional | Specifies the name of a root task that the finalizer task is associated with. Finalizer tasks run after all other tasks in the task graph run to completion. You can define the SQL of a finalizer task to handle notifications and the release and cleanup of resources that a task graph uses. For more information, see Finalizer task. A root task can only have one finalizer task. If you create multiple finalizer tasks for a root task, the task creation will fail. A finalizer task cannot have any child tasks. Any command attempting to make the finalizer task a predecessor will fail. A finalizer task cannot have a schedule. Creating a finalizer task with a schedule will fail. Default: No value |
TASK_AUTO_RETRY_ATTEMPTS = num | optional | Specifies the number of automatic task graph retry attempts. If any task graphs complete in a FAILED state, Snowflake can automatically retry the task graphs from the last task in the graph that failed. The automatic task graph retry is disabled by default. To enable this feature, set TASK_AUTO_RETRY_ATTEMPTS to a value greater than 0 on the root task of a task graph. Note that this parameter must be set to the root task of a task graph. If it’s set to a child task, an error will be returned. Values: 0 - 30. Default: 0 |
USER_TASK_MINIMUM_TRIGGER_INTERVAL_IN_SECONDS = num | optional | Defines how frequently a task can execute in seconds. If data changes occur more often than the specified minimum, changes will be grouped and processed together. The task will run every 12 hours even if this value is set to more than 12 hours. Values: Minimum 10, maximum 604800. Default: 30 |
TARGET_COMPLETION_INTERVAL = 'num { HOURS | MINUTES | SECONDS }' | optional | Specifies the desired task completion time. This parameter only applies to serverless tasks. This property is only set on a task. This parameter is required when you create serverless Triggered tasks. Values: \{ 10 - 86400 \} SECONDS, \{ 1 - 1440 \} MINUTES, or \{ 1-24 \} HOURS (That is, from 10 seconds to the equivalent of 1 day). Accepts positive integers only. Also supports the notations: HOUR, MINUTE, SECOND, and H, M, S. Default: Snowflake resizes serverless compute resources to complete before the next scheduled execution time. |
SERVERLESS_TASK_MIN_STATEMENT_SIZE = string | optional | Specifies the minimum allowed warehouse size for the serverless task. This parameter only applies to serverless tasks. This parameter can be specified on the task, schema, database, or account. Precedence follows the standard parameter hierarchy. Values: Minimum XSMALL, Maximum XXLARGE. Values are consistent with WAREHOUSE_SIZE values. Also supports the notation: X2LARGE. Default: XSMALL Note that if both SERVERLESS_TASK_MIN_STATEMENT_SIZE and USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE are specified, SERVERLESS_TASK_MIN_STATEMENT_SIZE must be equal to or smaller than USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE. |
SERVERLESS_TASK_MAX_STATEMENT_SIZE = string | optional | Specifies the maximum allowed warehouse size for the serverless task. This parameter only applies to serverless tasks. This parameter can be specified on the task, schema, database, or account. Precedence follows the standard parameter hierarchy. Values: Minimum XSMALL, Maximum XXLARGE. Also supports the notation: X2LARGE. Default: XXLARGE If both SERVERLESS_TASK_MIN_STATEMENT_SIZE and SERVERLESS_TASK_MAX_STATEMENT_SIZE are specified, SERVERLESS_TASK_MIN_STATEMENT_SIZE must be less than or equal to SERVERLESS_TASK_MAX_STATEMENT_SIZE. SERVERLESS_TASK_MAX_STATEMENT_SIZE must be equal to or greater than USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE. |
EXECUTE AS USER user_name | optional | Runs the task on behalf of a specified user account. The user who runs the command must have permissions granted by using the GRANT IMPERSONATE ON USER TO ROLE command. For more information, see Run tasks with user privileges. |
Usage notes
- A schedule isn’t required to create a task. However, a standalone task or the root task in a task graph runs automatically only if it has a schedule or is a triggered task. Otherwise, you can run it on demand with EXECUTE TASK, which requires the OWNERSHIP or OPERATE privilege on the task. Child tasks can’t have a schedule; they run after their predecessor tasks complete. For more information, see Define schedules or triggers and Run a task manually.
- Tasks run using the task owner’s privileges. For the list of minimum required privileges to run tasks, see Task security. Run the SQL statement or call the stored procedure, as the task owner role, before you include it in a task definition to ensure the role has the required privileges on objects referenced by the SQL or stored procedure.
- For serverless tasks: Serverless compute resources for a task can range from the equivalent of XSMALL to XXLARGE in warehouse sizes. To request a size increase, contact Snowflake Support.
- Individual tasks in a task graph can use serverless or user-managed compute resources. Using the serverless compute for all tasks in the task graph isn’t required.
- If a task fails with an unexpected error, you can receive a notification about the error. For more information on configuring task error notifications, see Set up alerts and notifications for tasks.
- By default, a DML statement executed without explicitly starting a transaction is automatically committed on success or rolled back on failure at the end of the statement. This behavior is called autocommit and is controlled with the AUTOCOMMIT parameter. This parameter must be set to TRUE. If the AUTOCOMMIT parameter is set to FALSE at the account level, then set the parameter to TRUE for the individual task (using ALTER TASK … SET AUTOCOMMIT = TRUE); otherwise, the task fails when it runs.
- Only one task should consume data from a stream. Create multiple streams for the same table to be consumed by more than one task. When a task consumes the data in a stream using a DML statement, the stream advances the offset and change data is no longer available for the next task to consume.
- The OVERLAP_POLICY parameter replaces the deprecated ALLOW_OVERLAPPING_EXECUTION parameter. For backward compatibility, ALLOW_OVERLAPPING_EXECUTION = TRUE maps to OVERLAP_POLICY = ALLOW_CHILD_OVERLAP, and ALLOW_OVERLAPPING_EXECUTION = FALSE maps to OVERLAP_POLICY = NO_OVERLAP.
- Regarding metadata: Attention Customers should ensure that no personal data (other than for a User object), sensitive data, export-controlled data, or other regulated data is entered as metadata when using the Snowflake service. For more information, see Metadata fields in Snowflake.
Access control requirements
A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes EXECUTE TASK | Account | Required to run any tasks the role owns. Revoking the EXECUTE TASK privilege on a role prevents all subsequent task runs from starting under that role. EXECUTE MANAGED TASK | Account | Required only for tasks that rely on serverless compute resources for runs. CREATE TASK | Schema | USAGE | Warehouse | Required only for tasks that rely on user-managed warehouses for runs. OWNERSHIP | Task | Required only when executing a CREATE OR ALTER TASK statement for an existing task. OWNERSHIP is a special privilege on an object that is automatically granted to the role that created the object, but can also be transferred using the GRANT OWNERSHIP command to a different role by the owning role (or any role with the MANAGE GRANTS privilege). Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema. For instructions on creating a custom role with a specified set of privileges, see Creating custom roles. For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.
CREATE OR ALTER TASK usage notes
- All limitations of the ALTER TASK command apply. - A task cannot be resumed or suspended using the CREATE OR ALTER TASK command. To resume or suspend a task, use the ALTER TASK command. - Setting or unsetting a tag is not supported; however, existing tags are not altered by a CREATE OR ALTER statement and remain unchanged.