Skip to content

Commit

Permalink
add a unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Chloe He committed Jul 1, 2024
1 parent 27d3cc4 commit 6f14e43
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion ibis/backends/flink/tests/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_rows_window(simple_table, assert_sql):
assert_sql(expr)


def test_tumble_window_by_agg(con):
def test_tumble_window_by_grouped_agg(con):
t = con.table("functional_alltypes_with_watermark")
expr = (
t.window_by(time_col=t.timestamp_col)
Expand All @@ -76,3 +76,15 @@ def test_tumble_window_by_agg(con):
result = expr.to_pandas()
assert list(result.columns) == ["window_start", "window_end", "string_col", "avg"]
assert result.shape == (610, 4)


def test_tumble_window_by_global_agg(con):
t = con.table("functional_alltypes_with_watermark")
expr = (
t.window_by(time_col=t.timestamp_col)
.tumble(size=ibis.interval(seconds=30))
.agg(avg=_.float_col.mean())
)
result = expr.to_pandas()
assert list(result.columns) == ["window_start", "window_end", "avg"]
assert result.shape == (610, 3)
2 changes: 1 addition & 1 deletion ibis/tests/expr/test_temporal_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_window_by_with_non_timestamp_column(table):
ids=["tumble", "hop"],
)
@pytest.mark.parametrize("by", ["g", _.g, ["g"]])
def test_window_by_group_by_agg(table, method, by):
def test_window_by_grouped_agg(table, method, by):
expr = method(table.window_by(time_col=table.i))
expr = expr.group_by(by).agg(a_sum=_.a.sum())
expected_schema = ibis.schema(
Expand Down

0 comments on commit 6f14e43

Please sign in to comment.