BigQuery Client - Class Table (1.31.1)

Reference documentation and code samples for the BigQuery Client class Table.

Tables are a standard two-dimensional table with individual records organized in rows, and a data type assigned to each column (also called a field).

Namespace

Google \ Cloud \ BigQuery

Methods

__construct

Parameters
NameDescription
connectionConnection\ConnectionInterface

Represents a connection to BigQuery. This object is created by BigQueryClient, and should not be instantiated outside of this client.

idstring

The table's id.

datasetIdstring

The dataset's id.

projectIdstring

The project's id.

mapperValueMapper

Maps values between PHP and BigQuery.

infoarray

[optional] The table's metadata.

locationstring|null

[optional] A default geographic location, used when no table metadata exists.

exists

Check whether or not the table exists.

Example:

if ($table->exists()) {
    echo 'Table exists!';
}
Returns
TypeDescription
bool

delete

Parameter
NameDescription
optionsarray

[optional] Configuration options.

update

Parameters
NameDescription
metadataarray

The available options for metadata are outlined at the Table Resource API docs

optionsarray

[optional] Configuration options.

rows

Parameters
NameDescription
optionsarray

Configuration options.

↳ maxResultsint

Maximum number of results to return per page.

↳ resultLimitint

Limit the number of results returned in total. Defaults to 0 (return all results).

↳ pageTokenstring

A previously-returned page token used to resume the loading of results from a specific point.

↳ startIndexint

Zero-based index of the starting row.

Returns
TypeDescription
Google\Cloud\Core\Iterator\ItemIterator<array>

runJob

Parameters
NameDescription
configJobConfigurationInterface

The job configuration.

optionsarray

Configuration options.

↳ maxRetriesint

The number of times to retry, checking if the job has completed. Defaults to 100.

Returns
TypeDescription
Job

startJob

Parameters
NameDescription
configJobConfigurationInterface

The job configuration.

optionsarray

[optional] Configuration options.

Returns
TypeDescription
Job

copy

Parameters
NameDescription
destinationTable

The destination table.

optionsarray

Configuration options.

↳ configurationarray

Job configuration. Please see the API documentation for the available options.

↳ configurationarray

.copy Copy job configuration. Please see the documentation for the available options.

Returns
TypeDescription
CopyJobConfiguration

extract

Parameters
NameDescription
destinationstring|Google\Cloud\Storage\StorageObject

The destination object. May be a Google\Cloud\Storage\StorageObject or a URI pointing to a Google Cloud Storage object in the format of gs://{bucket-name}/{object-name}.

optionsarray

Configuration options.

↳ configurationarray

Job configuration. Please see the API documentation for the available options.

↳ configurationarray

.extract Extract job configuration. Please see the documentation for the available options.

Returns
TypeDescription
ExtractJobConfiguration

load

Parameters
NameDescription
datastring|resource|Psr\Http\Message\StreamInterface

The data to load.

optionsarray

Configuration options.

↳ configurationarray

Job configuration. Please see the API documentation for the available options.

↳ configurationarray

.load Load job configuration. Please see the documentation for the available options.

Returns
TypeDescription
LoadJobConfiguration

loadFromStorage

Parameters
NameDescription
objectstring|Google\Cloud\Storage\StorageObject

The object to load data from. May be a Google\Cloud\Storage\StorageObject or a URI pointing to a Google Cloud Storage object in the format of gs://{bucket-name}/{object-name}.

optionsarray

Configuration options.

↳ configurationarray

Job configuration. Please see the API documentation for the available options.

↳ configurationarray

.load Load job configuration. Please see the documentation for the available options.

Returns
TypeDescription
LoadJobConfiguration

insertRow

Parameters
NameDescription
rowarray

Key/value set of data matching the table's schema.

optionsarray

Please see Table::insertRows() for the other available configuration options.

↳ insertIdstring

Used to ensure data consistency.

Returns
TypeDescription
InsertResponse

insertRows

Parameters
NameDescription
rowsarray

The rows to insert. Each item in the array must contain a data key which is to hold a key/value array with data matching the schema of the table. Optionally, one may also provide an insertId key which will be used to ensure data consistency.

optionsarray

Configuration options.

↳ autoCreatebool

Whether or not to attempt to automatically create the table in the case it does not exist. Please note, it will be required to provide a schema through $tableMetadata['schema'] in the case the table does not already exist. Defaults to false.

↳ tableMetadataarray

Metadata to apply to table to be created. The full set of metadata are outlined at the Table Resource API docs. Only applies when autoCreate is true.

↳ maxRetriesint

The maximum number of times to attempt creating the table in the case of failure. Please note, each retry attempt may take up to two minutes. Only applies when autoCreate is true. Defaults to 100.

↳ skipInvalidRowsbool

Insert all valid rows of a request, even if invalid rows exist. The default value is false, which causes the entire request to fail if any invalid rows exist. Defaults to false.

↳ ignoreUnknownValuesbool

Accept rows that contain values that do not match the schema. The unknown values are ignored. The default value is false, which treats unknown values as errors. Defaults to false.

↳ templateSuffixstring

If specified, treats the destination table as a base template, and inserts the rows into an instance table named "{destination}{templateSuffix}". BigQuery will manage creation of the instance table, using the schema of the base template table. See Creating tables automatically using template tables for considerations when working with templates tables.

Returns
TypeDescription
InsertResponse

info

Parameter
NameDescription
optionsarray

[optional] Configuration options.

Returns
TypeDescription
array

reload

Parameter
NameDescription
optionsarray

[optional] Configuration options.

Returns
TypeDescription
array

id

Retrieves the table's ID.

Example:

echo $table->id();
Returns
TypeDescription
string

identity

Retrieves the table's identity.

An identity provides a description of a nested resource.

Example:

echo $table->identity()['projectId'];
Returns
TypeDescription
array

iam

Returns
TypeDescription
Google\Cloud\Core\Iam\Iam

Constants

MAX_RETRIES

Value: 100

INSERT_CREATE_MAX_DELAY_MICROSECONDS

Value: 60000000