Google BigQuery v2 API - Class BigQueryResults (3.8.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
NameDescription
clientBigQueryClient

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

responseGetQueryResultsResponse

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

tableReferenceTableReference

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

optionsGetQueryResultsOptions

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
TypeDescription
bool

JobReference

public JobReference JobReference { get; }

The reference to the query job.

Property Value
TypeDescription
JobReference

NumDmlAffectedRows

public long? NumDmlAffectedRows { get; }

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

Property Value
TypeDescription
long

Schema

public TableSchema Schema { get; }

The schema of the query.

Property Value
TypeDescription
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
TypeDescription
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
TypeDescription
ulong

Methods

GetEnumerator()

public IEnumerator<BigQueryRow> GetEnumerator()

Returns an iterator over the query results.

Returns
TypeDescription
IEnumeratorBigQueryRow

An iterator over the query results.

GetRowsAsync()

public IAsyncEnumerable<BigQueryRow> GetRowsAsync()

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

Returns
TypeDescription
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
NameDescription
pageSizeint

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

Returns
TypeDescription
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
NameDescription
pageSizeint

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

cancellationTokenCancellationToken

The token to monitor for cancellation requests.

Returns
TypeDescription
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
TypeDescription
BigQueryResults

this if the job has no errors.

Exceptions
TypeDescription
GoogleApiException

The job has errors.