Fan-Out Collections with Explode¶
Transform a single list input into multiple outputs, one per item, enabling parallel processing of collection elements.
QType YAML¶
steps:
- type: Explode
id: fan_out
inputs:
- items # Variable of type list[T]
outputs:
- item # Variable of type T
Explanation¶
- Explode: Takes a single list and yields one output message per item
- inputs: Must be a single variable of type
list[T] - outputs: Single variable of the item type
T(unwrapped from the list) - Fan-out pattern: Each item is processed independently by downstream steps
Complete Example¶
id: explode_example
description: Explode a list into individual items for fan-out processing
flows:
- type: Flow
id: main
description: Takes a list and processes each item individually
variables:
- id: items
type: list[text]
- id: item
type: text
inputs:
- items
outputs:
- item
steps:
- type: Explode
id: fan_out
inputs: [items]
outputs: [item]
Run it:
qtype run examples/data_processing/explode_items.qtype.yaml \
-i '{"items": ["apple", "banana", "cherry"]}'