The Switch node takes a mandatory input and an optional input, and then inspects both inputs. The main use of this node is to create loops within a data flow.
When the Switch node runs, it inspects both inputs; if the second (optional) input contains data, this data is output. Otherwise, the data from the first input is output. The first input must always have data, while it is not mandatory for the second (optional) input to contain data.
"Data" can be considered to include metadata without any data rows for the purposes of the switching logic. Therefore, for an input pin to contain "no data", the input must be null and not just 0 records. Clocks should be used if the node needs to wait for data from the second input pin, see example 2 below.
This article contains three examples of how the Switch node can be used.
Please see SwitchExample1.lna attached. Since most of the time, the sleep node delays the arrival of the second input, the Switch node will pass the first input.
Please see SwitchExample2.lna attached. Using a clock, the second is forced to arrive first. The Switch node cannot complete until the first input completes. Even though it waits for the first, it passes the data from the second input.
Please see SwitchExample3.lna attached. Using a sleep node, the second is likely to arrive first. The Switch node cannot complete until the first input completes. Even though it waits for the first, it passes the data from the second input.