Icon

5. Empty Table Switch

<p><strong>Empty Table Switch</strong></p><p>This workflow implements another example of a CASE Switch and demonstrates the use of the <em>Empty Table Switch</em> node.</p><p>First, we access the <em>cars-85.csv</em> dataset. With the two <em>Value Selection Widget</em> nodes, we select a car manufacturer and a type of wheel drive. We filter the dataset to the selected car manufacturer and then follow three different workflow branches depending on the selected type of wheel drive:</p><ul><li><p>Case 1 (port 0): fwd</p></li><li><p>Case 2 (port 1): rwd</p></li><li><p>Case 3 (port 2): 4wd</p></li></ul><p>In each branch, we filter the dataset to the selected wheel drive and send the resulting data table back to a <em>CASE Switch End</em> node. Finally, we aggregate the data using a <em>GroupBy</em> node.</p><p><strong><em>Note.</em></strong> Depending on the selected car manufacturer and type of wheel drive, the second <em>Row Filter</em> might produce an empty data table. Empty tables can still be processed by nodes further down in the workflow, however, some nodes require a non-empty data input which then would lead to node failure. To prevent this from happening, we add an <em>Empty Table Switch</em> node to each branch. This node has two output ports: the top port is active when the output table is not empty, the second port is active when an empty table is created.</p>

CASE Switch

Workflow: Empty Table Switch


This workflow implements another example of a CASE Switch and demonstrates the use of the Empty Table Switch node.

First, we access the cars-85.csv dataset. With the two Value Selection Widget nodes, we select a car manufacturer and a type of wheel drive. We filter the dataset to the selected car manufacturer and then follow three different workflow branches depending on the selected type of wheel drive:

  • Case 1 (port 0): fwd

  • Case 2 (port 1): rwd

  • Case 3 (port 2): 4wd

In each branch, we filter the dataset to the selected wheel drive and send the resulting data table back to a CASE Switch End node. Finally, we aggregate the data using a GroupBy node.

Note. Depending on the selected car manufacturer and type of wheel drive, the second Row Filter might produce an empty data table. Empty tables can still be processed by nodes further down in the workflow, however, some nodes require a non-empty data input which then would lead to node failure. To prevent this from happening, we add an Empty Table Switch node to each branch. This node has two output ports: the top port is active when the output table is not empty, the second port is active when an empty table is created.

Reading data

Case 1 (port 0): Wheel drive = fwd

Case 2 (port 1): Wheel drive = rwd

Case 3 (port 2): Wheel drive = 4wd

Aggregating data:

Count by fuel type

Creating flow variable

To control CASE Switch

Creating flow variable

To filter dataset

Empty Table Switch
Filter to fwd
Row Filter
Empty Table Switch
Filter to rwd
Row Filter
Create port variable basedon selected wheel drive value
Variable Expression
Empty Table Switch
Filter data toselected manufacturer
Row Filter
Select wheel drive;Default: fwd
Value Selection Widget
Filter to 4wd
Row Filter
CASE Switch End
cars-85.csv
CSV Reader
Count by fuel-type
GroupBy
Select car manufacturer;Default: alfa-romeo
Value Selection Widget
Active port derived fromport variable (selected wheel drive)
CASE Switch Start

Nodes

Extensions

Links