PHP 클래스 Google\Cloud\BigQuery\BigQueryClient

Example: use Google\Cloud\ServiceBuilder; $cloud = new ServiceBuilder(); $bigQuery = $cloud->bigQuery(); BigQueryClient can be instantiated directly. use Google\Cloud\BigQuery\BigQueryClient; $bigQuery = new BigQueryClient();
상속: use trait Google\Cloud\ArrayTrait, use trait Google\Cloud\ClientTrait, use trait JobConfigurationTrait
파일 보기 프로젝트 열기: GoogleCloudPlatform/gcloud-php

보호된 프로퍼티들

프로퍼티 타입 설명
$connection Google\Cloud\BigQuery\Connection\ConnectionInterface Represents a connection to BigQuery.

공개 메소드들

메소드 설명
__construct ( array $config = [] ) Create a BigQuery client.
bytes ( string | resource | Psr\Http\Message\StreamInterface $value ) : Bytes Create a Bytes object.
createDataset ( string $id, array $options = [] ) : Dataset Creates a dataset.
dataset ( string $id ) : Dataset Lazily instantiates a dataset. There are no network requests made at this point. To see the operations that can be performed on a dataset please see {@see Google\Cloud\BigQuery\Dataset}.
datasets ( array $options = [] ) : Generator Fetches datasets in the project.
date ( DateTimeInterface $value ) : Date Create a Date object.
int64 ( string $value ) : Int64 Create an Int64 object. This can be used to work with 64 bit integers as a string value while on a 32 bit platform.
job ( string $id ) : Job Lazily instantiates a job. There are no network requests made at this point. To see the operations that can be performed on a job please see {@see Google\Cloud\BigQuery\Job}.
jobs ( array $options = [] ) : Generator Fetches jobs in the project.
runQuery ( string $query, array $options = [] ) : QueryResults Runs a BigQuery SQL query in a synchronous fashion. Rows are returned immediately as long as the query completes within a specified timeout. In the case that the query does not complete in the specified timeout, you are able to poll the query's status until it is complete.
runQueryAsJob ( string $query, array $options = [] ) : Job Runs a BigQuery SQL query in an asynchronous fashion. Running a query in this fashion requires you to poll for the status before being able to access results.
time ( DateTimeInterface $value ) : Time Create a Time object.
timestamp ( DateTimeInterface $value ) : Timestamp Create a Timestamp object.

비공개 메소드들

메소드 설명
formatQueryParameters ( array $parameters ) : array Formats query parameters for the API.

메소드 상세

__construct() 공개 메소드

