

def _exists_subquery(translator, expr):
    op = expr.op()
    ctx = translator.context
    dummy = ir.literal(1).name(ir.unnamed)
    filtered = op.foreign_table.filter(op.predicates)
    expr = filtered.projection([dummy])
    subquery = ctx.get_compiled_expr(expr)
    if isinstance(op, transforms.ExistsSubquery):
        key = 'EXISTS'
    elif isinstance(op, transforms.NotExistsSubquery):
        key = 'NOT EXISTS'
    else:
        raise NotImplementedError
    return '{0} (\n{1}\n)'.format(key, util.indent(subquery, ctx.indent))

dataset/ETHPy150Open cloudera/ibis/ibis/impala/compiler.py _exists_subquery/original