Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay Chia committed Aug 15, 2024
1 parent 6589fde commit 4a1bc88
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/cookbook/test_count_rows.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ def test_count_rows(daft_df, service_requests_csv_pd_df, repartition_nparts):
assert daft_df_row_count == service_requests_csv_pd_df.shape[0]


def test_dataframe_count_no_args(daft_df, service_requests_csv_pd_df):
"""Counts rows using `df.count()` without any arguments"""
results = daft_df.count().to_pydict()
assert "count" in results
assert len(results["count"]) == 1
assert results["count"][0] == service_requests_csv_pd_df.shape[0]


def test_filtered_count_rows(daft_df, service_requests_csv_pd_df, repartition_nparts):
"""Count rows on a table filtered by a certain condition"""
daft_df_row_count = daft_df.repartition(repartition_nparts).where(col("Borough") == "BROOKLYN").count_rows()
Expand Down

0 comments on commit 4a1bc88

Please sign in to comment.