Skip to main content
SUBMIT TASK submits an ETL statement as an asynchronous task. You can use this statement to:
  • execute long-running tasks in the background (supported from v2.5 onwards)
  • schedule a task at a regular interval (supported from v3.3 onwards)
Supported statements include: You can view the list of tasks by querying INFORMATION_SCHEMA.tasks, or view the execution history of tasks by querying INFORMATION_SCHEMA.task_runs. For more information, see Usage Notes. You can modify an asynchronous task using ALTER TASK, or drop an asynchronous task using DROP TASK.

Syntax

PROPERTIES

You can add the session. prefix before session variables to change the task running context configurations. Tip You can set the warehouse property in the statement to specify the warehouse used for this operation. By default, default_warehouse is used. For example, the following statement submits a task named test_task with session properties which enables query profile and increase query timeout:

Parameters

Return value

  • TaskName: The name of the task.
  • Status: The status of the task. Valid values:
    • SUBMITTED: The task has been submitted.
    • REJECTED: The task has been rejected.
    • FAILED: The task has failed.

Usage notes

This statement creates a Task, which is a template for storing a task that executes the ETL statement. You can check the information of the Task by querying the metadata view tasks in Information Schema.
After you run the Task, a TaskRun is generated accordingly. A TaskRun indicates a task that executes the ETL statement. A TaskRun has the following states:
  • PENDING: The task waits to be run.
  • RUNNING: The task is running.
  • FAILED: The task failed.
  • SUCCESS: The task runs successfully.
You can check the state of a TaskRun by querying the metadata view task_runs in Information Schema.

Configure via FE configuration items

You can configure asynchronous ETL tasks using the following FE configuration items:

Examples

Example 1: Submit an asynchronous task for CREATE TABLE tbl1 AS SELECT * FROM src_tbl, and specify the task name as etl0:
Example 2: Submit an asynchronous task for INSERT INTO tbl2 SELECT * FROM src_tbl, and specify the task name as etl1:
Example 3: Submit an asynchronous task for INSERT OVERWRITE tbl3 SELECT * FROM src_tbl:
Example 4: Submit an asynchronous task for INSERT OVERWRITE insert_wiki_edit SELECT * FROM source_wiki_edit without specifying the task name, and extend the query timeout to 100000 seconds using the hint:
Example 5: Create an asynchronous task for an INSERT OVERWRITE statement. The task will be regularly executed at an interval of 1 minute.
Example 6: Create a task with custom session properties: