Creating a SQL Task Component
Task Components in Ascend let you execute arbitrary SQL code as a component. Unlike Transform Components, SQL Tasks aren't directly tied to the Data Plane, giving you more flexibility.
Structuring Your SQL Component​
In SQL Task Components, the config
function defines the task type and its dependencies. This function specifies the input data and any components that your task relies on.
Example​
Here's a SQL Task Component example:
{{
config(
type="task",
dependencies=[ref("route_closures")]
)
}}
-- Identify routes with closures today and log a warning
WITH closures_today AS (
SELECT
route_id
FROM
{{ ref("route_closures") }}
WHERE
start_date >= CURRENT_DATE
AND end_date <= CURRENT_DATE
)
SELECT
route_id
FROM
closures_today;
This example identifies routes with active closures today:
-
Config function: Defines the task type and dependencies. The task depends on the
route_closures
component for its data source. -
Common table expression (CTE): The
WITH
clause creates a temporary result setclosures_today
that filters theroute_closures
data for routes where closures are active on the current date. -
Final selection: The query selects
route_id
from the filtered data, which can be used for warnings or further processing.
Next Steps​
- Learn more about Tasks in our Concept Guide
- Explore Task options in our Reference Guide