Skip to main content

jobs

Creates, updates, deletes, gets or lists a jobs resource.

Overview

Namejobs
TypeResource
Idgoogle.bigquery.jobs

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringOutput only. Opaque ID field of the job.
configurationobjectRequired. Describes the job configuration. (id: JobConfiguration)
etagstringOutput only. A hash of this resource.
jobCreationReasonobjectOutput only. The reason why a Job was created. (id: JobCreationReason)
jobReferenceobjectOptional. Reference describing the unique-per-user name of the job. (id: JobReference)
kindstringOutput only. The type of the resource. (default: bigquery#job)
principal_subjectstringOutput only. [Full-projection-only] String representation of identity of requesting party. Populated for both first- and third-party identities. Only present for APIs that support third-party identities.
selfLinkstringOutput only. A URL that can be used to access the resource again.
statisticsobjectOutput only. Information about the job, including starting time and ending time of the job. (id: JobStatistics)
statusobjectOutput only. The status of this job. Examine this value when polling an asynchronous job to see if the job is complete. (id: JobStatus)
user_emailstringOutput only. Email address of the user who ran the job.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectprojectId, +jobIdlocationReturns information about a specific job. Job information is available for a six month period after creation. Requires that you're the person who ran the job, or have the Is Owner project role. # IAM Permissions Requires the bigquery.jobs.get permission on the job resource. If the user matches the creator of the job, the bigquery.jobs.create permission on the project is required instead.
listselectprojectIdpageToken, maxCreationTime, allUsers, parentJobId, maxResults, minCreationTime, projection, stateFilterLists all jobs that you started in the specified project. Job information is available for a six month period after creation. The job list is sorted in reverse chronological order, by job creation time. Requires the Can View project role, or the Is Owner project role if you set the allUsers property. # IAM Permissions Requires no specific IAM permission(s) to use this method. Users are able to list the jobs they created. Additional access is granted based on the following permissions: - Users with the bigquery.jobs.listAll permission can list all jobs with all metadata. - Users with the bigquery.jobs.list permission can list all jobs, but with redacted information for jobs they did not create.
insertinsertprojectIdStarts a new asynchronous job. This API has two different kinds of endpoint URIs, as this method supports a variety of use cases. * The Metadata URI is used for most interactions, as it accepts the job configuration directly. * The Upload URI is ONLY for the case when you're sending both a load job configuration and a data stream together. In this case, the Upload URI accepts the job configuration and the data as two distinct multipart MIME parts. # IAM Permissions Requires the bigquery.jobs.create permission on the project resource. Additional permissions are required depending on the job type: - Load, Export, and Copy jobs: Generally require data-level permissions such as bigquery.tables.export or access to external storage. - Query jobs: Permissions are dependent on the SQL statement. Complex queries (DDL, DCL) may require additional permissions to create reservations, modify IAM policies, or update project settings.
deletedeleteprojectId, +jobIdlocationRequests the deletion of the metadata of a job. This call returns when the job's metadata is deleted. # IAM Permissions Requires the bigquery.jobs.delete permission on the job resource.
queryexecprojectIdRuns a BigQuery SQL query synchronously and returns query results if the query completes within a specified timeout. # IAM Permissions Requires the bigquery.jobs.create permission on the project resource. Data-level permissions are highly dependent on the SQL statement being executed. While standard queries require data access (such as bigquery.tables.getData), complex operations like DDL or DCL may require permissions to manage reservations, IAM policies, or project settings.
cancelexecprojectId, +jobIdlocationRequests that a job be cancelled. This call will return immediately, and the client will need to poll for the job status to see if the cancel completed successfully. Cancelled jobs may still incur costs. # IAM Permissions Requires the bigquery.jobs.update permission on the job resource. If the user matches the creator of the job, the bigquery.jobs.create permission on the project is required instead.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
+jobIdstring
projectIdstring
allUsersboolean
locationstring
maxCreationTimestring (uint64)
maxResultsinteger (uint32)
minCreationTimestring (uint64)
pageTokenstring
parentJobIdstring
projectionstring
stateFilterstring

SELECT examples

Returns information about a specific job. Job information is available for a six month period after creation. Requires that you're the person who ran the job, or have the Is Owner project role. # IAM Permissions Requires the bigquery.jobs.get permission on the job resource. If the user matches the creator of the job, the bigquery.jobs.create permission on the project is required instead.

SELECT
id,
configuration,
etag,
jobCreationReason,
jobReference,
kind,
principal_subject,
selfLink,
statistics,
status,
user_email
FROM google.bigquery.jobs
WHERE projectId = '{{ projectId }}' -- required
AND +jobId = '{{ +jobId }}' -- required
AND location = '{{ location }}'
;

INSERT examples

Starts a new asynchronous job. This API has two different kinds of endpoint URIs, as this method supports a variety of use cases. * The Metadata URI is used for most interactions, as it accepts the job configuration directly. * The Upload URI is ONLY for the case when you're sending both a load job configuration and a data stream together. In this case, the Upload URI accepts the job configuration and the data as two distinct multipart MIME parts. # IAM Permissions Requires the bigquery.jobs.create permission on the project resource. Additional permissions are required depending on the job type: - Load, Export, and Copy jobs: Generally require data-level permissions such as bigquery.tables.export or access to external storage. - Query jobs: Permissions are dependent on the SQL statement. Complex queries (DDL, DCL) may require additional permissions to create reservations, modify IAM policies, or update project settings.

INSERT INTO google.bigquery.jobs (
data__configuration,
data__jobReference,
projectId
)
SELECT
'{{ configuration }}',
'{{ jobReference }}',
'{{ projectId }}'
RETURNING
id,
configuration,
etag,
jobCreationReason,
jobReference,
kind,
principal_subject,
selfLink,
statistics,
status,
user_email
;

DELETE examples

Requests the deletion of the metadata of a job. This call returns when the job's metadata is deleted. # IAM Permissions Requires the bigquery.jobs.delete permission on the job resource.

DELETE FROM google.bigquery.jobs
WHERE projectId = '{{ projectId }}' --required
AND +jobId = '{{ +jobId }}' --required
AND location = '{{ location }}'
;

Lifecycle Methods

Runs a BigQuery SQL query synchronously and returns query results if the query completes within a specified timeout. # IAM Permissions Requires the bigquery.jobs.create permission on the project resource. Data-level permissions are highly dependent on the SQL statement being executed. While standard queries require data access (such as bigquery.tables.getData), complex operations like DDL or DCL may require permissions to manage reservations, IAM policies, or project settings.

EXEC google.bigquery.jobs.query
@projectId='{{ projectId }}' --required
@@json=
'{
"preserveNulls": {{ preserveNulls }},
"location": "{{ location }}",
"labels": "{{ labels }}",
"defaultDataset": "{{ defaultDataset }}",
"queryResultsFormat": "{{ queryResultsFormat }}",
"timeoutMs": {{ timeoutMs }},
"parameterMode": "{{ parameterMode }}",
"requestId": "{{ requestId }}",
"queryParameters": "{{ queryParameters }}",
"continuous": {{ continuous }},
"maxResults": {{ maxResults }},
"connectionProperties": "{{ connectionProperties }}",
"kind": "{{ kind }}",
"jobTimeoutMs": "{{ jobTimeoutMs }}",
"formatOptions": "{{ formatOptions }}",
"useLegacySql": {{ useLegacySql }},
"writeIncrementalResults": {{ writeIncrementalResults }},
"arrowSerializationOptions": "{{ arrowSerializationOptions }}",
"maximumBytesBilled": "{{ maximumBytesBilled }}",
"query": "{{ query }}",
"useQueryCache": {{ useQueryCache }},
"destinationEncryptionConfiguration": "{{ destinationEncryptionConfiguration }}",
"reservation": "{{ reservation }}",
"createSession": {{ createSession }},
"dryRun": {{ dryRun }},
"maxSlots": {{ maxSlots }},
"jobCreationMode": "{{ jobCreationMode }}"
}'
;