Tasks: compute, ownership and one manual run
A task runs a SQL statement or procedure under its configured execution identity. It needs both compute configuration and permission to perform the work.
Understand the idea
A task is not your open worksheet session. It does not inherit a temporary table or variable you happened to create interactively. Use durable objects and fully qualified references for scheduled work.
| Concept | What it means |
|---|---|
| Warehouse-backed | Uses a warehouse selected by the task definition. |
| Serverless | Snowflake manages compute for the task; usage is still billed. |
| Task owner role | Normally supplies the task’s execution privileges. |
| Suspended | A newly created task does not begin scheduling itself. |
A concrete example
Replace the warehouse placeholder. After task history reports SUCCEEDED, one manual row should exist. Do not repeatedly click EXECUTE while waiting.
Remember: Separate task submission, execution and committed business outcome.
Explain it step by step · full theory
Understand the concept
A task is not your open worksheet session. It does not inherit a temporary table or variable you happened to create interactively. Use durable objects and fully qualified references for scheduled work.
The owner role needs CREATE TASK on the schema, global EXECUTE TASK and privileges required by its SQL. Warehouse-backed tasks also need warehouse USAGE. Serverless tasks require EXECUTE MANAGED TASK in addition to applicable privileges. An authorized administrator supplies these grants; do not elevate to administrator just to make a demo work.
Walk through the behavior
EXECUTE TASK submits work asynchronously by default. Its return does not prove the INSERT completed. Inspect TASK_HISTORY for a terminal state before querying expected results. A successful manual run does not automatically enable a recurring schedule.
Words used in this lesson
- Warehouse-backed
- Uses a warehouse selected by the task definition.
- Serverless
- Snowflake manages compute for the task; usage is still billed.
- Task owner role
- Normally supplies the task’s execution privileges.
- Suspended
- A newly created task does not begin scheduling itself.
See how it works
Choose a step to explore the idea at your own pace.
Open the interactive explanation
Tasks: compute, ownership and one manual run
Start with the source
A task runs a SQL statement or procedure under its configured execution identity. It needs both compute configuration and permission to perform the work.
Automatic playback is off for reduced motion. Select any step or use Previous and Next. Illustrations explain behavior; they are not live measurements.
Read the complete diagram explanation
- Start with the source
A task runs a SQL statement or procedure under its configured execution identity. It needs both compute configuration and permission to perform the work.
- Follow the work
A task is not your open worksheet session. It does not inherit a temporary table or variable you happened to create interactively. Use durable objects and fully qualified references for scheduled work.
- Explain the outcome
Separate task submission, execution and committed business outcome.
Try the SQL or command
Read → predict → run in your learning environment → compare. You can also learn by reading without an account.
New to SQL? Where to run it and how to read it
A query is a question written in SQL. Snowflake runs it and returns a result table. This website shows examples; it does not connect to your account.
- No account yet? Read and predict the output first. Follow the account and Snowsight lesson when you are ready.
- For SQL practice, use a learning account in Snowsight and select an authorized role and warehouse. A role determines permissions; a warehouse supplies processing power. Follow the example’s database/schema setup when it refers to stored objects.
- Read the entire example, including comments beginning with
--. Run the selected statement or labeled block in the stated order. Examples labeled Python, shell or HTTP belong in that client, not in a SQL editor. - Compare values and row counts with the explained result. If an example deliberately causes an error, follow its rollback and cleanup steps before continuing.
- SELECT / FROM
- Choose the values to return / identify their input.
- VALUES / COLUMN1
- VALUES supplies tiny example rows. COLUMN1 means their first column, COLUMN2 their second.
- AS / WITH
- AS gives a result a readable name. WITH names a temporary query step within one statement.
- NULL / ::
- NULL means missing or unknown. The :: notation converts a value to a named data type.
- Session
- One connection and its settings. Keep related transaction steps in the same session.
- Database.schema.table
- A full address for stored data. It is separate from the warehouse that processes queries.
Need the L2_OBJECTS_LAB setup? Open the first database-object lesson →
Help with common practice errors
- No active warehouse: select a warehouse your role can use. Do not assume you need to create a new one.
- Object missing or not authorized: check the full name, required setup and active role. Ask the account owner for access if needed.
- Object already exists: setup may already have run. Read the current state or choose a fresh lab name consistently; do not add OR REPLACE blindly.
- Different result: check whether an earlier INSERT or UPDATE changed the data. VALUES examples provide their own fresh input for each statement.
Before running this lesson
Manual learning lab; nothing runs on this website. Complete lesson 1 setup in L2_OBJECTS_LAB.M11_LAB and follow the lesson order. Use the same authorized role and warehouse for manual SQL. Task templates use <lab_warehouse>: replace it with an approved warehouse name. Do not activate several consumers against the same stream. Each task starts suspended; running or resuming it can consume compute credits.
Create a one-shot learning task
CREATE TABLE TASK_RUN_LOG (LABEL VARCHAR, RAN_AT TIMESTAMP_LTZ);
CREATE TASK MANUAL_TASK WAREHOUSE=<lab_warehouse>
AS INSERT INTO L2_OBJECTS_LAB.M11_LAB.TASK_RUN_LOG VALUES ('manual',CURRENT_TIMESTAMP());
EXECUTE TASK MANUAL_TASK;What to expect and why
Replace the warehouse placeholder. After task history reports SUCCEEDED, one manual row should exist. Do not repeatedly click EXECUTE while waiting.
Observe task completion
SELECT NAME,STATE,QUERY_ID,ERROR_MESSAGE,SCHEDULED_TIME,COMPLETED_TIME
FROM TABLE(L2_OBJECTS_LAB.INFORMATION_SCHEMA.TASK_HISTORY(TASK_NAME=>'MANUAL_TASK',RESULT_LIMIT=>20))
ORDER BY SCHEDULED_TIME DESC;
SELECT * FROM TASK_RUN_LOG ORDER BY RAN_AT;What to expect and why
History can show scheduled/running states before completion. If the run failed, investigate the returned error before assuming a row was inserted.
Check your understanding
Choose an answer, then check your reasoning. This is practice, not a scored test.
Try it yourself
Why should a task not depend on your temporary worksheet table?
Compare your reasoning
Task execution has its own session context; session-local objects and variables are not a durable pipeline interface.