Explode Array
Description
Converts each element from an Array into a new row.
Parameters
- Mode: Specify the behavior mode for exploding Arrays.
- Recursive (default): Explode the specified Array. When the Array's elements are Structs, any Arrays found inside those Structs are also exploded recursively.
- Selective: Explode only the specified Array, one level. Arrays nested inside its elements are left as-is.
- Array: The Array to explode. Accepts a dot-separated path through Struct fields — use
arrayNamefor a top-level Array (e.g.scores) orparent1.arrayNamefor an Array nested inside a Struct (e.g.user.scores). Intermediate segments must be Struct types; navigating through Arrays is not supported.- Required when Mode is Selective.
- Optional when Mode is Recursive. If omitted, every top-level field in the schema is processed, and all Arrays reachable from those fields are exploded. When multiple independent Arrays are exploded in this way, the result is the Cartesian product of their elements.
Input Requirements
- At least one field should be an Array type in order to perform the transformation.
Expected Output
- Adds a new row for each element in an Array, or one new row for an empty array.
- Removes all exploded Arrays from the schema.
Examples
Example 1: Standard Array
Input:
// Mode = "Recursive"
{
"sensor": "NYC Air Quality",
"readings": [115,23,53,24,45]
}
Output:
| Sensor | Readings |
|---|---|
| "NYC Air Quality" | 115 |
| "NYC Air Quality" | 23 |
| "NYC Air Quality" | 53 |
| "NYC Air Quality" | 24 |
| "NYC Air Quality" | 45 |
Example 2: Array of Structs
Input:
// Mode = "Recursive"
{
"address": "123 Main St",
"residents": [
{
"first": "Alice",
"last": "Jones"
},
{
"first": "Mike",
"last": "Hart"
},
{
"first": "Bill",
"last": "Nye"
}
]
}
Output:
| Address | Residents |
|---|---|
| "123 Main St" | {"first": "Alice", "last": "Jones"} |
| "123 Main St" | {"first": "Mike", "last": "Hart"} |
| "123 Main St" | {"first": "Bill", "last": "Nye"} |
Tip: Add a Flatten Struct transformation to split "first" and "last" into separate fields.
Example 3: Complex Structure
// Input
// Mode = "Recursive"
{
"customerId": "123abc",
"account": {
"accountId": 999999,
"preferences": {
"emailNotification": true
}
},
"deliveryAddress": null,
"orders": [
{
"orderId": 77777,
"orderDetails": {
"isGift": true
}
},
{
"orderId": 444444,
"orderDetails": {
"isGift": false
}
}
]
}
// Ouput Row 1
{
"customerId": "123abc",
"account": {
"accountId": 999999,
"preferences": {
"emailNotification": true
}
},
"deliveryAddress": null,
"orders": {
"orderId": 77777,
"orderDetails": {
"isGift": true
}
}
}
// Ouput Row 2
{
"customerId": "123abc",
"account": {
"accountId": 999999,
"preferences": {
"emailNotification": true
}
},
"deliveryAddress": null,
"orders": {
"orderId": 444444,
"orderDetails": {
"isGift": false
}
}
}
Example 4: Selective mode with a single Array
In Selective mode, only the specified Array is exploded — other Arrays in the schema are preserved as-is.
// Mode = "Selective", Array = "scores"
// Input
{
"name": "andy",
"scores": [94, 87, 79],
"classes": ["math", "science"]
}
// Output — Record 1
{ "name": "andy", "scores": 94, "classes": ["math", "science"] }
// Output — Record 2
{ "name": "andy", "scores": 87, "classes": ["math", "science"] }
// Output — Record 3
{ "name": "andy", "scores": 79, "classes": ["math", "science"] }
Example 5: Exploding an Array nested inside a Struct
A dot-separated path can target an Array inside a Struct. Only the Array at the end of the path is exploded; other Struct fields are untouched.
// Mode = "Selective", Array = "user.scores"
// Input
{
"user": {
"name": "andy",
"scores": [94, 87, 79]
}
}
// Output — Record 1
{ "user": { "name": "andy", "scores": 94 } }
// Output — Record 2
{ "user": { "name": "andy", "scores": 87 } }
// Output — Record 3
{ "user": { "name": "andy", "scores": 79 } }