# tfio.bigquery.BigQueryReadSession

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/bigquery_dataset_ops.py#L238-L354) |

Entry point for reading data from Cloud BigQuery.

    tfio.bigquery.BigQueryReadSession(
        parent, project_id, table_id, dataset_id, selected_fields,
        selected_fields_repeated, output_types, default_values, row_restriction,
        requested_streams, data_format, streams, schema, client_resource
    )

## Methods

### `get_streams`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/bigquery_dataset_ops.py#L273-L279)

    get_streams()

Returns Tensor with stream names for reading data from BigQuery.

<br />

<br />

<br />

| Returns ||
|---|---|
| Tensor with stream names. ||

<br />

### `parallel_read_rows`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/bigquery_dataset_ops.py#L306-L354)

    parallel_read_rows(
        cycle_length=None, sloppy=False, block_length=1, num_parallel_calls=None
    )

Retrieves rows from the BigQuery service in parallel streams.

    bq_client = BigQueryClient()
    bq_read_session = bq_client.read_session(...)
    ds1 = bq_read_session.parallel_read_rows(...)

Args:
cycle_length: number of streams to process in parallel. If not specified, it
is defaulted to the number of streams in the read session.
sloppy: If false, elements are produced in deterministic order. If true,
the implementation is allowed, for the sake of expediency, to produce
elements in a non-deterministic order.
When reading from multiple BigQuery streams, setting sloppy=True usually
yields a better performance.
block_length: The number of consecutive elements to pull from a session stream
before advancing to the next one.
num_parallel_calls: Number of threads to use for processing input streams.
If the value [`tf.data.experimental.AUTOTUNE`](https://www.tensorflow.org/api_docs/python/tf/data/experimental#AUTOTUNE) is used, then the number of
parallel calls is set dynamically based on available CPU.
Defaulted to the number of streams in the read session.

<br />

<br />

<br />

| Returns ||
|---|---|
| A [`tf.data.Dataset`](https://www.tensorflow.org/api_docs/python/tf/data/Dataset) returning the row keys and the cell contents. ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `ValueError` | If the configured probability is unexpected. |

<br />

### `read_rows`

[View source](https://github.com/tensorflow/io/blob/v0.24.0/tensorflow_io/python/ops/bigquery_dataset_ops.py#L281-L304)

    read_rows(
        stream, offset=0
    )

Retrieves rows (including values) from the BigQuery service.

<br />

<br />

<br />

| Args ||
|---|---|
| `stream` | name of the stream to read from. |
| `offset` | Position in the stream. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A [`tf.data.Dataset`](https://www.tensorflow.org/api_docs/python/tf/data/Dataset) returning the row keys and the cell contents. ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `ValueError` | If the configured probability is unexpected. |

<br />