BigQuery Client - Class Routine (1.24.2)

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
NameDescription
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
TypeDescription
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 Google\Cloud\BigQuery\Routine::reload().

Example:

$res = $routine->info();
Parameter
NameDescription
options array

[optional] Configuration options

Returns
TypeDescription
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 Google\Cloud\BigQuery\Routine::info().

Example:

$res = $routine->reload();
Parameter
NameDescription
options array

[optional] Configuration options

Returns
TypeDescription
array

exists

Check whether or not the routine exists.

Example:

if ($routine->exists()) {
    echo 'Routine exists!';
}
Parameter
NameDescription
options array

[optional] Configuration options.

Returns
TypeDescription
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
NameDescription
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. returnType.typeKind. Google Cloud PHP will attempt to infer this value on your behalf. You may use this field to limit which parts of the resource are updated, should you choose to provide the full resource as the $metadata argument.

Returns
TypeDescription
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
NameDescription
options array

[optional] Configuration options.