def METHOD_NAME(ht, field, value, key=None) -> Table:
    """Spread a key-value pair of fields across multiple fields.
    :func:`.spread` mimics the functionality of the `spread()` function in R's
    `tidyr` package. This is a way to turn "long" format data into "wide"
    format data.
    Given a ``field``, :func:`.spread` will create a new table by grouping
    ``ht`` by its row key and, optionally, any additional fields passed to the
    ``key`` argument.
    After collapsing ``ht`` by these keys, :func:`.spread` creates a new row field
    for each unique value of ``field``, where the row field values are given by the
    corresponding ``value`` in the original ``ht``.
    Parameters
    ----------
    ht : :class:`.Table`
        A Hail table.
    field : :class:`str`
        The name of the factor field in `ht`.
    value : :class:`str`
        The name of the value field in `ht`.
    key : optional, obj:`str` or list of :class:`str`
        The name of any fields to group by, in addition to the
        row key fields of ``ht``.
    Returns
    -------
    :class:`.Table`
        Table with original ``key`` and ``value`` fields spread across multiple columns."""
    if key is None:
        key = list(ht.key)
    else:
        key = wrap_to_list(key)
        key = list(ht.key) + key
    field_vals = list(ht.aggregate(hl.agg.collect_as_set(ht[field])))
    ht = (ht.group_by(*key)
            .aggregate(**{rv: hl.agg.take(ht[rv], 1)[0] for rv in ht.row_value if rv not in set(key + [field, value])},
                       **{fv: hl.agg.filter(ht[field] == fv,
                                            hl.rbind(
                                                hl.agg.take(ht[value], 1),
                                                lambda take: hl.if_else(hl.len(take) > 0,
                                                                        take[0],
                                                                        'NA'))) for fv in field_vals}))
    ht_tmp = new_temp_file()
    ht.write(ht_tmp)
    return ht