def _clean_join_predicates(left, right, predicates):
    import ibis.expr.analysis as L
    result = []
    if (not isinstance(predicates, (list, tuple))):
        predicates = [predicates]
    for pred in predicates:
        if isinstance(pred, tuple):
            if (len(pred) != 2):
                raise com.ExpressionError('Join key tuple must be length 2')
            (lk, rk) = pred
            lk = left._ensure_expr(lk)
            rk = right._ensure_expr(rk)
            pred = (lk == rk)
        elif isinstance(pred, str):
            pred = (left[pred] == right[pred])
        elif (not isinstance(pred, ir.Expr)):
            raise NotImplementedError
        if (not isinstance(pred, ir.BooleanColumn)):
            raise com.ExpressionError('Join predicate must be comparison')
        preds = L.flatten_predicate(pred)
        result.extend(preds)
    _validate_join_predicates(left, right, result)
    return result
def _clean_join_predicates(left, right, predicates):
    import ibis.expr.analysis as L
    result = []
    if (not isinstance(predicates, (list, tuple))):
        predicates = [predicates]
    for pred in predicates:
        if isinstance(pred, tuple):
            if (len(pred) != 2):
                raise com.ExpressionError('Join key tuple must be length 2')
            (lk, rk) = pred
            lk = left._ensure_expr(lk)
            rk = right._ensure_expr(rk)
            pred = (lk == rk)
        elif isinstance(pred, str):
            pred = (left[pred] == right[pred])
        elif (not isinstance(pred, ir.Expr)):
            raise NotImplementedError
        if (not isinstance(pred, ir.BooleanColumn)):
            raise com.ExpressionError('Join predicate must be comparison')
        preds = L.flatten_predicate(pred)
        result.extend(preds)
    _validate_join_predicates(left, right, result)
    return result