I have data in my bucket that is of this form:
{
...,
"details": {
"items": [
{
...,
"subitems": ["a", "b", "c"]
...,
},
{
...,
"subitems": ["d", "e", "f", "g"]
...,
}
]
}
...,
}
I would like to select the count of all subitems in each document. How can I achieve this? What I tried was this:
SELECT COUNT(ARRAY_AGG(details.items[*].subitems)) AS count FROM bucket;
This does not work as expected. For example, the above example json has all subitems:
["a", "b", "c", "d", "e", "f", "g"]
And therefore should return 7.