Skip to content

Commit 7789322

Browse files
committed
Rename to_record_batch_stream to execute_stream and update references in the codebase; mark the old method as deprecated.
1 parent 8a250a4 commit 7789322

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

docs/source/user-guide/dataframe/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ Asynchronous iteration is supported as well, allowing integration with
194194
... # process each batch as it is produced
195195
196196
To work with the stream directly, use
197-
``to_record_batch_stream()``, which returns a
197+
``execute_stream()``, which returns a
198198
:class:`~datafusion.RecordBatchStream`:
199199

200200
.. code-block:: python
201201
202-
stream = df.to_record_batch_stream()
202+
stream = df.execute_stream()
203203
for batch in stream:
204204
...
205205

python/datafusion/dataframe.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,9 +1040,12 @@ def execute_stream_partitioned(self) -> list[RecordBatchStream]:
10401040
streams = self.df.execute_stream_partitioned()
10411041
return [RecordBatchStream(rbs) for rbs in streams]
10421042

1043-
def to_record_batch_stream(self) -> RecordBatchStream: # noqa: F811
1043+
@deprecated("Use execute_stream() instead")
1044+
def to_record_batch_stream(self) -> RecordBatchStream:
10441045
"""Return a :py:class:`RecordBatchStream` over this DataFrame's results.
10451046
1047+
This method is deprecated. Use :py:meth:`execute_stream` instead.
1048+
10461049
Returns:
10471050
A ``RecordBatchStream`` representing the lazily generated record
10481051
batches for this DataFrame.
@@ -1133,11 +1136,11 @@ def __arrow_c_stream__(self, requested_schema: object | None = None) -> object:
11331136

11341137
def __iter__(self) -> Iterator[RecordBatch]:
11351138
"""Return an iterator over this DataFrame's record batches."""
1136-
return iter(self.to_record_batch_stream())
1139+
return iter(self.execute_stream())
11371140

11381141
def __aiter__(self) -> AsyncIterator[RecordBatch]:
11391142
"""Return an async iterator over this DataFrame's record batches."""
1140-
return self.to_record_batch_stream().__aiter__()
1143+
return self.execute_stream().__aiter__()
11411144

11421145
def transform(self, func: Callable[..., DataFrame], *args: Any) -> DataFrame:
11431146
"""Apply a function to the current DataFrame which returns another DataFrame.

python/tests/test_dataframe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,8 @@ def test_iter_returns_datafusion_recordbatch(df):
403403
assert isinstance(batch, RecordBatch)
404404

405405

406-
def test_to_record_batch_stream(df):
407-
stream = df.to_record_batch_stream()
406+
def test_execute_stream_basic(df):
407+
stream = df.execute_stream()
408408
batches = list(stream)
409409

410410
assert len(batches) == 1

0 commit comments

Comments
 (0)