Beispiel #1
0
def test_sql_mutate(db):
    tbl = LazyTbl(db, addresses, funcs=funcs)
    f = mutate(user_id2=_.user_id + 1)
    out1 = tbl >> f >> collect()
    out2 = tbl >> collect() >> f

    assert_frame_equal(out1, out2)
Beispiel #2
0
def assert_equal_query(tbl, lazy_query, target, **kwargs):
    out = collect(lazy_query(tbl))

    if isinstance(tbl, pd.DataFrame):
        df_a = ungroup(out).reset_index(drop=True)
        df_b = ungroup(target).reset_index(drop=True)
        assert_frame_equal(df_a, df_b, **kwargs)
    else:
        assert_frame_sort_equal(out, target, **kwargs)
def test_distinct_keep_all_not_impl(backend, df):
    # TODO: should just mock LazyTbl
    with pytest.raises(NotImplementedError):
        distinct(df, _.y, _keep_all = True) >> collect()
Beispiel #4
0
def assert_equal_query(tbl, lazy_query, target):
    out = collect(lazy_query(tbl))
    assert_frame_sort_equal(out, target)