Jobs#

Define API Jobs.

class google.cloud.bigquery.job.Compression(name)[source]#

Bases: google.cloud.bigquery._helpers._EnumProperty

Pseudo-enum for compression properties.

class google.cloud.bigquery.job.CopyJob(name, destination, sources, client)[source]#

Bases: google.cloud.bigquery.job._AsyncJob

Asynchronous job: copy data into a table from other tables.

Parameters:
begin(client=None)#

API call: begin the job via a POST request

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/insert

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current dataset.
Raises:ValueError if the job has already begin.
cancel(client=None)#

API call: cancel job via a POST request

See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/cancel

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current dataset.
create_disposition#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.copy.createDisposition

created#

Datetime at which the job was created.

Return type:datetime.datetime, or NoneType
Returns:the creation time (None until set from the server).
ended#

Datetime at which the job finished.

Return type:datetime.datetime, or NoneType
Returns:the end time (None until set from the server).
error_result#

Error information about the job as a whole.

Return type:mapping, or NoneType
Returns:the error information (None until set from the server).
errors#

Information about individual errors generated by the job.

Return type:list of mappings, or NoneType
Returns:the error information (None until set from the server).
etag#

ETag for the job resource.

Return type:str, or NoneType
Returns:the ETag (None until set from the server).
exists(client=None)#

API call: test for the existence of the job via a GET request

See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current dataset.
Return type:bool
Returns:Boolean indicating existence of the job.
classmethod from_api_repr(resource, client)[source]#

Factory: construct a job given its API representation

Parameters:
Return type:

google.cloud.bigquery.job.CopyJob

Returns:

Job parsed from resource.

job_type#

Type of job

Return type:str
Returns:one of ‘load’, ‘copy’, ‘extract’, ‘query’
path#

URL path for the job’s APIs.

Return type:str
Returns:the path based on project and job name.
project#

Project bound to the job.

Return type:str
Returns:the project (derived from the client).
reload(client=None)#

API call: refresh job properties via a GET request

See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current dataset.

URL for the job resource.

Return type:str, or NoneType
Returns:the URL (None until set from the server).
started#

Datetime at which the job was started.

Return type:datetime.datetime, or NoneType
Returns:the start time (None until set from the server).
state#

Status of the job.

Return type:str, or NoneType
Returns:the state (None until set from the server).
user_email#

E-mail address of user who submitted the job.

Return type:str, or NoneType
Returns:the URL (None until set from the server).
write_disposition#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.copy.writeDisposition

class google.cloud.bigquery.job.CreateDisposition(name)[source]#

Bases: google.cloud.bigquery._helpers._EnumProperty

Pseudo-enum for create_disposition properties.

class google.cloud.bigquery.job.DestinationFormat(name)[source]#

Bases: google.cloud.bigquery._helpers._EnumProperty

Pseudo-enum for destination_format properties.

class google.cloud.bigquery.job.Encoding(name)[source]#

Bases: google.cloud.bigquery._helpers._EnumProperty

Pseudo-enum for encoding properties.

class google.cloud.bigquery.job.ExtractTableToStorageJob(name, source, destination_uris, client)[source]#

Bases: google.cloud.bigquery.job._AsyncJob

Asynchronous job: extract data from a table into Cloud Storage.

Parameters:
  • name (str) – the name of the job
  • source (google.cloud.bigquery.table.Table) – Table into which data is to be loaded.
  • destination_uris (list of string) – URIs describing Cloud Storage blobs into which extracted data will be written, in format gs://<bucket_name>/<object_name_or_glob>.
  • client (google.cloud.bigquery.client.Client) – A client which holds credentials and project configuration for the dataset (which requires a project).
begin(client=None)#

API call: begin the job via a POST request

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/insert

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current dataset.
Raises:ValueError if the job has already begin.
cancel(client=None)#

API call: cancel job via a POST request

See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/cancel

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current dataset.
compression#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.extract.compression

created#

Datetime at which the job was created.

Return type:datetime.datetime, or NoneType
Returns:the creation time (None until set from the server).
destination_format#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.extract.destinationFormat

ended#

Datetime at which the job finished.

Return type:datetime.datetime, or NoneType
Returns:the end time (None until set from the server).
error_result#

Error information about the job as a whole.

Return type:mapping, or NoneType
Returns:the error information (None until set from the server).
errors#

Information about individual errors generated by the job.

Return type:list of mappings, or NoneType
Returns:the error information (None until set from the server).
etag#

ETag for the job resource.

