{
"outer_1": "1",
"outer_2": 2,
"inner": [
{
"inner_1": 0,
"inner_2": null,
},
{
"inner_1": 3,
"inner_2": true,
},
]
}
Above you can see roughly what my data looks like. In terms of BigQuery, inner is a repeated record. I would like to calculate aggregates (like the sum of non-null inner_1 fields) for each row.
One idea is to use unnest(inner), calculate aggregates and then group by all other columns. This doesn't seem, however, to be the optimal approach. I already have about a million rows. Unnesting would create tremendously many more rows and doing aggregation to group everything right away doesn't sound right.
I bet there might be a more efficient way to iterate over nested records and calculate aggregates for them.
In the end, I would like to have something like:
{
"outer_1": "1",
"outer_2": 2,
"inner_1_sum: 3,
"inner_2_non_null_count": 1
}
