Skip to content

Iterators

The iterator lets you iterate, or loop, through a table of data within a brew workflow. Iterators provide immense flexibility when building brew workflows.

Dragging the iterator button from the canvas toolbar

You can add an iterator into your workflow by dragging the “iterator” button from the canvas toolbar onto the canvas.

Iterators are often used to:

  • Perform operations on individual rows of data (format a value within a cell in every row)
  • Perform queries on specific values within each row
  • Batch-execute workflows (using sub-workflows)

Just like functionals, the iterator expects an input — but you only connect a single table input to each iterator. When the workflow executes, the input table is iterated through and the functionals inside the iterator run once per row in the input table. A 100-row table means 100 executions, run in the same order supplied by the input table.

Iterators are used in two main ways:

  • To modify an input table and produce an updated table with additional columns
  • To run a functional or series of functionals for each row inside the table and produce a new output
Example table flowing through an iterator to produce a new output column

It’s difficult to see what’s happening inside an iterator. brewlytics can retrieve a trace-table log of each iteration — the iteration number, exception(s), start/end time, duration in milliseconds, and the iteration’s inputs and outputs (exceptions/inputs/outputs formatted as JSON). The execution log and the iterator’s progress bar also show the number of errors encountered.

Enable trace capture via the cog in the iterator’s lower-right corner — this extends a table connector output usable like any normal CV_Table output, or simply as an indicator that capture is enabled. Trace capture is automatically turned off when a model is saved unless it’s connected to downstream functionals (to save resources).

Iterator trace-capture cog in unselected, selected, and connected states