def _filter_groupby_columns(by, cols, meta):
    """
    Checks ?_by=col&_by=col for filter().

    - ``by``: list of column names to group by
    - ``cols``: list of valid column names
    - ``meta``: meta['by'] and meta['ignored'] are updated

    Returns a list of columns to group by
    """
    colset = set(cols)
    for col in by:
        if col in colset:
            meta['by'].append(col)
        else:
            meta['ignored'].append(('_by', col))
    return meta['by']
