Reference documentation and code samples for the BigQuery Client class Dataset.
Datasets allow you to organize and control access to your tables.
Methods
__construct
connection
Google\Cloud\BigQuery\Connection\ConnectionInterface
Represents a connection to BigQuery.
id
string
The dataset's ID.
projectId
string
The project's ID.
info
array
[optional] The dataset's metadata.
location
string|null
[optional] A default geographic location, used when no dataset metadata exists.
exists
Check whether or not the dataset exists.
Example:
echo $dataset->exists();
bool
delete
Delete the dataset.
Please note that by default the library will not attempt to retry this call on your behalf.
Example:
$dataset->delete();
options
array
Configuration options.
↳ deleteContents
bool
If true, delete all the tables in the dataset. If false and the dataset contains tables, the request will fail. Defaults to false
.
update
Update the dataset.
Providing an etag
key as part of $metadata
will enable simultaneous
update protection. This is useful in preventing override of modifications
made by another user. The resource's current etag can be obtained via a
GET request on the resource.
Please note that by default this call will not automatically retry on
your behalf unless an etag
is set.
Example:
$dataset->update([
'friendlyName' => 'A fanciful dataset.'
]);
metadata
options
array
[optional] Configuration options.
table
Lazily instantiates a table. There are no network requests made at this point. To see the operations that can be performed on a dataset please see Table .
Example:
$table = $dataset->table('myTableId');
id
string
The id of the table to request.
tables
Fetches tables in the dataset.
Example:
$tables = $dataset->tables();
foreach ($tables as $table) {
echo $table->id() . PHP_EOL;
}
options
array
Configuration options.
↳ maxResults
int
Maximum number of results to return per page.
↳ resultLimit
int
Limit the number of results returned in total. Defaults to 0
(return all results).
↳ pageToken
string
A previously-returned page token used to resume the loading of results from a specific point.
Google\Cloud\Core\Iterator\ItemIterator<\google\cloud\bigquery\table>
createTable
Creates a table.
Please note that by default the library will not attempt to retry this call on your behalf.
Example:
$table = $dataset->createTable('aTable');
id
mixed
options
array
Configuration options.
↳ metadata
model
Lazily instantiates a machine learning model in the dataset. There are no network requests made at this point. To see the operations that can be performed on a model, please see Model .
Example:
$model = $dataset->model('my_model');
echo $model->id();
id
string
The model's ID.
info
array
[optional] The model resource data.
models
Fetches all of the models in the dataset.
Please note that Model instances obtained from this method contain only a
subset of the resource representation. Fields returned include modelReference
, modelType
, creationTime
, lastModifiedTime
and labels
. To obtain a full representation, call
{@see}.
Example:
$models = $dataset->models();
foreach ($models as $model) {
echo $model->id() . PHP_EOL;
}
options
array
Configuration options.
↳ maxResults
int
Maximum number of results to return per page.
↳ resultLimit
int
Limit the number of results returned in total. Defaults to 0
(return all results).
↳ pageToken
string
A previously-returned page token used to resume the loading of results from a specific point.
Google\Cloud\Core\Iterator\ItemIterator<\google\cloud\bigquery\model>
routine
Lazily instantiates a routine.
There are no network requests made at this point. To see the operations that can be performed on a routine, please see {@see}.
Example:
$routine = $dataset->routine('my_routine');
echo $routine->identity()['routineId'];
id
string
The routine's ID.
info
array
[optional] The routine resource data.
routines
Fetches all of the routines in the dataset.
Please note that Routine instances obtained from this method contain only a
subset of the resource representation. Fields returned include etag
, projectId
, datasetId
, routineId
, routineType
, creationTime
, lastModifiedTime
and language
. To obtain a full representation, call
{@see}.
Example:
$routines = $dataset->routines();
foreach ($routines as $routine) {
echo $routine->identity()['routineId'] . PHP_EOL;
}
options
array
Configuration options.
↳ maxResults
int
Maximum number of results to return per page.
↳ resultLimit
int
Limit the number of results returned in total. Defaults to 0
(return all results).
↳ pageToken
string
A previously-returned page token used to resume the loading of results from a specific point.
Google\Cloud\Core\Iterator\ItemIterator<\google\cloud\bigquery\model>
createRoutine
Creates a routine.
Please note that by default the library will not attempt to retry this call on your behalf.
Example:
$routine = $dataset->createRoutine('my_routine', [
'routineType' => 'SCALAR_FUNCTION',
'definitionBody' => 'concat(x, "\n", y)',
'arguments' => [
[
'name' => 'x',
'dataType' => [
'typeKind' => 'STRING'
]
], [
'name' => 'y',
'dataType' => [
'typeKind' => 'STRING'
]
]
]
]);
id
string
The routine ID.
metadata
array
The available options for metadata are outlined at the Routine Resource API docs
. Omit routineReference
as it is computed and appended by the client.
options
array
[optional] Configuration options.
info
Retrieves the dataset's details. If no dataset data is cached a network request will be made to retrieve it.
Example:
$info = $dataset->info();
echo $info['selfLink'];
options
array
[optional] Configuration options.
array
reload
Triggers a network request to reload the dataset's details.
Example:
$dataset->reload();
$info = $dataset->info();
echo $info['selfLink'];
options
array
[optional] Configuration options.
array
id
Retrieves the dataset's ID.
Example:
echo $dataset->id();
string
identity
Retrieves the dataset's identity.
An identity provides a description of a resource that is nested in nature.
Example:
echo $dataset->identity()['projectId'];
array