Implements group_by, projection and offset on datastore Query.