Class ReadRowsStream

A stream of results from a read rows request.

This stream is an iterable of ReadRowsResponse. Iterate over it to fetch all row messages.

If the fastavro library is installed, use the rows() method to parse all messages into a stream of row dictionaries.

If the pandas and fastavro libraries are installed, use the to_dataframe() method to parse all messages into a pandas.DataFrame.

This object should not be created directly, but is returned by other methods in this library.

Inheritance

builtins.object > ReadRowsStream

Methods

__iter__

__iter__()

An iterable of messages.

Returns
TypeDescription
Iterable[ ReadRowsResponse ]A sequence of row messages.

rows

rows(read_session=None)

Iterate over all rows in the stream.

This method requires the fastavro library in order to parse row messages in avro format. For arrow format messages, the pyarrow library is required.

.. warning:: DATETIME columns are not supported. They are currently parsed as strings in the fastavro library.

Parameter
NameDescription
read_session Optional[ReadSession]

DEPRECATED. This argument was used to specify the schema of the rows in the stream, but now the first message in a read stream contains this information.

Returns
TypeDescription
Iterable[Mapping]A sequence of rows, represented as dictionaries.

to_arrow

to_arrow(read_session=None)

Create a pyarrow.Table of all rows in the stream.

This method requires the pyarrow library and a stream using the Arrow format.

Parameter
NameDescription
read_session ReadSession

DEPRECATED. This argument was used to specify the schema of the rows in the stream, but now the first message in a read stream contains this information.

Returns
TypeDescription
pyarrow.TableA table of all rows in the stream.

to_dataframe

to_dataframe(read_session=None, dtypes=None)

Create a pandas.DataFrame of all rows in the stream.

This method requires the pandas libary to create a data frame and the fastavro library to parse row messages.

.. warning:: DATETIME columns are not supported. They are currently parsed as strings.

Parameters
NameDescription
read_session ReadSession

DEPRECATED. This argument was used to specify the schema of the rows in the stream, but now the first message in a read stream contains this information.

dtypes Map[str, Union[str, pandas.Series.dtype]]

Optional. A dictionary of column names pandas dtypes. The provided dtype is used when constructing the series for the column specified. Otherwise, the default pandas behavior is used.

Returns
TypeDescription
pandas.DataFrameA data frame of all rows in the stream.