Skip to content

Commit c332403

Browse files
committed
[data] add test for concatenating blocks
Signed-off-by: Wang Jingxin <[email protected]>
1 parent 74b4f0b commit c332403

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

python/ray/data/tests/test_arrow_block.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,5 +552,36 @@ def test_arrow_block_max_chunk_size(table_data, max_chunk_size_bytes, expected):
552552
assert _get_max_chunk_size(table, max_chunk_size_bytes) == expected
553553

554554

555+
def test_arrow_block_concat():
556+
def gen_block(table):
557+
if table["item"][0].as_py() == 0:
558+
return pa.table(
559+
{
560+
"a": [1, 2, 3],
561+
"s": [
562+
{
563+
"x": 7,
564+
},
565+
{
566+
"x": 8,
567+
},
568+
{
569+
"x": 9,
570+
},
571+
],
572+
}
573+
)
574+
return pa.table(
575+
{
576+
"b": [4, 5, 6],
577+
}
578+
)
579+
580+
dataset = ray.data.from_items([0, 1], override_num_blocks=2)
581+
mapped = dataset.map_batches(gen_block, batch_size=1, batch_format="pyarrow")
582+
mapped = mapped.map_batches(lambda x: x, batch_size=2, batch_format="pyarrow")
583+
mapped.materialize()
584+
585+
555586
if __name__ == "__main__":
556587
sys.exit(pytest.main(["-v", __file__]))

0 commit comments

Comments
 (0)