

@dispatch(Join, ClauseElement, ClauseElement)
def compute_up(t, lhs, rhs, **kwargs):
    if isinstance(lhs, ColumnElement):
        lhs = select(lhs)
    if isinstance(rhs, ColumnElement):
        rhs = select(rhs)
    if (name(lhs) == name(rhs)):
        (left_suffix, right_suffix) = t.suffixes
        lhs = lhs.alias(('%s%s' % (name(lhs), left_suffix)))
        rhs = rhs.alias(('%s%s' % (name(rhs), right_suffix)))
    lhs = alias_it(lhs)
    rhs = alias_it(rhs)
    if isinstance(lhs, Select):
        lhs = lhs.alias(next(aliases))
        left_conds = [lhs.c.get(c) for c in listpack(t.on_left)]
    else:
        ldict = dict(((c.name, c) for c in inner_columns(lhs)))
        left_conds = [ldict.get(c) for c in listpack(t.on_left)]
    if isinstance(rhs, Select):
        rhs = rhs.alias(next(aliases))
        right_conds = [rhs.c.get(c) for c in listpack(t.on_right)]
    else:
        rdict = dict(((c.name, c) for c in inner_columns(rhs)))
        right_conds = [rdict.get(c) for c in listpack(t.on_right)]
    condition = reduce(and_, map(eq, left_conds, right_conds))
    if (t.how == 'inner'):
        join = _join_selectables(lhs, rhs, condition=condition)
        main = lhs
    elif (t.how == 'left'):
        (main, other) = (lhs, rhs)
        join = _join_selectables(lhs, rhs, condition=condition, isouter=True)
    elif (t.how == 'right'):
        join = _join_selectables(rhs, lhs, condition=condition, isouter=True)
        main = rhs
    else:
        raise ValueError("SQLAlchemy doesn't support full outer Join")
    "\n    We now need to arrange the columns in the join to match the columns in\n    the expression.  We care about order and don't want repeats\n    "
    if isinstance(join, Select):

        def cols(x):
            if isinstance(x, Select):
                return list(x.inner_columns)
            else:
                return list(x.columns)
    else:
        cols = (lambda x: list(x.columns))
    main_cols = cols(main)
    left_cols = cols(lhs)
    left_names = set(map(_getname, left_cols))
    right_cols = cols(rhs)
    right_names = set(map(_getname, right_cols))
    (left_suffix, right_suffix) = t.suffixes
    fields = [f.replace(left_suffix, '').replace(right_suffix, '') for f in t.fields]
    columns = [c for c in main_cols if (c.name in t._on_left)]
    columns += [_clean_join_name(right_names, left_suffix, c) for c in left_cols if ((c.name in fields) and (c.name not in t._on_left))]
    columns += [_clean_join_name(left_names, right_suffix, c) for c in right_cols if ((c.name in fields) and (c.name not in t._on_right))]
    if isinstance(join, Select):
        return join.with_only_columns(columns)
    else:
        return sa.select(columns, from_obj=join)

dataset/ETHPy150Open blaze/blaze/blaze/compute/sql.py compute_up/original