Create a BigQuery client.
public __construct ( array $config = [] )
$config array [optional] { Configuration options. @type string $projectId The project ID from the Google Developer's Console. @type CacheItemPoolInterface $authCache A cache for storing access tokens. **Defaults to** a simple in memory implementation. @type array $authCacheOptions Cache configuration options. @type callable $authHttpHandler A handler used to deliver Psr7 requests specifically for authentication. @type callable $httpHandler A handler used to deliver Psr7 requests. Only valid for requests sent over REST. @type string $keyFile The contents of the service account credentials .json file retrieved from the Google Developers Console. @type string $keyFilePath The full path to your service account credentials .json file retrieved from the Google Developers Console. @type int $retries Number of retries for a failed request. **Defaults to** `3`. @type array $scopes Scopes to be used for the request. @type bool $returnInt64AsObject If true, 64 bit integers will be returned as a {@see \Google\Cloud\Int64} object for 32 bit platform compatibility. **Defaults to** false. }

bytes() 공개 메소드

Example: $bytes = $bigQuery->bytes('hello world');
public bytes ( string | resource | Psr\Http\Message\StreamInterface $value ) : Bytes
$value string | resource | Psr\Http\Message\StreamInterface The bytes value.
리턴 Bytes

createDataset() 공개 메소드

Example: $dataset = $bigQuery->createDataset('aDataset');
또한 보기: https://cloud.google.com/bigquery/docs/reference/v2/datasets/insert Datasets insert API documentation.
public createDataset ( string $id, array $options = [] ) : Dataset
$id string The id of the dataset to create.
$options array [optional] { Configuration options. @type array $metadata The available options for metadata are outlined at the [Dataset Resource API docs](https://cloud.google.com/bigquery/docs/reference/v2/datasets#resource) }
리턴 Dataset

dataset() 공개 메소드

Example: $dataset = $bigQuery->dataset('myDatasetId');
public dataset ( string $id ) : Dataset
$id string The id of the dataset to request.
리턴 Dataset

datasets() 공개 메소드

Example: $datasets = $bigQuery->datasets(); foreach ($datasets as $dataset) { echo $dataset->id() . PHP_EOL; }
또한 보기: https://cloud.google.com/bigquery/docs/reference/v2/datasets/list Datasets list API documentation.
public datasets ( array $options = [] ) : Generator
$options array [optional] { Configuration options. @type bool $all Whether to list all datasets, including hidden ones. @type int $maxResults Maximum number of results to return. }
리턴 Generator

date() 공개 메소드

Example: $date = $bigQuery->date(new \DateTime('1995-02-04'));
public date ( DateTimeInterface $value ) : Date
$value DateTimeInterface The date value.
리턴 Date

int64() 공개 메소드

Example: $int64 = $bigQuery->int64('9223372036854775807');
public int64 ( string $value ) : Int64
$value string
리턴 Google\Cloud\Int64

job() 공개 메소드

Example: $job = $bigQuery->job('myJobId');
public job ( string $id ) : Job
$id string The id of the job to request.
리턴 Job

jobs() 공개 메소드

Example: Get all jobs with the state of 'done' $jobs = $bigQuery->jobs([ 'stateFilter' => 'done' ]); foreach ($jobs as $job) { echo $job->id() . PHP_EOL; }
또한 보기: https://cloud.google.com/bigquery/docs/reference/v2/jobs/list Jobs list API documentation.
public jobs ( array $options = [] ) : Generator
$options array [optional] { Configuration options. @type bool $allUsers Whether to display jobs owned by all users in the project. **Defaults to** `false`. @type int $maxResults Maximum number of results to return. @type string $stateFilter Filter for job state. Maybe be either `done`, `pending`, or `running`. }
리턴 Generator

runQuery() 공개 메소드

Queries constructed using standard SQL can take advantage of parametriziation. Refer to the table below for a guide on how parameter types are mapped to their BigQuery equivalents. | **PHP Type** | **BigQuery Data Type** | |--------------------------------------------|--------------------------------------| | \DateTimeInterface | DATETIME | | {@see \Google\Cloud\BigQuery\Bytes} | BYTES | | {@see \Google\Cloud\BigQuery\Date} | DATE | | {@see \Google\Cloud\Int64} | INT64 | | {@see \Google\Cloud\BigQuery\Time} | TIME | | {@see \Google\Cloud\BigQuery\Timestamp} | TIMESTAMP | | Associative Array | STRUCT | | Non-Associative Array | ARRAY | | float | FLOAT64 | | int | INT64 | | string | STRING | | resource | BYTES | | bool | BOOL | | object (Outside types specified above) | **ERROR** InvalidArgumentException | Example: $queryResults = $bigQuery->runQuery('SELECT commit FROM [bigquery-public-data:github_repos.commits] LIMIT 100'); $isComplete = $queryResults->isComplete(); while (!$isComplete) { sleep(1); // let's wait for a moment... $queryResults->reload(); // trigger a network request $isComplete = $queryResults->isComplete(); // check the query's status } foreach ($queryResults->rows() as $row) { echo $row['commit']; } Construct a query utilizing named parameters. $query = 'SELECT commit FROM bigquery-public-data.github_repos.commits' . 'WHERE author.date < @date AND message = @message LIMIT 100'; $queryResults = $bigQuery->runQuery($query, [ 'parameters' => [ 'date' => $bigQuery->timestamp(new \DateTime('1980-01-01 12:15:00Z')), 'message' => 'A commit message.' ] ]); $isComplete = $queryResults->isComplete(); while (!$isComplete) { sleep(1); // let's wait for a moment... $queryResults->reload(); // trigger a network request $isComplete = $queryResults->isComplete(); // check the query's status } foreach ($queryResults->rows() as $row) { echo $row['commit']; } Construct a query utilizing positional parameters. $query = 'SELECT commit FROM bigquery-public-data.github_repos.commits WHERE message = ? LIMIT 100'; $queryResults = $bigQuery->runQuery($query, [ 'parameters' => ['A commit message.'] ]); $isComplete = $queryResults->isComplete(); while (!$isComplete) { sleep(1); // let's wait for a moment... $queryResults->reload(); // trigger a network request $isComplete = $queryResults->isComplete(); // check the query's status } foreach ($queryResults->rows() as $row) { echo $row['commit']; }
또한 보기: https://cloud.google.com/bigquery/docs/reference/v2/jobs/query Query API documentation.
public runQuery ( string $query, array $options = [] ) : QueryResults
$query string A BigQuery SQL query.
$options array [optional] { Configuration options. @type int $maxResults 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. @type array $defaultDataset Specifies the default datasetId and projectId to assume for any unqualified table names in the query. If not set, all table names in the query string must be qualified in the format 'datasetId.tableId'. @type int $timeoutMs How long to wait for the query to complete, in milliseconds. **Defaults to** `10000` milliseconds (10 seconds). @type bool $useQueryCache Whether to look for the result in the query cache. @type bool $useLegacySql Specifies whether to use BigQuery's legacy SQL dialect for this query. @type array $parameters Only available for standard SQL queries. When providing a non-associative array positional parameters (`?`) will be used. When providing an associative array named parameters will be used (`@name`). }
리턴 QueryResults

runQueryAsJob() 공개 메소드

Queries constructed using standard SQL can take advantage of parametriziation. For more details and examples please see {@see \Google\Cloud\BigQuery\BigQueryClient::runQuery()}. Example: $job = $bigQuery->runQueryAsJob('SELECT commit FROM [bigquery-public-data:github_repos.commits] LIMIT 100'); $isComplete = false; $queryResults = $job->queryResults(); while (!$isComplete) { sleep(1); // let's wait for a moment... $queryResults->reload(); // trigger a network request $isComplete = $queryResults->isComplete(); // check the query's status } foreach ($queryResults->rows() as $row) { echo $row['commit']; }
또한 보기: https://cloud.google.com/bigquery/docs/reference/v2/jobs/insert Jobs insert API documentation.
public runQueryAsJob ( string $query, array $options = [] ) : Job
$query string A BigQuery SQL query.
$options array [optional] { Configuration options. @type array $parameters Only available for standard SQL queries. When providing a non-associative array positional parameters (`?`) will be used. When providing an associative array named parameters will be used (`@name`). @type array $jobConfig Configuration settings for a query job are outlined in the [API Docs for `configuration.query`](https://goo.gl/PuRa3I). If not provided default settings will be used. }
리턴 Job

time() 공개 메소드

Example: $time = $bigQuery->time(new \DateTime('12:15:00.482172'));
public time ( DateTimeInterface $value ) : Time
$value DateTimeInterface The time value.
리턴 Time

timestamp() 공개 메소드

Example: $timestamp = $bigQuery->timestamp(new \DateTime('2003-02-05 11:15:02.421827Z'));
public timestamp ( DateTimeInterface $value ) : Timestamp
$value DateTimeInterface The timestamp value.
리턴 Timestamp

프로퍼티 상세

$connection 보호되어 있는 프로퍼티

Represents a connection to BigQuery.
protected ConnectionInterface,Google\Cloud\BigQuery\Connection $connection
리턴 Google\Cloud\BigQuery\Connection\ConnectionInterface