Exemplo n.º 1
0
def check_keys(caller, name, protected_key):
    from hail.expr.expressions import ExpressionException
    if name in protected_key:
        msg = f"{caller!r}: cannot overwrite key field {name!r} with annotate, select or drop; " \
              f"use key_by to modify keys."
        error('Analysis exception: {}'.format(msg))
        raise ExpressionException(msg)
Exemplo n.º 2
0
def check_collisions(caller, names, indices, override_protected_indices=None):
    from hail.expr.expressions import ExpressionException
    fields = indices.source._fields

    if override_protected_indices is not None:

        def invalid(e):
            return e._indices in override_protected_indices
    else:

        def invalid(e):
            return e._indices != indices

    # check collisions with fields on other axes
    for name in names:
        if name in fields and invalid(fields[name]):
            msg = f"{caller!r}: name collision with field indexed by {list(fields[name]._indices.axes)}: {name!r}"
            error('Analysis exception: {}'.format(msg))
            raise ExpressionException(msg)

    # check duplicate fields
    for k, v in Counter(names).items():
        if v > 1:
            from hail.expr.expressions import ExpressionException
            raise ExpressionException(
                f"{caller!r}: selection would produce duplicate field {k!r}")
Exemplo n.º 3
0
def check_collisions(fields, name, indices):
    from hail.expr.expressions import ExpressionException
    if name in fields and not fields[name]._indices == indices:
        msg = 'name collision with field indexed by {}: {}'.format(
            list(fields[name]._indices.axes), name)
        error('Analysis exception: {}'.format(msg))
        raise ExpressionException(msg)
Exemplo n.º 4
0
def check_keys(name, indices):
    from hail.expr.expressions import ExpressionException
    if indices.key is None:
        return
    if name in set(indices.key):
        msg = "cannot overwrite key field {} with annotate, select or drop; use key_by to modify keys.".format(repr(name))
        error('Analysis exception: {}'.format(msg))
        raise ExpressionException(msg)
Exemplo n.º 5
0
def check_keys(name, indices):
    from hail.expr.expressions import ExpressionException
    if indices.key is None:
        return
    if name in set(indices.key):
        msg = "cannot overwrite key field {} with annotate, select or drop; use key_by to modify keys.".format(repr(name))
        error('Analysis exception: {}'.format(msg))
        raise ExpressionException(msg)
Exemplo n.º 6
0
def check_collisions(fields, name, indices):
    from hail.expr.expressions import ExpressionException
    if name in fields and not fields[name]._indices == indices:
        msg = "name collision with field indexed by {}: {}".format(list(fields[name]._indices.axes), repr(name))
        error('Analysis exception: {}'.format(msg))
        raise ExpressionException(msg)