import pyarrow


def concat_arrow_table_partitions(axis, partitions):
    """
    Concatenate given `partitions` in a single table.

    Parameters
    ----------
    axis : {0, 1}
        The axis to concatenate over.
    partitions : array-like
        Array with partitions for concatenating.

    Returns
    -------
    pyarrow.Table
        ``pyarrow.Table`` constructed from the passed partitions.
    """
    if axis == 0:
        table = pyarrow.Table.from_batches(
            [part.to_batches(part.num_rows)[0] for part in partitions]
        )
    else:
        table = partitions[0].drop([partitions[0].columns[-1].name])
        for obj in partitions[1:]:
            i = 0
            for col in obj.itercolumns():
                if i < obj.num_columns - 1:
                    table = table.append_column(col)
                i += 1
        table = table.append_column(partitions[0].columns[-1])
    return table