Exemplo n.º 1
0
def test_column_ref_table_aliases():
    context = ImpalaCompiler.make_context()

    table1 = ibis.table([('key1', 'string'), ('value1', 'double')])

    table2 = ibis.table([('key2', 'string'), ('value and2', 'double')])

    context.set_ref(table1, 't0')
    context.set_ref(table2, 't1')

    expr = table1['value1'] - table2['value and2']

    result = translate(expr, context=context)
    expected = 't0.`value1` - t1.`value and2`'
    assert result == expected
Exemplo n.º 2
0
def test_correlated_predicate_subquery(table):
    t0 = table
    t1 = t0.view()

    expr = t0.g == t1.g

    ctx = ImpalaCompiler.make_context()
    ctx.make_alias(t0)

    # Grab alias from parent context
    subctx = ctx.subcontext()
    subctx.make_alias(t1)
    subctx.make_alias(t0)

    result = translate(expr, context=subctx)
    expected = "t0.`g` = t1.`g`"
    assert result == expected
Exemplo n.º 3
0
def translate(expr, context=None, named=False):
    if context is None:
        context = ImpalaCompiler.make_context()
    translator = ImpalaExprTranslator(expr, context=context, named=named)
    return translator.get_result()