Fix the out of memory issue caused by the built-in array_agg