use Google\Cloud\BigQuery\BigQueryClient;
$bigQuery = new BigQueryClient();
Namespace
Google \ Cloud \ BigQuery
Methods
__construct
Create a BigQuery client.
Parameters
Name
Description
config
array Configuration options.
↳ apiEndpoint
string The hostname with optional port to use in place of the default service endpoint. Example: foobar.com or foobar.com:1234.
↳ projectId
string The project ID from the Google Developer's Console.
↳ authCache
CacheItemPoolInterface A cache for storing access tokens. Defaults to a simple in memory implementation.
↳ authCacheOptions
array Cache configuration options.
↳ authHttpHandler
callable A handler used to deliver Psr7 requests specifically for authentication.
↳ credentialsFetcher
FetchAuthTokenInterface A credentials fetcher instance.
↳ httpHandler
callable A handler used to deliver Psr7 requests. Only valid for requests sent over REST.
↳ keyFile
array [DEPRECATED] This option is being deprecated because of a potential security risk. This option does not validate the credential configuration. The security risk occurs when a credential configuration is accepted from a source that is not under your control and used without validation on your side. If you know that you will be loading credential configurations of a specific type, it is recommended to create the credentials directly and configure them using the credentialsFetcher option instead. use Google\Auth\Credentials\ServiceAccountCredentials; credentialsFetcher=newServiceAccountCredentials(credentialsFetcher = new ServiceAccountCredentials(credentialsFetcher=newServiceAccountCredentials(scopes, json);json); json);creds = new BigQueryClient(['credentialsFetcher' => $creds]); This will ensure that an unexpected credential type with potential for malicious intent is not loaded unintentionally. You might still have to do validation for certain credential types. If you are loading your credential configuration from an untrusted source and have not mitigated the risks (e.g. by validating the configuration yourself), make these changes as soon as possible to prevent security risks to your environment. Regardless of the method used, it is always your responsibility to validate configurations received from external sources. @see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials
↳ keyFilePath
string [DEPRECATED] This option is being deprecated because of a potential security risk. This option does not validate the credential configuration. The security risk occurs when a credential configuration is accepted from a source that is not under your control and used without validation on your side. If you know that you will be loading credential configurations of a specific type, it is recommended to create the credentials directly and configure them using the credentialsFetcher option instead. use Google\Auth\Credentials\ServiceAccountCredentials; credentialsFetcher=newServiceAccountCredentials(credentialsFetcher = new ServiceAccountCredentials(credentialsFetcher=newServiceAccountCredentials(scopes, json);json); json);creds = new BigQueryClient(['credentialsFetcher' => $creds]); This will ensure that an unexpected credential type with potential for malicious intent is not loaded unintentionally. You might still have to do validation for certain credential types. If you are loading your credential configuration from an untrusted source and have not mitigated the risks (e.g. by validating the configuration yourself), make these changes as soon as possible to prevent security risks to your environment. Regardless of the method used, it is always your responsibility to validate configurations received from external sources. @see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials
↳ requestTimeout
float Seconds to wait before timing out the request. Defaults to 0 with REST and 60 with gRPC.
↳ retries
int Number of retries for a failed request. Defaults to 3.
↳ scopes
array Scopes to be used for the request.
↳ quotaProject
string Specifies a user project to bill for access charges associated with the request.
↳ returnInt64AsObject
bool If true, 64 bit integers will be returned as a Google\Cloud\Core\Int64 object for 32 bit platform compatibility. Defaults to false.
↳ location
string If provided, determines the default geographic location used when creating datasets and managing jobs. Please note: This is only required for jobs started outside of the US and EU regions. Also, if location metadata has already been fetched over the network it will take precedent over this setting (by calling Table::reload(), for example).
Unless otherwise specified, all configuration options will default based on thequery job configurationexcept for configuration.query.useLegacySql, which defaults to falsein this client.
Example:
'SELECT commit FROM `bigquery-public-data.github_repos.commits` LIMIT 100'
);
// Set a region to run the job in. <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mi>u</mi><mi>e</mi><mi>r</mi><mi>y</mi><mi>J</mi><mi>o</mi><mi>b</mi><mi>C</mi><mi>o</mi><mi>n</mi><mi>f</mi><mi>i</mi><mi>g</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">queryJobConfig = </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mord mathnormal">u</span><span class="mord mathnormal" style="margin-right:0.03588em;">ery</span><span class="mord mathnormal" style="margin-right:0.09618em;">J</span><span class="mord mathnormal">o</span><span class="mord mathnormal">b</span><span class="mord mathnormal" style="margin-right:0.07153em;">C</span><span class="mord mathnormal">o</span><span class="mord mathnormal">n</span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal">i</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span>bigQuery->query(
'SELECT name FROM `my_project.users_dataset.users` LIMIT 100'
)->location('asia-northeast1');
Parameters
Name
Description
query
string A BigQuery SQL query.
options
array Configuration options.
↳ configuration
array Job configuration. Please see the API documentation for the available options. PropertiesNameDescription query arrayQuery job configuration. Please see the documentation for the available options.
Unless otherwise specified, all configuration options will default based on thequery job configurationexcept for configuration.query.useLegacySql, which defaults to falsein this client.
array Job configuration. Please see the API documentation for the available options. PropertiesNameDescription query arrayQuery job configuration. Please see the documentation for the available options.
int The maximum number of rows to return per page of results. Setting this flag to a small value such as 1000 and then paging through results might improve reliability when the query result set is large.
↳ startIndex
int Zero-based index of the starting row.
↳ timeoutMs
int How 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 10000 milliseconds (10 seconds).
↳ maxRetries
int The number of times to poll the Job status, until the job is complete. By default, will poll indefinitely.
↳ returnRawResults
bool Returns the raw data types returned from BigQuery without converting their values into native PHP types or the custom type classes supported by this library. Default is false.
↳ formatOptions.useInt64Timestamp
boolean Optional. Output timestamp as usec int64. Default is false.
There are no network requests made at this point. To see the operations that can be performed on a job please see Job.
Example:
Parameters
Name
Description
id
string The id of the already run or running job to request.
options
array Configuration options.
↳ location
string The geographic location of the job. Required for jobs started outside of the US and EU regions. Defaults to a location specified in the client configuration.
int Optional. Access policy schema version. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for conditional access policy binding in datasets must specify version 3. Dataset with no conditional role bindings in access policy may specify any valid value or leave the field unset. This field will be mapped to IAM Policy version and will be used to fetch policy from IAM. If unset or if 0 or 1 value is used for dataset with conditional bindings, access entry with condition will have role string appended by 'withcond' string followed by a hash value. For example : { "access": [ { "role": "roles/bigquery.dataViewer_with_conditionalbinding_7a34awqsda", "userByEmail": "user@example.com", } ] } Please refer https://cloud.google.com/iam/docs/troubleshooting-withcond for more details.
Numeric represents a value with a data type ofNumeric.
It supports a fixed 38 decimal digits of precision and 9 decimal digits of scale, and values are in the range of -99999999999999999999999999999.999999999 to 99999999999999999999999999999.999999999.
Example:
Parameter
Name
Description
value
string|int
Returns
Type
Description
numeric
bigNumeric
Create a BigNumeric object.
Numeric represents a value with a data type ofBIGNUMERIC.
It supports 76.76 (the 77th digit is partial) decimal digits of precision and 38 decimal digits of scale. Values are in the range of -5.7896044618658097711785492504343953926634992332820282019728792003956564819968E+38 to 5.7896044618658097711785492504343953926634992332820282019728792003956564819967E+38.
array Job configuration. Please see the API documentation for the available options. PropertiesNameDescription copy arrayCopy job configuration. Please see the documentation for the available options.
array Job configuration. Please see the API documentation for the available options. PropertiesNameDescription extract arrayExtract job configuration. Please see the documentation for the available options.
array Job configuration. Please see the API documentation for the available options. PropertiesNameDescription load arrayLoad job configuration. Please see the documentation for the available options.