The docs for the groupArray
function warns that
Values can be added to the array in any (indeterminate) order.... In some cases, you can still rely on the order of execution. This applies to cases when SELECT comes from a subquery that uses ORDER BY.
Does this just mean that the array will not neccessarily be in the order specified in the ORDER BY
? Can I depend on the order of multiple groupArray
s in the same query being consistent with each other?
For instance given the records:
{commonField:"common", fieldA: "1a", fieldB:"1b"}
{commonField:"common", fieldA: "2a", fieldB:"2b"}
{commonField:"common", fieldA: "3a", fieldB:"3b"}
Can I depend on the query
SELECT commonField, groupArray(fieldA), groupArray(fieldB) FROM myTable GROUP BY commonField
to return
{
commonField:"common",
groupedA:[
"2a", "3a", "1a"
],
groupedB:[
"2b", "3b", "1b"
]
}