Google BigQuery v2 API - Class BigQueryResults (3.10.0)

public sealed class BigQueryResults : IEnumerable<BigQueryRow>, IEnumerable

Reference documentation and code samples for the Google BigQuery v2 API class BigQueryResults.

The results of a completed query.

Inheritance

object > BigQueryResults

Namespace

Google.Cloud.BigQuery.V2

Assembly

Google.Cloud.BigQuery.V2.dll

Constructors

BigQueryResults(BigQueryClient, GetQueryResultsResponse, TableReference, GetQueryResultsOptions)

public BigQueryResults(BigQueryClient client, GetQueryResultsResponse response, TableReference tableReference, GetQueryResultsOptions options)

Constructs a new set of results.

Parameters
Name Description
client BigQueryClient

The client to use for further operations. Must not be null.

response GetQueryResultsResponse

The response to a GetQueryResults API call. Must not be null.

tableReference TableReference

A reference to the table containing the results. May be null. (For example, script queries don't store results in tables.)

options GetQueryResultsOptions

Options to use when fetching results. May be null.

Remarks

This is public to allow tests to construct instances for production code to consume; production code should not normally construct instances itself.

Properties

CacheHit

public bool CacheHit { get; }

Whether the query result was fetched from the query cache.

Property Value
Type Description
bool

JobReference

public JobReference JobReference { get; }

The reference to the query job.

Property Value
Type Description
JobReference

NumDmlAffectedRows

public long? NumDmlAffectedRows { get; }

The total number of rows affected by a DML statement, or null for non-DML results.

Property Value
Type Description
long

Schema

public TableSchema Schema { get; }

The schema of the query.

Property Value
Type Description
TableSchema

TableReference

public TableReference TableReference { get; }

The reference to the table containing the query results. May be null. (For example, script queries don't store results in tables.)

Property Value
Type Description
TableReference

TotalRows

public ulong? TotalRows { get; }

The total number of rows in the results, or null if the query results do not provide a row count.

Property Value
Type Description
ulong

Methods

GetEnumerator()

public IEnumerator<BigQueryRow> GetEnumerator()

Returns an iterator over the query results.

Returns
Type Description
IEnumeratorBigQueryRow

An iterator over the query results.

GetRowsAsync()

public IAsyncEnumerable<BigQueryRow> GetRowsAsync()

Returns an asynchronous sequence of rows from this set of results.

Returns
Type Description
IAsyncEnumerableBigQueryRow

An asynchronous sequence of rows from this set of results.

Remarks

This method exists rather than making the class implement IAsyncEnumerable<T> to avoid ambiguity.

ReadPage(int)

public BigQueryPage ReadPage(int pageSize)

Eagerly fetches a set of rows, up to the specified count, providing a page of results with a next page token if more results are available. This is typically used within web applications, where the next page token is propagated to the client along with the results, so that the next page can be retrieved in another request.

Parameter
Name Description
pageSize int

The maximum number of rows to retrieve. Must be positive.

Returns
Type Description
BigQueryPage

An in-memory result set of at most the given number of rows.

ReadPageAsync(int, CancellationToken)

public Task<BigQueryPage> ReadPageAsync(int pageSize, CancellationToken cancellationToken = default)

Asynchronously but eagerly fetches a set of rows, up to the specified count, providing a page of results with a next page token if more results are available. This is typically used within web applications, where the next page token is propagated to the client along with the results, so that the next page can be retrieved in another request.

Parameters
Name Description
pageSize int

The maximum number of rows to retrieve. Must be positive.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns
Type Description
TaskBigQueryPage

A task representing the asynchronous operation. When complete, the result is an in-memory result set of at most the given number of rows.

ThrowOnAnyError()

public BigQueryResults ThrowOnAnyError()

Returns this if the job has no errors, or throws an exception containing the errors. A job may have errors but still contain useful information.

Returns
Type Description
BigQueryResults

this if the job has no errors.

Exceptions
Type Description
GoogleApiException

The job has errors.