MCPcopy Create free account
hub / github.com/apache/arrow / test_stream_write_table_batches

Function test_stream_write_table_batches

python/pyarrow/tests/test_ipc.py:382–402  ·  view source on GitHub ↗
(stream_fixture)

Source from the content-addressed store, hash-verified

380
381@pytest.mark.pandas
382def test_stream_write_table_batches(stream_fixture):
383 # ARROW-504
384 df = pd.DataFrame({
385 'one': np.random.randn(20),
386 })
387
388 b1 = pa.RecordBatch.from_pandas(df[:10], preserve_index=False)
389 b2 = pa.RecordBatch.from_pandas(df, preserve_index=False)
390
391 table = pa.Table.from_batches([b1, b2, b1])
392
393 with stream_fixture._get_writer(stream_fixture.sink, table.schema) as wr:
394 wr.write_table(table, max_chunksize=15)
395
396 batches = list(pa.ipc.open_stream(stream_fixture.get_source()))
397
398 assert list(map(len, batches)) == [10, 15, 5, 10]
399 result_table = pa.Table.from_batches(batches)
400 assert_frame_equal(result_table.to_pandas(),
401 pd.concat([df[:10], df, df[:10]],
402 ignore_index=True))
403
404
405def test_stream_simple_roundtrip(stream_fixture):

Callers

nothing calls this directly

Calls 5

listFunction · 0.85
mapFunction · 0.85
get_sourceMethod · 0.80
_get_writerMethod · 0.45
write_tableMethod · 0.45

Tested by

no test coverage detected