Return type:str, or NoneType
Returns:the ETag (None until set from the server).
exists(client=None)#

API call: test for the existence of the job via a GET request

See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current dataset.
Return type:bool
Returns:Boolean indicating existence of the job.
field_delimiter#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.extract.fieldDelimiter

classmethod from_api_repr(resource, client)[source]#

Factory: construct a job given its API representation

Parameters:
Return type:

google.cloud.bigquery.job.ExtractTableToStorageJob

Returns:

Job parsed from resource.

job_type#

Type of job

Return type:str
Returns:one of ‘load’, ‘copy’, ‘extract’, ‘query’
path#

URL path for the job’s APIs.

Return type:str
Returns:the path based on project and job name.
print_header#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.extract.printHeader

project#

Project bound to the job.

Return type:str
Returns:the project (derived from the client).
reload(client=None)#

API call: refresh job properties via a GET request

See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current dataset.

URL for the job resource.

Return type:str, or NoneType
Returns:the URL (None until set from the server).
started#

Datetime at which the job was started.

Return type:datetime.datetime, or NoneType
Returns:the start time (None until set from the server).
state#

Status of the job.

Return type:str, or NoneType
Returns:the state (None until set from the server).
user_email#

E-mail address of user who submitted the job.

Return type:str, or NoneType
Returns:the URL (None until set from the server).
class google.cloud.bigquery.job.LoadTableFromStorageJob(name, destination, source_uris, client, schema=())[source]#

Bases: google.cloud.bigquery.job._AsyncJob

Asynchronous job for loading data into a table from CloudStorage.

Parameters:
  • name (str) – the name of the job
  • destination (google.cloud.bigquery.table.Table) – Table into which data is to be loaded.
  • source_uris (sequence of string) – URIs of one or more data files to be loaded, in format gs://<bucket_name>/<object_name_or_glob>.
  • client (google.cloud.bigquery.client.Client) – A client which holds credentials and project configuration for the dataset (which requires a project).
  • schema (list of google.cloud.bigquery.table.SchemaField) – The job’s schema
allow_jagged_rows#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.allowJaggedRows

allow_quoted_newlines#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.allowQuotedNewlines

begin(client=None)#

API call: begin the job via a POST request

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/insert

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current dataset.
Raises:ValueError if the job has already begin.
cancel(client=None)#

API call: cancel job via a POST request

See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/cancel

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current dataset.
create_disposition#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.createDisposition

created#

Datetime at which the job was created.

Return type:datetime.datetime, or NoneType
Returns:the creation time (None until set from the server).
encoding#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.encoding

ended#

Datetime at which the job finished.

Return type:datetime.datetime, or NoneType
Returns:the end time (None until set from the server).
error_result#

Error information about the job as a whole.

Return type:mapping, or NoneType
Returns:the error information (None until set from the server).
errors#

Information about individual errors generated by the job.

Return type:list of mappings, or NoneType
Returns:the error information (None until set from the server).
etag#

ETag for the job resource.

Return type:str, or NoneType
Returns:the ETag (None until set from the server).
exists(client=None)#

API call: test for the existence of the job via a GET request

See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current dataset.
Return type:bool
Returns:Boolean indicating existence of the job.
field_delimiter#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.fieldDelimiter

classmethod from_api_repr(resource, client)[source]#

Factory: construct a job given its API representation

Parameters:
Return type:

google.cloud.bigquery.job.LoadTableFromStorageJob

Returns:

Job parsed from resource.

ignore_unknown_values#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.ignoreUnknownValues

input_file_bytes#

Count of bytes loaded from source files.

Return type:int, or NoneType
Returns:the count (None until set from the server).
input_files#

Count of source files.

Return type:int, or NoneType
Returns:the count (None until set from the server).
job_type#

Type of job

Return type:str
Returns:one of ‘load’, ‘copy’, ‘extract’, ‘query’
max_bad_records#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.maxBadRecords

output_bytes#

Count of bytes saved to destination table.

Return type:int, or NoneType
Returns:the count (None until set from the server).
output_rows#

Count of rows saved to destination table.

Return type:int, or NoneType
Returns:the count (None until set from the server).
path#

URL path for the job’s APIs.

Return type:str
Returns:the path based on project and job name.
project#

Project bound to the job.

Return type:str
Returns:the project (derived from the client).
quote_character#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.quote

reload(client=None)#

API call: refresh job properties via a GET request

See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current dataset.
schema#

Table’s schema.

Return type:list of SchemaField
Returns:fields describing the schema

