Fix a bug with PG (the built-in sum does not support array type)