Skip to main content

Explode Array

Description

Converts each element from an Array into a new row.

Parameters

  • Mode: Specify the behavior mode for the exploding arrays.
    • Recursive (currently the only option): Loop through nested Arrays and unnest each element into a new row.

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:

SensorReadings
"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:

AddressResidents
"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
}
}
}