def _get_join_indices(left_table, right_table, join_conditions):
    """Given the join conditions, return the indices of the columns used in the join."""

    left_indices = []
    right_indices = []
    for cond in join_conditions:
        for join_col_name in (cond.left_operand, cond.right_operand):

            left_col = left_table.get_column_for_name(join_col_name)
            right_col = right_table.get_column_for_name(join_col_name)

            assert not (left_col and right_col)

            if left_col:
                left_indices.append(left_table.column_idxs[left_col][0])
            elif right_col:
                right_indices.append(right_table.column_idxs[right_col][0])
            else:
                raise ValueError('Column name {0} not found on tables {1} or {2}'.format(
                    join_col_name,
                    left_table,
                    right_table
                    ))

    return zip(left_indices, right_indices)