@@ -1505,7 +1505,8 @@ def test_to_arrow_table(df):
15051505
15061506def test_execute_stream (df ):
15071507 stream = df .execute_stream ()
1508- assert all (batch is not None for batch in stream )
1508+ batches = list (stream )
1509+ assert all (isinstance (batch , pa .RecordBatch ) for batch in batches )
15091510 assert not list (stream ) # after one iteration the generator must be exhausted
15101511
15111512
@@ -1526,30 +1527,9 @@ def test_execute_stream_to_arrow_table(df, schema):
15261527 stream = df .execute_stream ()
15271528
15281529 if schema :
1529- pyarrow_table = pa .Table .from_batches (
1530- (batch .to_pyarrow () for batch in stream ), schema = df .schema ()
1531- )
1530+ pyarrow_table = pa .Table .from_batches (stream , schema = df .schema ())
15321531 else :
1533- pyarrow_table = pa .Table .from_batches (batch .to_pyarrow () for batch in stream )
1534-
1535- assert isinstance (pyarrow_table , pa .Table )
1536- assert pyarrow_table .shape == (3 , 3 )
1537- assert set (pyarrow_table .column_names ) == {"a" , "b" , "c" }
1538-
1539-
1540- @pytest .mark .asyncio
1541- @pytest .mark .parametrize ("schema" , [True , False ])
1542- async def test_execute_stream_to_arrow_table_async (df , schema ):
1543- stream = df .execute_stream ()
1544-
1545- if schema :
1546- pyarrow_table = pa .Table .from_batches (
1547- [batch .to_pyarrow () async for batch in stream ], schema = df .schema ()
1548- )
1549- else :
1550- pyarrow_table = pa .Table .from_batches (
1551- [batch .to_pyarrow () async for batch in stream ]
1552- )
1532+ pyarrow_table = pa .Table .from_batches (stream )
15531533
15541534 assert isinstance (pyarrow_table , pa .Table )
15551535 assert pyarrow_table .shape == (3 , 3 )
@@ -1558,7 +1538,9 @@ async def test_execute_stream_to_arrow_table_async(df, schema):
15581538
15591539def test_execute_stream_partitioned (df ):
15601540 streams = df .execute_stream_partitioned ()
1561- assert all (batch is not None for stream in streams for batch in stream )
1541+ assert all (
1542+ isinstance (batch , pa .RecordBatch ) for stream in streams for batch in stream
1543+ )
15621544 assert all (
15631545 not list (stream ) for stream in streams
15641546 ) # after one iteration all generators must be exhausted
0 commit comments