'Validates that a query\'s projection and group by match.
Args:
projection: A set of string property names in the projection.
group_by: A set of string property names in the group by.
Raises:
datastore_errors.BadRequestError: if the projection and group
by sets are not equal.'

def _validate_projection_and_group_by(self, projection, group_by):

    if projection:
        if group_by:
            extra = (set(projection) - set(group_by))
            if extra:
                raise datastore_errors.BadRequestError(('projections    includes    properties    not    in    the    group_by    argument:    %s' % extra))
    elif group_by:
        raise datastore_errors.BadRequestError('cannot    specify    group_by    without    a    projection')
