Reference documentation and code samples for the BigQuery Client class Routine.
Routines are used-defined functions or stored procedures.
Example:
use Google\Cloud\BigQuery\BigQueryClient;
$bigquery = new BigQueryClient();
$dataset = $bigquery->dataset('my_dataset');
$routine = $dataset->routine('my_routine');
Methods
__construct
Parameters | |
---|---|
Name | Description |
connection |
Google\Cloud\BigQuery\Connection\ConnectionInterface
A connection to the BigQuery API. |
id |
string
The routine ID. |
datasetId |
string
The dataset ID. |
projectId |
string
The project ID. |
info |
array
[optional] An optional representation of the routine resource. |
identity
Get the routine identity.
An identity provides a description of a nested resource.
Example:
$identity = $routine->identity();
echo $identity['routineId'];
Returns | |
---|---|
Type | Description |
array |
info
Return the routine resource.
If the value is not already cached, a service call will be made. To force a refresh of the cached value, use {@see}.
Example:
$res = $routine->info();
Parameter | |
---|---|
Name | Description |
options |
array
[optional] Configuration options |
Returns | |
---|---|
Type | Description |
array |
reload
Fetch the routine resource from the API.
This method will always trigger a service request. To make use of a cached representation of the resource, see {@see}.
Example:
$res = $routine->reload();
Parameter | |
---|---|
Name | Description |
options |
array
[optional] Configuration options |
Returns | |
---|---|
Type | Description |
array |
exists
Check whether or not the routine exists.
Example:
if ($routine->exists()) {
echo 'Routine exists!';
}
Parameter | |
---|---|
Name | Description |
options |
array
[optional] Configuration options. |
Returns | |
---|---|
Type | Description |
bool |
update
Update information in an existing routine.
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 the library will not automatically retry this
call on your behalf unless an etag
is set.
Please note that in order to implement partial updates, this method will trigger two service calls: the first to fetch the most up-to-date version of the resource and the second to apply the update.
Example:
$routine->update([
'definitionBody' => 'CONCAT(x, "\n", y)'
]);
// Using update masks to limit modified fields
$newData = [
'displayName' => 'My Function',
'definitionBody' => 'return x + y;',
'language' => 'JAVASCRIPT'
];
// Update the routine, excluding 'displayName' from updating.
$routine->update($newData, [
'updateMask' => [
'definitionBody',
'language'
]
]);
Parameters | |
---|---|
Name | Description |
metadata |
array
The full routine resource with desired modifications. |
options |
array
Configuration options |
↳ updateMask |
array
A list of field paths to be modified. Nested key names should be dot-separated, e.g. |
Returns | |
---|---|
Type | Description |
array |
delete
Delete a routine.
Please note that by default the library will not attempt to retry this call on your behalf.
Example:
$routine->delete();
Parameter | |
---|---|
Name | Description |
options |
array
[optional] Configuration options. |