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:406–426  ·  view source on GitHub ↗
(stream_fixture)

Source from the content-addressed store, hash-verified

404
405@pytest.mark.pandas
406def test_stream_write_table_batches(stream_fixture):
407 # ARROW-504
408 df = pd.DataFrame({
409 'one': np.random.randn(20),
410 })
411
412 b1 = pa.RecordBatch.from_pandas(df[:10], preserve_index=False)
413 b2 = pa.RecordBatch.from_pandas(df, preserve_index=False)
414
415 table = pa.Table.from_batches([b1, b2, b1])
416
417 with stream_fixture._get_writer(stream_fixture.sink, table.schema) as wr:
418 wr.write_table(table, max_chunksize=15)
419
420 batches = list(pa.ipc.open_stream(stream_fixture.get_source()))
421
422 assert list(map(len, batches)) == [10, 15, 5, 10]
423 result_table = pa.Table.from_batches(batches)
424 assert_frame_equal(result_table.to_pandas(),
425 pd.concat([df[:10], df, df[:10]],
426 ignore_index=True))
427
428
429def 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