Skip to content

Commit d5507a5

Browse files
committed
test: add partitioned table creation test and improve existing table assertions
1 parent a0fc731 commit d5507a5

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

python/tests/test_dataframe.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,22 @@ def test_table_from_batches_dataframe(df, fail_collect):
16081608
assert isinstance(batch, pa.RecordBatch)
16091609

16101610

1611+
def test_table_from_batches_partitions(fail_collect):
1612+
ctx = SessionContext()
1613+
1614+
batch1 = pa.record_batch([pa.array([1])], names=["a"])
1615+
batch2 = pa.record_batch([pa.array([2])], names=["a"])
1616+
df = ctx.create_dataframe([[batch1], [batch2]])
1617+
1618+
table = pa.Table.from_batches(df)
1619+
expected = pa.Table.from_batches([batch1, batch2])
1620+
1621+
assert table.equals(expected)
1622+
1623+
for batch in df:
1624+
assert isinstance(batch, RecordBatch)
1625+
1626+
16111627
def test_arrow_c_stream_to_table_and_reader(fail_collect):
16121628
ctx = SessionContext()
16131629

python/tests/test_io.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ def test_table_from_batches_stream(ctx, fail_collect):
129129
df = range_table(ctx, 0, 10)
130130

131131
table = pa.Table.from_batches(df)
132-
assert table.shape == (10, 1)
133-
assert table.column_names == ["value"]
132+
expected = pa.Table.from_arrays([pa.array(range(10))], names=["value"])
133+
134+
assert table.equals(expected)
134135

135136
for batch in df:
136137
assert isinstance(batch, pa.RecordBatch)

0 commit comments

Comments
 (0)