

@dispatch(Tail)
def _subexpr_optimize(expr):
    child = sorter = expr._child
    while (not isinstance(sorter, Sort)):
        try:
            sorter = sorter._child
        except AttributeError:
            break
    else:
        return child._subs({
            sorter: sorter._child.sort(sorter._key, ascending=(not sorter.ascending)),
        }).head(expr.n).sort(sorter._key, ascending=sorter.ascending)
    warnings.warn("'tail' of a sql operation with no sort is the same as 'head'")
    return sorter.head(expr.n)

dataset/ETHPy150Open blaze/blaze/blaze/compute/sql.py _subexpr_optimize/VarMisuse@123/182 `child`->`sorter`