Fix group by clauses on metasql queries for 8.4 compatibility