Union
Union stacks rows from the tables you connect, aligning columns by name or position. A Source column records which input each row came from, such as input_1. With By column name, differing columns can all be kept, reduced to the shared ones or stop with an error. By position stops with an error if the tables have different numbers of columns. Rows come out in the order the inputs are connected.
Stack two months of orders
January has two orders and February has three. Both connect to Union, aligned by column name.
Union interactive example
Loading interactive example…
The live example needs a desktop screen. The result it produces is shown here, and the explanation and settings below work on any screen.
| order | amount | Source |
|---|---|---|
| 1001 | 120 | input_1 |
| 1002 | 75 | input_1 |
| 1003 | 240 | input_2 |
| 1004 | 60 | input_2 |
| 1005 | 95 | input_2 |
- Look at the preview. It has five rows in one table. The
Sourcecolumn shows input_1 for January and input_2 for February. - Clear Source Column Name. The
Sourcecolumn disappears, and the five rows stay.
When to use
Use Union when several tables hold the same kind of rows, such as one export per month or per region. To add columns from another table by matching a key, use Join.
To combine tables side by side on a key, use Join.
Inputs and outputs
Inputs
1 port- InRequired
Accepts: Tables, Geospatial data.
Accepts multiple connections on this port.
Outputs
1 port- Out
Configure the block
- Align
How input columns are aligned. By position reports an error when inputs have different numbers of columns.
Default:
By column nameOptions: By column name, By position.
- When columns differ
Applies to By column name. How to handle inputs whose column names don't match. Keep all fills missing values with null, Common columns only keeps the intersection, Error stops before running.
Default:
Keep all columnsOptions: Keep all columns, Common columns only, Error on mismatch.
- Source Column Name
Name of the column that tags each row with its input (input_1, input_2 and so on). Clear the box to leave the column out.
Default:
Source
Union FAQs
- What happens when the columns differ?
- With By column name, When columns differ decides: keep all columns, keep the common ones or stop with an error. By position reports an error when the inputs have different numbers of columns.
- Can I leave out the Source column?
- Yes. Clear Source Column Name. The rows stay the same.
- In what order do the rows come out?
- In the order the inputs are connected.
Prepare your data. Build it in Strata.
Strata opens in your browser, with no account.