URL for the job resource.

Return type:str, or NoneType
Returns:the URL (None until set from the server).
skip_leading_rows#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.skipLeadingRows

source_format#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.sourceFormat

started#

Datetime at which the job was started.

Return type:datetime.datetime, or NoneType
Returns:the start time (None until set from the server).
state#

Status of the job.

Return type:str, or NoneType
Returns:the state (None until set from the server).
user_email#

E-mail address of user who submitted the job.

Return type:str, or NoneType
Returns:the URL (None until set from the server).
write_disposition#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.load.writeDisposition

class google.cloud.bigquery.job.QueryJob(name, query, client, udf_resources=(), query_parameters=())[source]#

Bases: google.cloud.bigquery.job._AsyncJob

Asynchronous job: query tables.

Parameters:
  • name (str) – the name of the job
  • query (str) – SQL query string
  • client (google.cloud.bigquery.client.Client) – A client which holds credentials and project configuration for the dataset (which requires a project).
  • udf_resources (tuple) – An iterable of google.cloud.bigquery._helpers.UDFResource (empty by default)
  • query_parameters (tuple) – An iterable of google.cloud.bigquery._helpers.AbstractQueryParameter (empty by default)
allow_large_results#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.allowLargeResults

begin(client=None)#

API call: begin the job via a POST request

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/insert

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current dataset.
Raises:ValueError if the job has already begin.
cancel(client=None)#

API call: cancel job via a POST request

See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/cancel

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current dataset.
create_disposition#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.createDisposition

created#

Datetime at which the job was created.

Return type:datetime.datetime, or NoneType
Returns:the creation time (None until set from the server).
default_dataset#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.defaultDataset

destination#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.destinationTable

dry_run#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.dryRun

ended#

Datetime at which the job finished.

Return type:datetime.datetime, or NoneType
Returns:the end time (None until set from the server).
error_result#

Error information about the job as a whole.

Return type:mapping, or NoneType
Returns:the error information (None until set from the server).
errors#

Information about individual errors generated by the job.

Return type:list of mappings, or NoneType
Returns:the error information (None until set from the server).
etag#

ETag for the job resource.

Return type:str, or NoneType
Returns:the ETag (None until set from the server).
exists(client=None)#

API call: test for the existence of the job via a GET request

See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current dataset.
Return type:bool
Returns:Boolean indicating existence of the job.
flatten_results#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.flattenResults

classmethod from_api_repr(resource, client)[source]#

Factory: construct a job given its API representation

Parameters:
Return type:

google.cloud.bigquery.job.RunAsyncQueryJob

Returns:

Job parsed from resource.

job_type#

Type of job

Return type:str
Returns:one of ‘load’, ‘copy’, ‘extract’, ‘query’
maximum_billing_tier#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.maximumBillingTier

maximum_bytes_billed#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.maximumBytesBilled

path#

URL path for the job’s APIs.

Return type:str
Returns:the path based on project and job name.
priority#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.priority

project#

Project bound to the job.

Return type:str
Returns:the project (derived from the client).
reload(client=None)#

API call: refresh job properties via a GET request

See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get

Parameters:client (Client or NoneType) – the client to use. If not passed, falls back to the client stored on the current dataset.
results()[source]#

Construct a QueryResults instance, bound to this job.

Return type:QueryResults
Returns:results instance

URL for the job resource.

Return type:str, or NoneType
Returns:the URL (None until set from the server).
started#

Datetime at which the job was started.

Return type:datetime.datetime, or NoneType
Returns:the start time (None until set from the server).
state#

Status of the job.

Return type:str, or NoneType
Returns:the state (None until set from the server).
use_legacy_sql#

See: https://cloud.google.com/bigquery/docs/reference/v2/jobs#configuration.query.useLegacySql

use_query_cache#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.useQueryCache

user_email#

E-mail address of user who submitted the job.

Return type:str, or NoneType
Returns:the URL (None until set from the server).
write_disposition#

See: https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.writeDisposition

class google.cloud.bigquery.job.QueryPriority(name)[source]#

Bases: google.cloud.bigquery._helpers._EnumProperty

Pseudo-enum for QueryJob.priority property.

class google.cloud.bigquery.job.SourceFormat(name)[source]#

Bases: google.cloud.bigquery._helpers._EnumProperty

Pseudo-enum for source_format properties.

class google.cloud.bigquery.job.WriteDisposition(name)[source]#

Bases: google.cloud.bigquery._helpers._EnumProperty

Pseudo-enum for write_disposition properties.