Skip to content

Commit 7391b73

Browse files
committed
test: add batch iteration test for DataFrame
1 parent dd1701f commit 7391b73

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

python/tests/test_dataframe.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,23 @@ def test_cast(df):
379379
assert df.schema() == expected
380380

381381

382+
def test_iter_batches(df):
383+
batches = []
384+
for batch in df:
385+
batches.append(batch) # noqa: PERF402
386+
387+
# Delete DataFrame to ensure RecordBatches remain valid
388+
del df
389+
390+
assert len(batches) == 1
391+
392+
batch = batches[0]
393+
assert isinstance(batch, pa.RecordBatch)
394+
assert batch.column(0).to_pylist() == [1, 2, 3]
395+
assert batch.column(1).to_pylist() == [4, 5, 6]
396+
assert batch.column(2).to_pylist() == [8, 5, 8]
397+
398+
382399
def test_with_column_renamed(df):
383400
df = df.with_column("c", column("a") + column("b")).with_column_renamed("c", "sum")
384401

0 commit comments

Comments
 (0)