Skip to main content
Tasks are Python functions that run as part of the DAG. Use them for computation, side effects, and orchestration steps that are not loading data into a source and not producing a tracked artifact. See Python Nodes for the shared model and the SQL boundary rules.

Defining a task

Place Python files under tasks/ and decorate functions with @task:
The task receives a TaskContext and returns through ctx.result(...). A plain return value or None is also accepted and normalized to a successful result.

Dependencies

Tasks declare dependencies with depends_on, accepting a single function, a tuple, or a list:
ctx.result_of(node_fn) reads the latest persisted result of an upstream node, returning a NodeResultEnvelope with payload, metadata, status, and ts fields. Results persist across runs. Use ctx.results_of(node_fn, limit=N) to read result history. Reading a missing or unsuccessful upstream raises unless you pass default=. Tasks may depend on other tasks, assets, and loaders. They may not depend on SQL models or sources as graph dependencies, but they can read them at runtime with typed references - see SQL references.

Returning results

  • payload is the value downstream nodes read with ctx.result_of(...).
  • metadata is structured JSON for catalogs and downstream reads.
  • Tasks cannot set materialized - that is for assets.

Skipping

Return ctx.skip(...) to skip a task:
  • "soft" (default) skips only this task; dependents may still run if another upstream succeeded.
  • "hard" skips this task and blocks its dependents.
mode accepts either a plain string or the SkipMode enum:

Retries

@task accepts a retry policy for transient failures:
The default is no retry. Set retry_on explicitly rather than relying on the broad default when you can. The original exception is preserved if all attempts fail.

Decorator parameters

Running tasks

Tasks run during sqb build. They are not validated by checks unless you also write a check that depends on them.