@@ -1812,6 +1812,7 @@ def to_arrow_iterable(
18121812 self ,
18131813 bqstorage_client : Optional ["bigquery_storage.BigQueryReadClient" ] = None ,
18141814 max_queue_size : int = _pandas_helpers ._MAX_QUEUE_SIZE_DEFAULT , # type: ignore
1815+ max_stream_count : Optional [int ] = None ,
18151816 ) -> Iterator ["pyarrow.RecordBatch" ]:
18161817 """[Beta] Create an iterable of class:`pyarrow.RecordBatch`, to process the table as a stream.
18171818
@@ -1836,6 +1837,22 @@ def to_arrow_iterable(
18361837 created by the server. If ``max_queue_size`` is :data:`None`, the queue
18371838 size is infinite.
18381839
1840+ max_stream_count (Optional[int]):
1841+ The maximum number of parallel download streams when
1842+ using BigQuery Storage API. Ignored if
1843+ BigQuery Storage API is not used.
1844+
1845+ This setting also has no effect if the query result
1846+ is deterministically ordered with ORDER BY,
1847+ in which case, the number of download stream is always 1.
1848+
1849+ If set to 0 or None (the default), the number of download
1850+ streams is determined by BigQuery the server. However, this behaviour
1851+ can require a lot of memory to store temporary download result,
1852+ especially with very large queries. In that case,
1853+ setting this parameter value to a value > 0 can help
1854+ reduce system resource consumption.
1855+
18391856 Returns:
18401857 pyarrow.RecordBatch:
18411858 A generator of :class:`~pyarrow.RecordBatch`.
@@ -1852,6 +1869,7 @@ def to_arrow_iterable(
18521869 preserve_order = self ._preserve_order ,
18531870 selected_fields = self ._selected_fields ,
18541871 max_queue_size = max_queue_size ,
1872+ max_stream_count = max_stream_count ,
18551873 )
18561874 tabledata_list_download = functools .partial (
18571875 _pandas_helpers .download_arrow_row_iterator , iter (self .pages ), self .schema
@@ -1978,6 +1996,7 @@ def to_dataframe_iterable(
19781996 bqstorage_client : Optional ["bigquery_storage.BigQueryReadClient" ] = None ,
19791997 dtypes : Optional [Dict [str , Any ]] = None ,
19801998 max_queue_size : int = _pandas_helpers ._MAX_QUEUE_SIZE_DEFAULT , # type: ignore
1999+ max_stream_count : Optional [int ] = None ,
19812000 ) -> "pandas.DataFrame" :
19822001 """Create an iterable of pandas DataFrames, to process the table as a stream.
19832002
@@ -2008,6 +2027,22 @@ def to_dataframe_iterable(
20082027
20092028 .. versionadded:: 2.14.0
20102029
2030+ max_stream_count (Optional[int]):
2031+ The maximum number of parallel download streams when
2032+ using BigQuery Storage API. Ignored if
2033+ BigQuery Storage API is not used.
2034+
2035+ This setting also has no effect if the query result
2036+ is deterministically ordered with ORDER BY,
2037+ in which case, the number of download stream is always 1.
2038+
2039+ If set to 0 or None (the default), the number of download
2040+ streams is determined by BigQuery the server. However, this behaviour
2041+ can require a lot of memory to store temporary download result,
2042+ especially with very large queries. In that case,
2043+ setting this parameter value to a value > 0 can help
2044+ reduce system resource consumption.
2045+
20112046 Returns:
20122047 pandas.DataFrame:
20132048 A generator of :class:`~pandas.DataFrame`.
@@ -2034,6 +2069,7 @@ def to_dataframe_iterable(
20342069 preserve_order = self ._preserve_order ,
20352070 selected_fields = self ._selected_fields ,
20362071 max_queue_size = max_queue_size ,
2072+ max_stream_count = max_stream_count ,
20372073 )
20382074 tabledata_list_download = functools .partial (
20392075 _pandas_helpers .download_dataframe_row_iterator ,
@@ -2690,6 +2726,7 @@ def to_dataframe_iterable(
26902726 bqstorage_client : Optional ["bigquery_storage.BigQueryReadClient" ] = None ,
26912727 dtypes : Optional [Dict [str , Any ]] = None ,
26922728 max_queue_size : Optional [int ] = None ,
2729+ max_stream_count : Optional [int ] = None ,
26932730 ) -> Iterator ["pandas.DataFrame" ]:
26942731 """Create an iterable of pandas DataFrames, to process the table as a stream.
26952732
@@ -2705,6 +2742,9 @@ def to_dataframe_iterable(
27052742 max_queue_size:
27062743 Ignored. Added for compatibility with RowIterator.
27072744
2745+ max_stream_count:
2746+ Ignored. Added for compatibility with RowIterator.
2747+
27082748 Returns:
27092749 An iterator yielding a single empty :class:`~pandas.DataFrame`.
27102750
@@ -2719,6 +2759,7 @@ def to_arrow_iterable(
27192759 self ,
27202760 bqstorage_client : Optional ["bigquery_storage.BigQueryReadClient" ] = None ,
27212761 max_queue_size : Optional [int ] = None ,
2762+ max_stream_count : Optional [int ] = None ,
27222763 ) -> Iterator ["pyarrow.RecordBatch" ]:
27232764 """Create an iterable of pandas DataFrames, to process the table as a stream.
27242765
@@ -2731,6 +2772,9 @@ def to_arrow_iterable(
27312772 max_queue_size:
27322773 Ignored. Added for compatibility with RowIterator.
27332774
2775+ max_stream_count:
2776+ Ignored. Added for compatibility with RowIterator.
2777+
27342778 Returns:
27352779 An iterator yielding a single empty :class:`~pyarrow.RecordBatch`.
27362780 """
0 commit comments