Reshape node
What it does
The Reshape node changes rows between a tall and a wide shape:
- Pivot (Rows to Columns): the distinct values of one column become new columns, with one output row per group.
- Unpivot (Columns to Rows): several columns become rows, one row per column.
When to use
- Rows arrive as
(customer, month, amount)and the target wants one row per customer with a column per month: pivot. - Rows arrive as
(customer, jan, feb, mar)and the target wants one row per customer and month: unpivot.
Configure
Select the node and press Configure to open Configure Reshape. Choose the Reshape Mode. The output columns change with it.
Save and Done stay unavailable while a required setting is missing. Cancel discards the changes made since the dialog opened or was last saved. A message confirms each save.
Identity Keys: columns carried through unchanged. In a pivot, there is one output row per distinct combination. A button fills them with the upstream primary key.
Pivot Settings
- Pivot Column: the column whose values become column names, such as
Month. - Value Column: the column whose values fill the new columns, such as
Amount. - Collision: when a group has the same pivot value twice,
Last winsorFirst wins. - Prefix: optional text added to each new column name.
- Pivot Values (comma-separated): the columns to create, such as
Jan, Feb, Mar. Matching ignores case, and the column takes the spelling from your list. Leave blank to use the values found, up to 50. - Pivot Column Order:
Sort by Pivot Values,Sort by Mapped ValuesorAs Configured/Encountered. - Pivot Value Remap (optional): rename pivot values before they become columns.
Unpivot Settings
- Columns to Unpivot: the columns that become rows. Leave blank to unpivot every column that is not an identity key.
- Attribute Name Column: the output column for the original column name, such as
AttributeName. - Attribute Value Column: the output column for the value, such as
AttributeValue.
Preview & Validation shows the resulting columns once an upstream node is connected.
Ports
| Port | Direction | Kind | Notes |
|---|---|---|---|
in | in | data | Rows. |
out | out | data | Reshaped rows. |
error | out | control | Receives the input rows when the node fails. |
A pivot needs every row of a group before it is complete, so its output arrives after the last input row. An unpivot sends rows as they arrive.
Examples
Pivot monthly totals. Identity Keys customer, Pivot Column month, Value Column amount, Pivot Values Jan, Feb, Mar.
| customer | month | amount |
|---|---|---|
C1 | Jan | 10 |
C1 | Feb | 20 |
becomes
| customer | Jan | Feb | Mar |
|---|---|---|---|
C1 | 10 | 20 |
Unpivot survey answers. Identity Keys respondent, Columns to Unpivot q1, q2, q3, Attribute Name Column question, Attribute Value Column answer. Each respondent becomes three rows.
Troubleshooting
| Symptom | Cause | What to do |
|---|---|---|
| The run fails with "more than 50 distinct pivot values" | The pivot column has too many values. | List the columns you need in Pivot Values. |
| A cell holds the wrong value | The group had the pivot value twice. | Set Collision, or aggregate first with a Compute node. |
| A column name has unexpected case | The name comes from Pivot Values, not the data. | Write the names as you want them in the list. |
| Too many output rows from an unpivot | Columns to Unpivot is blank, so every non-key column is used. | List the columns. |