Skip to main content
Execute downstream steps only when a condition is met. When a branch evaluates to false, all steps that depend on its output table are skipped.
{
  branch: {
    sql: "SELECT COUNT(*) > 0 FROM raw_orders WHERE status = 'pending'",
  },
  outputTable: "has_pending_orders",
}
FieldRequiredDescription
outputTableYesName of the table this step produces
conditionNoA template variable to evaluate. Truthy values (true, non-empty strings, non-zero numbers) execute the branch. Falsy values (false, "", 0, null) skip it.
sqlNoSQL query that returns a single value. Truthy results execute the branch.
One of condition or sql must be specified, but not both.

Dependency graph

Branch steps produce an output table like any other step. Steps that reference the branch’s output table only execute if the branch condition is met:
steps: [
  { service: "shopify", operation: "listOrders", ..., outputTable: "raw_orders" },

  {
    branch: {
      sql: "SELECT COUNT(*) > 1000 FROM raw_orders",
    },
    outputTable: "large_dataset_flag",
  },

  {
    sql: "SELECT ... FROM raw_orders WHERE ...",
    outputTable: "filtered_orders",
    dependsOn: ["large_dataset_flag"],
  },
]
If raw_orders has fewer than 1,000 rows, the filtered_orders step is skipped entirely.

Validation

Check
Only one of condition or sql can be specified
SQL conditions are validated the same as sql steps