Reference documentation and code samples for the BigQuery Client class QueryResults.
QueryResults represent the result of a BigQuery SQL query. Read more at the Query Response API Documentation
This class should be not instantiated directly, but as a result of calling BigQueryClient::runQuery() or Job::queryResults().
Namespace
Google \ Cloud \ BigQueryMethods
__construct
| Parameters | |
|---|---|
| Name | Description | 
| connection | Connection\ConnectionInterfaceRepresents a connection to BigQuery. This object is created by BigQueryClient, and should not be instantiated outside of this client. | 
| jobId | stringThe job's ID. | 
| projectId | stringThe project's ID. | 
| info | arrayThe query result's metadata. | 
| mapper | ValueMapperMaps values between PHP and BigQuery. | 
| job | JobThe job from which the query results originated. | 
| queryResultsOptions | arrayDefault options to be used for calls to get query results. | 
rows
Retrieves the rows associated with the query and merges them together with the table's schema.
Refer to the table below for a guide on how BigQuery types are mapped as they come back from the API.
| PHP Type | BigQuery Data Type | 
|---|---|
| \DateTimeInterface | DATETIME | 
| Bytes | BYTES | 
| Date | DATE | 
| Google\Cloud\Core\Int64 | INTEGER | 
| Time | TIME | 
| Timestamp | TIMESTAMP | 
| Associative Array | RECORD | 
| Non-Associative Array | RECORD(Repeated) | 
| float | FLOAT | 
| int | INTEGER | 
| string | STRING | 
| bool | BOOLEAN | 
Example:
$rows = $queryResults->rows(); foreach ($rows as $row) { echo $row['name'] . PHP_EOL; } | Parameters | |
|---|---|
| Name | Description | 
| options | arrayConfiguration options. Please note, these options will inherit the values set by either BigQueryClient::runQuery() or Job::queryResults(). | 
| ↳ maxResults | intMaximum number of results to read per page. | 
| ↳ startIndex | intZero-based index of the starting row. | 
| ↳ timeoutMs | intHow long, in milliseconds, each API call will wait for query results to become available before timing out. Depending on whether the $maxRetries has been exceeded, the results will be polled again after the timeout has been reached. Defaults to  | 
| ↳ maxRetries | intThe number of times to poll the Job status, until the job is complete. By default, will poll indefinitely. | 
| ↳ returnRawResults | boolReturns the raw data types returned from BigQuery without converting their values into native PHP types or the custom type classes supported by this library. | 
| Returns | |
|---|---|
| Type | Description | 
| Google\Cloud\Core\Iterator\ItemIterator | |
waitUntilComplete
Blocks until the query is complete.
Example:
$queryResults->waitUntilComplete(); | Parameters | |
|---|---|
| Name | Description | 
| options | arrayConfiguration options. Please note, these options will inherit the values set by either BigQueryClient::runQuery() or Job::queryResults(). | 
| ↳ maxResults | intMaximum number of results to read per page. | 
| ↳ startIndex | intZero-based index of the starting row. | 
| ↳ timeoutMs | intHow long, in milliseconds, each API call will wait for query results to become available before timing out. Depending on whether the $maxRetries has been exceeded, the results will be polled again after the timeout has been reached. Defaults to  | 
| ↳ maxRetries | intThe number of times to poll the Job status, until the job is complete. By default, will poll indefinitely. | 
info
| Returns | |
|---|---|
| Type | Description | 
| array | |
reload
See also:
| Parameters | |
|---|---|
| Name | Description | 
| options | arrayConfiguration options. | 
| ↳ maxResults | intMaximum number of results to read per page. | 
| ↳ startIndex | intZero-based index of the starting row. | 
| ↳ timeoutMs | intHow long to wait for the query to complete, in milliseconds. Defaults to  | 
| Returns | |
|---|---|
| Type | Description | 
| array | |
identity
Retrieves the query result's identity.
An identity provides a description of a nested resource.
Example:
echo $queryResults->identity()['projectId']; | Returns | |
|---|---|
| Type | Description | 
| array | |
isComplete
Checks the job's completeness.
Useful in combination with QueryResults::reload() to poll for query status.
Example:
$isComplete = $queryResults->isComplete(); while (!$isComplete) { sleep(1); // let's wait for a moment... $queryResults->reload(); $isComplete = $queryResults->isComplete(); } echo 'Query complete!'; | Returns | |
|---|---|
| Type | Description | 
| bool | |
job
Returns a reference to the job.
The Job instance is used to fetch the query results. This is especially useful when attempting to access job statistics after calling BigQueryClient::runQuery().
Example:
$job = $queryResults->job(); | Returns | |
|---|---|
| Type | Description | 
| Job | |
getIterator
| Returns | |
|---|---|
| Type | Description | 
| Google\Cloud\Core\Iterator\ItemIterator | |