def test_lean_by_with_summary(): assert lean_projection(by(t.x, total=t.y.sum()))._child.isidentical(t[["x", "y"]]) tt = t[["x", "y"]] result = lean_projection(by(t.x, a=t.y.sum(), b=t.z.sum())[["x", "a"]]) expected = Projection(By(Field(tt, "x"), summary(a=sum(Field(tt, "y")))), ("x", "a")) assert result.isidentical(expected)
def test_lean_by_with_summary(): assert lean_projection(by(t.x, total=t.y.sum()))._child.isidentical( t[['x', 'y']]) tt = t[['x', 'y']] result = lean_projection(by(t.x, a=t.y.sum(), b=t.z.sum())[['x', 'a']]) expected = Projection(By(Field(tt, 'x'), summary(a=sum(Field(tt, 'y')))), ('x', 'a')) assert result.isidentical(expected)
def test_lean_by_with_summary(): assert lean_projection(by(t.x, total=t.y.sum()))._child.isidentical( t[['x', 'y']]) tt = t[['x', 'y']] result = lean_projection(by(t.x, a=t.y.sum(), b=t.z.sum())[['x', 'a']]) expected = Projection( By(Field(tt, 'x'), summary(a=sum(Field(tt, 'y')))), ('x', 'a')) assert result.isidentical(expected)
def test_merge(): expr = lean_projection(merge(a=t.x + 1, y=t.y)) assert expr._child.isidentical(t[['x', 'y']])
def test_distinct(): expr = t.distinct()[['x', 'y']] assert lean_projection(expr).isidentical(expr)
def test_sort(): assert lean_projection(t.sort('x').y).isidentical(t[['x','y']].sort('x').y)
def test_lean_projection_by(): assert lean_projection(by(t.x, t.y.sum()))._child.isidentical( t[['x', 'y']])
def optimize(expr, _): return lean_projection(expr)
def test_merge_with_table(): expr = lean_projection(merge(t, a=t.x + 1)) assert expr.isidentical(expr) # wut?
def test_merge(): expr = lean_projection(merge(a=t.x + 1, y=t.y)) assert expr._child.isidentical(t[["x", "y"]])
def test_sort(): assert lean_projection(t.sort("x").y).isidentical(t[["x", "y"]].sort("x").y)
def test_lean_projection_by(): assert lean_projection(by(t.x, total=t.y.sum()))._child.isidentical(t[["x", "y"]])
def test_lean_projection(): assert lean_projection(t[t.x > 0].y)._child._child.isidentical(t[["x", "y"]])
def test_like(): t = symbol('t', 'var * {name: string, x: int, y: int}') expr = t.like(name='Alice').y result = lean_projection(expr) assert result._child._child.isidentical(t[['name', 'y']])
def test_merge_with_table(): expr = lean_projection(merge(t, a=t.x + 1)) assert expr.isidentical(expr)
def test_elemwise_thats_also_a_column(): t = symbol('t', 'var * {x: int, time: datetime, y: int}') expr = t[t.x > 0].time.truncate(months=1) expected = t[['time', 'x']] result = lean_projection(expr) assert result._child._child._child.isidentical(t[['time', 'x']])
def test_head(): assert lean_projection(t.sort("x").y.head(5)).isidentical(t[["x", "y"]].sort("x").y.head(5))
def test_like(): t = symbol('t', 'var * {name: string, x: int, y: int}') expr = t[t.name.like('Alice')].y result = lean_projection(expr) assert result._child._child.isidentical(t[['name', 'y']])
def test_elemwise_thats_also_a_column(): t = symbol("t", "var * {x: int, time: datetime, y: int}") expr = t[t.x > 0].time.truncate(months=1) expected = t[["time", "x"]] result = lean_projection(expr) assert result._child._child._child.isidentical(expected)
def test_lean_projection(): assert lean_projection(t[t.x > 0].y)._child._child.isidentical(t[['x', 'y']])
def test_distinct(): expr = t.distinct()[["x", "y"]] assert lean_projection(expr).isidentical(expr)
def test_like(): t = symbol("t", "var * {name: string, x: int, y: int}") expr = t[t.name.like("Alice")].y result = lean_projection(expr) assert result._child._child.isidentical(t[["name", "y"]])
def test_head(): assert lean_projection(t.sort('x').y.head(5)).isidentical( t[['x','y']].sort('x').y.head(5))