Fix for issue resulting from grouped queries that cross shards