@dispatch(By, ClauseElement)
def compute_up(expr, data, **kwargs):
    if not valid_grouper(expr.grouper):
        raise TypeError("Grouper must have a non-nested record or one "
                        "dimensional collection datashape, "
                        "got %s of type %r with dshape %s" %
                        (expr.grouper, type(expr.grouper).__name__,
                         expr.grouper.dshape))
    grouper = get_inner_columns(
        compute(
            expr.grouper,
            data,
            post_compute=False,
            return_type='native',
        ),
    )
    app = expr.apply
    reductions = [
        compute(
            val,
            data,
            post_compute=False,
            return_type='native',
        ).label(name)
        for val, name in zip(app.values, app.fields)
    ]

    return sa.select(grouper + reductions).group_by(*grouper)
dataset/ETHPy150Open blaze/blaze/blaze/compute/sql.py/compute_up/original