Fix type cast on group sum with custom expression

For PG adapters with custom expression and grouped result
of aggregate functions have not found correct column type
for it. Extract column type from query result.

Closes: #13230
Merge pull request #13236 from jetthoughts/13230_type_cast_bug_in_agr_functions

Fix type cast on group sum with custom expression