I'm trying to fetch the data of a nested json using databricks sql, but unable to perform the explode on multiple array columns and its throwing below error
[UNSUPPORTED_GENERATOR.MULTI_GENERATOR] The generator is not supported: only one generator allowed
when trying to execute the below query
SELECT
explode(array_join(from_json(food:Fruits.children\[*\].`Fruit Quantity`, 'array\<string\>'), ' - ')) AS `Fruit Quantity`,
explode(array_join(from_json(food:Fruits.children\[*\].`Fruit Weight`, 'array\<string\>'), ' - ')) AS `Fruit Weight`,
explode(array_join(from_json(food:Fruits.children\[\*\].`Fruit Packaging`, 'array\<string\>'), ' - ')) AS `Fruit Packaging`
FROM
input_table
Input
| Day | Food |
| -------- | -------- |
| Day 1 | {
"breakfast": {
"carbs": [
{
"carbs name": "No food"
}
]
},
"Fruits": {
"batch": "batch01",
"children": [
{
"Fruit name": "apple01",
"Fruit Quantity": 3,
"Fruit Weight": "50g",
"Fruit Packaging": "Basket"
},
{
"Fruit name": "apple01",
"Fruit Quantity": 3,
"Fruit Weight": "50g",
"Fruit Packaging": ""
},
{
"Fruit name": "apple02",
"Fruit Quantity": 5,
"Fruit Weight": "100g",
"Fruit Packaging": "Foil"
}
]
}
} |
Day 2 | {dinner:["bread", "egg"]}
Note: I need sql without any CTEs or subqueries.
The food column will have different data types i might need different functionality to be done on those as separate columns. The Lateral view explode option is excluding the other data types

Use
LATERAL VIEW EXPLODEto explode multiple array columns. Check below query.