In this article let’ dive into Snowflake Tasks, what they are, how they work, how to implement them, and best practices to get the most out of your automation efforts.
Features change from time to time with new features being added regularly, it is recommended that you review the documentation for the latest on what specific features are included with any of the Editions.
Table of Contents
Open Table of Contents
What Are Snowflake Tasks?
At a fundamental level, a Snowflake Task is a scheduled or event-driven object that executes a single SQL statement or a stored procedure. Tasks are used to automate business processes, maintain data freshness, and support data transformation pipelines.
Tasks can:
-
Be scheduled using CRON syntax.
-
Be triggered by the completion of other tasks (task graphs).
-
React to changes in data using Snowflake Streams.
-
Execute with either serverless compute or user-managed warehouses.
Why Use Snowflake Tasks?
Snowflake Tasks reduce operational overhead by automating routine data operations.
They are a key enabler for:
-
Periodic transformations (daily aggregations, table maintenance).
-
Real-time or near real-time processing (using Streams and triggered Tasks).
-
Creating Directed Acyclic Graphs (DAGs) for dependent task orchestration.
Task Execution Models
Features change from time to time with new features being added regularly, it is recommended that you review the documentation for the latest on what specific features are included with any of the Editions.
Serverless Tasks
With serverless tasks, Snowflake provisions and manages compute resources automatically. You don’t need to specify a warehouse.
Benefits:
-
Auto-scaling compute.
-
Cost-effective for infrequent or short-running jobs.
-
Ideal for triggered workflows.
Limitations:
-
Maximum size equivalent to XXLARGE warehouse.
-
Slight delay in execution due to provisioning.
Below is an example of how a serverless task can be created in Snowflake:
CREATE TASK my_serverless_task
SCHEDULE = 'USING CRON 0 * * * * UTC'
TARGET_COMPLETION_INTERVAL = '10 MINUTE'
AS
CALL process_hourly_data();
User-Managed Tasks
These tasks specify a virtual warehouse for execution. They offer more control and are suitable for predictable workloads.
CREATE TASK my_manual_task
WAREHOUSE = my_wh
SCHEDULE = 'USING CRON 0 0 * * * UTC'
AS
CALL process_daily_aggregates();
Task Graphs (DAGs)
Task graphs define parent-child relationships, ensuring proper execution order. These are essential for complex workflows like:
Data ingestion → 2. Data transformation → 3. Report generation
CREATE TASK stage_1
SCHEDULE = '1 HOUR'
AS
CALL ingest_data();
CREATE TASK stage_2
AFTER stage_1
AS
CALL transform_data();
CREATE TASK stage_3
AFTER stage_2
AS
CALL generate_reports();
Task Triggers Using Streams
For reactive processing, combine tasks with Streams:
-
Monitor new/updated data.
-
Trigger tasks only when data changes.
-
Ideal for event-driven architecture.
CREATE TASK process_stream
AFTER insert_stream
WHEN
SYSTEM$STREAM_HAS_DATA('my_stream')
AS
CALL process_new_data();
Conclusion
Snowflake Tasks offer a powerful and flexible way to automate workflows within your data platform. Whether you’re running scheduled maintenance jobs, orchestrating multi-step pipelines, or processing real-time data changes, tasks provide the backbone for building efficient, scalable, and manageable solutions.
To get started:
-
Try creating a basic task using the CREATE TASK syntax.
-
Explore DAGs for multi-stage workflows.
-
Combine with Streams for reactive ELT pipelines.
Snowflake Tasks are more than just schedulers—they’re automation tools built for the modern data cloud.
Features change from time to time with new features being added regularly, it is recommended that you review the documentation for the latest on what specific features are included with any of the Editions.