Manage jobs
This document describes how to manage jobs in BigQuery,including how toview job details,list jobs,cancel a job,repeat a job,anddelete job metadata.
About BigQuery jobs
Every time youload,export,query, orcopy data, BigQuery automatically creates, schedules, and runs a job that tracks the progress of the task.
Because jobs can potentially take a long time to complete, they run asynchronously and can bepolled for their status. Shorter actions, such as listing resources or getting metadata, are notmanaged as jobs.
When a job is submitted, it can be in one of the following states:
PENDING: The job is scheduled and waiting to be run.RUNNING: The job is in progress.DONE: The job is completed. If the job failed, theJobStatus.errorResult will be present.
Quotas
For information about job quotas, see the documentation for the job type on theQuotas and limits page:
Pricing
Every job is associated with a specific project that you specify. The billingaccount attached to the associated project is billed for any usage incurred bythe job. If you share access to a project, any jobs run in the project arealso billed to the billing account.
For example, when running a query job,the cost is billed to the project that runs the job. Thus when you view the jobID of a query job with the format of<project_id>:<region>.<job_id>, theproject_id is the ID of the project billed for the query.
For more information, seePricing.
Before you begin
Grant Identity and Access Management (IAM) roles that give users the necessarypermissions to perform each task in this document.
Required roles
To get the permissions that you need to run and manage jobs, ask your administrator to grant you the following IAM roles on your project:
- BigQuery Job User (
roles/bigquery.jobUser) - to run or repeat a job, list your jobs, view details of your jobs, and cancel your jobs. - BigQuery User (
roles/bigquery.user) - to run or repeat a job, list your jobs, view details of your jobs, and cancel your jobs (this role is more permissive than BigQuery Job User). - BigQuery Resource Admin (
roles/bigquery.resourceAdmin) - to list all jobs and retrieve metadata on any job. - BigQuery Admin (
roles/bigquery.admin) - to list all jobs, retrieve metadata on any job, and cancel any job.
For more information about granting roles, seeManage access to projects, folders, and organizations.
These predefined roles contain the permissions required to run and manage jobs. To see the exact permissions that are required, expand theRequired permissions section:
Required permissions
The following permissions are required to run and manage jobs:
on the project to run or repeat a job and list your jobs.bigquery.jobs.createon the project to view the metadata for any job.bigquery.jobs.geton the project to cancel any job.bigquery.jobs.updateon the organization, folder, or project to list all jobs and retrieve metadata on any job submitted by any user. To see details for all jobs, thebigquery.jobs.listAllbigquery.jobs.listpermission is also required.on the project to list all jobs and retrieve metadata on any job submitted by any user. For jobs submitted by other users, details and metadata are redacted.bigquery.jobs.liston the organization to list all job execution metadata (without sensitive information) for any job submitted by any user.bigquery.jobs.listExecutionMetadataon the project to cancel any job.bigquery.jobs.updateon the project to delete any job.bigquery.jobs.delete
You might also be able to get these permissions withcustom roles or otherpredefined roles.
For more information about IAM roles and permissions inBigQuery, seePredefined roles and permissions.
View job details
You can view job details by using the Google Cloud console, thebq command-line tool, the API, or the client libraries. The details include data andmetadata, such as the job type, the job state, and the user who created the job.
To view job details, follow these steps:
Console
Go to theBigQuery page.
In the left pane, clickExplorer:

If you don't see the left pane, clickExpand left pane to open the pane.
In theExplorer pane, clickJob history.
Select the type of job history you want to view:
- To display information of your recent jobs, clickPersonal history.
- To display information of recent jobs in your project, clickProject history.
To view job details, click a job.
Note: The duration of a job is calculated by subtracting starttime (instead of creation time) from end time.
bq
Issue thebq showcommand with the--job=true flag and a job ID.
When you supply the job ID, you can use the fully qualified ID or the shortform. For example, job IDs listed in the Google Cloud console are fullyqualified, that is, they include the project and location:
my-project-1234:US.bquijob_123x456_123y123z123c
Job IDs in the command-line tool are listed using the short form.Project ID and location are not included:
bquijob_123x456_123y123z123c
To specify the job location, supply the--location flag and set the valueto yourlocation. This flag is optionalif you use the fully qualified job ID. If you include the--locationflag and you're using the fully qualified job ID, the--location flag isignored.
The following command requests information about a job:
bq--location=LOCATIONshow--job=trueJOB_ID
Replace the following:
LOCATION: the name of thelocation where the job runs. For example, if you are usingBigQuery in the Tokyo region, set the flag's value toasia-northeast1. You can set a default value for the location using the.bigqueryrcfile.If the location isn't specified as part of the job ID or by using the--locationflag, the default location is used.JOB_ID: the ID of the job
Examples
The following command gets summary information about jobUS.bquijob_123x456_123y123z123c running inmyproject:
bq show --job=true myproject:US.bquijob_123x456_123y123z123cThe output is similar to the following:
Job Type State Start Time Duration User Email Bytes Processed Bytes Billed Billing Tier Labels ---------- --------- ----------------- ---------- ------------------- ----------------- -------------- -------------- -------- extract SUCCESS 06 Jul 11:32:10 0:01:41 user@example.com
To see full job details, enter the following:
bq show --format=prettyjson --job=true myproject:US.bquijob_123x456_789y123z456cThe output is similar to the following:
{ "configuration": { "extract": { "compression": "NONE", "destinationUri": "[URI removed]", "destinationUris": [ "[URI removed]" ], "sourceTable": { "datasetId": "github_repos", "projectId": "bigquery-public-data", "tableId": "commits" } } }, "etag": "\"[etag removed]\"", "id": "myproject:bquijob_123x456_789y123z456c", "jobReference": { "jobId": "bquijob_123x456_789y123z456c", "projectId": "[Project ID removed]" }, "kind": "bigquery#job", "selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/federated-testing/jobs/bquijob_123x456_789y123z456c", "statistics": { "creationTime": "1499365894527", "endTime": "1499365894702", "startTime": "1499365894702" }, "status": { "errorResult": { "debugInfo": "[Information removed for readability]", "message": "Operation cannot be performed on a nested schema. Field: author", "reason": "invalid" }, "errors": [ { "message": "Operation cannot be performed on a nested schema. Field: author", "reason": "invalid" } ], "state": "DONE" }, "user_email": "user@example.com"}API
Calljobs.get and providethejobId andprojectId parameters. (Optional) Supply thelocationparameter and set the value to thelocationwhere the job runs. This parameter is optional if you use thefully qualified job ID that includes the location, for example,my-project-1234:US.bquijob_123x456_123y123z123c.
Go
Before trying this sample, follow theGo setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryGo API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
import("context""fmt""io""cloud.google.com/go/bigquery")// getJobInfo demonstrates retrieval of a job, which can be used to monitor// completion or print metadata about the job.funcgetJobInfo(wio.Writer,projectID,jobIDstring)error{// projectID := "my-project-id"// jobID := "my-job-id"ctx:=context.Background()client,err:=bigquery.NewClient(ctx,projectID)iferr!=nil{returnfmt.Errorf("bigquery.NewClient: %v",err)}deferclient.Close()job,err:=client.JobFromID(ctx,jobID)iferr!=nil{returnerr}status:=job.LastStatus()state:="Unknown"switchstatus.State{casebigquery.Pending:state="Pending"casebigquery.Running:state="Running"casebigquery.Done:state="Done"}fmt.Fprintf(w,"Job %s was created %v and is in state %s\n",jobID,status.Statistics.CreationTime,state)returnnil}Java
Before trying this sample, follow theJava setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryJava API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
importcom.google.cloud.bigquery.BigQuery;importcom.google.cloud.bigquery.BigQueryException;importcom.google.cloud.bigquery.BigQueryOptions;importcom.google.cloud.bigquery.Job;importcom.google.cloud.bigquery.JobId;// Sample to get a jobpublicclassGetJob{publicstaticvoidrunGetJob(){// TODO(developer): Replace these variables before running the sample.StringjobName="MY_JOB_NAME";getJob(jobName);}publicstaticvoidgetJob(StringjobName){try{// Initialize client that will be used to send requests. This client only needs to be created// once, and can be reused for multiple requests.BigQuerybigquery=BigQueryOptions.getDefaultInstance().getService();JobIdjobId=JobId.of(jobName);Jobjob=bigquery.getJob(jobId);System.out.println("Job retrieved successfully");}catch(BigQueryExceptione){System.out.println("Job not retrieved. \n"+e.toString());}}}Node.js
Before trying this sample, follow theNode.js setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryNode.js API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
// Import the Google Cloud client libraryconst{BigQuery}=require('@google-cloud/bigquery');constbigquery=newBigQuery();asyncfunctiongetJob(){// Get job properties./** * TODO(developer): Uncomment the following lines before running the sample. */// const jobId = "existing-job-id";// Create a job referenceconstjob=bigquery.job(jobId);// Retrieve jobconst[jobResult]=awaitjob.get();console.log(jobResult.metadata.jobReference);}Python
Before trying this sample, follow thePython setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryPython API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
fromgoogle.cloudimportbigquerydefget_job(client:bigquery.Client,location:str="us",job_id:str="abcd-efgh-ijkl-mnop",)->None:job=client.get_job(job_id,location=location)# All job classes have "location" and "job_id" string properties.# Use these properties for job operations such as "cancel_job" and# "delete_job".print(f"{job.location}:{job.job_id}")print(f"Type:{job.job_type}")print(f"State:{job.state}")print(f"Created:{job.created.isoformat()}")If you need more information to troubleshoot a job, see theINFORMATION_SCHEMA.JOBS* views andLogs.
List jobs
BigQuery saves a six-month job historyfor all the jobs of a project, for all locations. The job history includes jobsthat are in theRUNNING state and jobs that areDONE (indicated by reporting the state asSUCCESS orFAILURE).
To list jobs in a project, follow these steps:
Console
Go to theBigQuery page.
In the left pane, clickExplorer:

In theExplorer pane, clickJob history.
To list all jobs in a project, clickProject history. If you aren'tthe project owner, you might not have permission to view all the jobs fora project. The most recent jobs are listed first.
To list your jobs, clickPersonal history.
bq
Issue thebq lscommand with one of the following flags:
--jobs=trueor-j: identifies jobs as the type of resource tolist.--all=trueor-a: lists jobs from all users. To see full (unredacted)details for all jobs, you must havebigquery.jobs.listAllpermissions.--min_creation_time: lists jobs after a supplied timestampvalue. This value is represented as aUnix epoch timestamp in milliseconds.--max_creation_time: lists jobs before a supplied timestampvalue. This value is represented as aUnix epoch timestamp in milliseconds.--max_resultsor-nlimits the results. The default is 50 results.
bqls--jobs=true--all=true\--min_creation_time=MIN_TIME\--max_creation_time=MAX_TIME\--max_results=MAX_RESULTS\PROJECT_ID
Replace the following:
MIN_TIME: an integer that represents aUnix epochtimestamp in milliseconds.MAX_TIME: an integer that represents aUnix epochtimestamp in milliseconds.MAX_RESULTS: an integer that indicates the numberof jobs returned.PROJECT_ID: the ID of the project that containsthe jobs that you're listing. If youset a default project,you don't need to provide thePROJECT_IDparameter.
Examples
The following command lists all jobs for the current user. Running thiscommand requiresbigquery.jobs.list permissions.
bq ls --jobs=true myprojectThe following command lists all jobs for all users. Running this commandrequiresbigquery.jobs.listAll permissions.
bq ls --jobs=true --all=true myprojectThe following command lists the 10 most recent jobs inmyproject:
bq ls --jobs=true --all=true --max_results=10 myprojectThe following command lists all jobs submitted before March 3, 2032, at4:04:00 AM. This timestamp (in milliseconds) is equivalent to the followinginteger value:1961899440000.
bq ls --jobs=true --max_creation_time=1961899440000API
Call thejobs.list method and providetheprojectId parameter. To list jobs for all users, set theallUsersparameter totrue. SettingallUsers totrue requiresbigquery.jobs.listAll permissions. Thejobs.list method doesn't returnchild jobs. To list child jobs, use theINFORMATION_SCHEMA.JOBS view.
Go
Before trying this sample, follow theGo setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryGo API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
import("context""fmt""io""cloud.google.com/go/bigquery""google.golang.org/api/iterator")// listJobs demonstrates iterating through the BigQuery jobs collection.funclistJobs(wio.Writer,projectIDstring)error{// projectID := "my-project-id"// jobID := "my-job-id"ctx:=context.Background()client,err:=bigquery.NewClient(ctx,projectID)iferr!=nil{returnfmt.Errorf("bigquery.NewClient: %v",err)}deferclient.Close()it:=client.Jobs(ctx)// List up to 10 jobs to demonstrate iteration.fori:=0;i <10;i++{j,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{returnerr}state:="Unknown"switchj.LastStatus().State{casebigquery.Pending:state="Pending"casebigquery.Running:state="Running"casebigquery.Done:state="Done"}fmt.Fprintf(w,"Job %s in state %s\n",j.ID(),state)}returnnil}Java
Before trying this sample, follow theJava setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryJava API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
importcom.google.api.gax.paging.Page;importcom.google.cloud.bigquery.BigQuery;importcom.google.cloud.bigquery.BigQueryException;importcom.google.cloud.bigquery.BigQueryOptions;importcom.google.cloud.bigquery.Job;// Sample to get list of jobspublicclassListJobs{publicstaticvoidrunListJobs(){listJobs();}publicstaticvoidlistJobs(){try{// Initialize client that will be used to send requests. This client only needs to be created// once, and can be reused for multiple requests.BigQuerybigquery=BigQueryOptions.getDefaultInstance().getService();Page<Job>jobs=bigquery.listJobs(BigQuery.JobListOption.pageSize(10));if(jobs==null){System.out.println("Dataset does not contain any jobs.");return;}jobs.getValues().forEach(job->System.out.printf("Success! Job ID: %s",job.getJobId()));}catch(BigQueryExceptione){System.out.println("Jobs not listed in dataset due to error: \n"+e.toString());}}}Node.js
Before trying this sample, follow theNode.js setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryNode.js API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
// Import the Google Cloud client libraryconst{BigQuery}=require('@google-cloud/bigquery');constbigquery=newBigQuery();asyncfunctionlistJobs(){// Lists all jobs in current GCP project.// List the 10 most recent jobs in reverse chronological order.// Omit the max_results parameter to list jobs from the past 6 months.constoptions={maxResults:10};const[jobs]=awaitbigquery.getJobs(options);console.log('Jobs:');jobs.forEach(job=>console.log(job.id));}Python
Before trying this sample, follow thePython setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryPython API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
fromgoogle.cloudimportbigqueryimportdatetime# Construct a BigQuery client object.client=bigquery.Client()# List the 10 most recent jobs in reverse chronological order.# Omit the max_results parameter to list jobs from the past 6 months.print("Last 10 jobs:")forjobinclient.list_jobs(max_results=10):# API request(s)print("{}".format(job.job_id))# The following are examples of additional optional parameters:# Use min_creation_time and/or max_creation_time to specify a time window.print("Jobs from the last ten minutes:")ten_mins_ago=datetime.datetime.utcnow()-datetime.timedelta(minutes=10)forjobinclient.list_jobs(min_creation_time=ten_mins_ago):print("{}".format(job.job_id))# Use all_users to include jobs run by all users in the project.print("Last 10 jobs run by all users:")forjobinclient.list_jobs(max_results=10,all_users=True):print("{} run by user:{}".format(job.job_id,job.user_email))# Use state_filter to filter by job state.print("Last 10 jobs done:")forjobinclient.list_jobs(max_results=10,state_filter="DONE"):print("{}".format(job.job_id))Cancel a job
You can cancel aRUNNING orPENDING job.It usually takes less than a minute to complete a job cancellation.
Even if the job can be canceled, success is not guaranteed. The job might havecompleted by the time the cancel request is submitted, or the job might be in astage where it cannot be canceled.
Note: You can still incur costs after canceling a job depending on the stage atwhich it was canceled. For more information, see thePricingpage.To cancel a job, follow these steps:
Console
Go to theBigQuery page.
ClickCompose new query and enter a query.
To run the query, clickRun.
To cancel a job, clickCancel.
SQL
Use theBQ.JOBS.CANCEL system procedure:
CALLBQ.JOBS.CANCEL('JOB_ID');ReplaceJOB_ID with the ID of the job you're canceling.
If you are in a different project but in the same region as the job youwant to cancel, you must also include the project ID:
CALLBQ.JOBS.CANCEL('PROJECT_ID.JOB_ID');Replace the following:
PROJECT_ID: the ID of the project that containsthe job that you're cancelingJOB_ID: the ID of the job that you're canceling
The procedure returns immediately, and BigQuery cancels thejob shortly afterward. If the job has already succeeded or failed, theprocedure has no effect.
bq
Issue thebq cancelcommand with theJOB_ID argument. You can requestcancellation and return immediately by using the--nosync=true flag. Bydefault, cancellation requests wait for completion.
When you supply theJOB_ID argument, you can use thefully qualified ID or the shortform. For example, job IDs listed in the Google Cloud console are fullyqualified; that is, they include the project and location:
my-project-1234:US.bquijob_123x456_123y123z123c
Job IDs in the bq command-line tool are listed using the short form. Project ID andlocation are not included:
bquijob_123x456_123y123z123c
To specify the job location, supply the--location flag and set the valueto yourlocation. This flag is optionalif you use the fully qualified job ID. If you include the--locationflag and you're using the fully qualified job ID, the--location flag isignored.
The following command requests job cancellation and waits for completion. Ifthe fully qualified job ID is supplied, the--location flag is ignored:
bq--location=LOCATIONcancelJOB_IDThe following command requests job cancellation and returns immediately. Ifthe fully qualified job ID is supplied, the--location flag is ignored:
bq--location=LOCATION--nosynccancelJOB_IDReplace the following:
LOCATION(optional): the name of thelocation where the job runs. For example, if you are usingBigQuery in the Tokyo region, set the flag's value toasia-northeast1. You can set a default value for the location using the.bigqueryrcfile.JOB_ID: the ID of the job that you're canceling.If you copy the job ID from the Google Cloud console, the project ID andlocation are included in the job ID. For example,my-project-1234:US.bquijob_123x456_123y123z123c.
Examples
The following command cancels the jobmy-project-1234:US.bquijob_123x456_123y123z123c running intheUS multi-region location in themy-project-1234 project, and waitsforcompletion. Because the fully qualified job ID is used, the location flag isnot supplied.
bq cancel my-project-1234:US.bquijob_123x456_123y123z123cThe following command cancels the jobbquijob_123x456_123y123z123c running intheUS multi-region location in themy-project-1234 project and waitsforcompletion. Because the short form of the job ID is used, the--locationflag is supplied.
bq --location=US cancel bquijob_123x456_123y123z123cThe following command cancels the jobbquijob_123x456_123y123z123c runningin theUS multi-region location in themy-project-1234 project,and returns immediately.Because the fully qualified job ID is used, the--location flag isnot supplied.
bq --nosync cancel my-project-1234:US.bquijob_123x456_123y123z123cAPI
Calljobs.cancel and providethejobId andprojectId parameters. Supply thelocationparameter and set the value to thelocationwhere the job runs.
Go
Before trying this sample, follow theGo setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryGo API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
import("context""fmt""cloud.google.com/go/bigquery")// cancelJob demonstrates how a job cancellation request can be issued for a specific// BigQuery job.funccancelJob(projectID,jobIDstring)error{// projectID := "my-project-id"// jobID := "my-job-id"ctx:=context.Background()client,err:=bigquery.NewClient(ctx,projectID)iferr!=nil{returnfmt.Errorf("bigquery.NewClient: %v",err)}deferclient.Close()job,err:=client.JobFromID(ctx,jobID)iferr!=nil{returnnil}returnjob.Cancel(ctx)}Java
Before trying this sample, follow theJava setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryJava API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
importcom.google.cloud.bigquery.BigQuery;importcom.google.cloud.bigquery.BigQueryException;importcom.google.cloud.bigquery.BigQueryOptions;importcom.google.cloud.bigquery.Job;importcom.google.cloud.bigquery.JobId;importcom.google.cloud.bigquery.JobInfo;importcom.google.cloud.bigquery.QueryJobConfiguration;importjava.util.UUID;// Sample to cancel a jobpublicclassCancelJob{publicstaticvoidrunCancelJob(){// TODO(developer): Replace these variables before running the sample.Stringquery="SELECT country_name from `bigquery-public-data.utility_us.country_code_iso`";cancelJob(query);}publicstaticvoidcancelJob(Stringquery){try{// Initialize client that will be used to send requests. This client only needs to be created// once, and can be reused for multiple requests.BigQuerybigquery=BigQueryOptions.getDefaultInstance().getService();// Specify a job configuration to set optional job resource properties.QueryJobConfigurationqueryConfig=QueryJobConfiguration.newBuilder(query).build();// The location and job name are optional,// if both are not specified then client will auto-create.StringjobName="jobId_"+UUID.randomUUID().toString();JobIdjobId=JobId.newBuilder().setLocation("us").setJob(jobName).build();// Create a job with job IDbigquery.create(JobInfo.of(jobId,queryConfig));// Get a job that was just createdJobjob=bigquery.getJob(jobId);if(job.cancel()){System.out.println("Job canceled successfully");}else{System.out.println("Job was not canceled");}}catch(BigQueryExceptione){System.out.println("Job was not canceled.\n"+e.toString());}}}Node.js
Before trying this sample, follow theNode.js setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryNode.js API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
// Import the Google Cloud client libraryconst{BigQuery}=require('@google-cloud/bigquery');constbigquery=newBigQuery();asyncfunctioncancelJob(){// Attempts to cancel a job./** * TODO(developer): Uncomment the following lines before running the sample. */// const jobId = "existing-job-id";// Create a job referenceconstjob=bigquery.job(jobId);// Attempt to cancel jobconst[apiResult]=awaitjob.cancel();console.log(apiResult.job.status);}Python
Before trying this sample, follow thePython setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryPython API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
Delete job metadata
You can delete the metadata for a specific job using the bq command-line tool and the Python client library.BigQuery preserves a history of jobs executedin the past 6 months. You can use this method to remove sensitive informationthat might be present in query statements. Job metadata can only be deletedafter the job is complete. If a job has created child jobs, the child jobs arealso deleted. Deletion of child jobs is notallowed. Only parent or top-level jobs can be deleted.
To delete job metadata, follow these steps:
bq
Issue thebq rm command with the-j flag and a job ID.
When you supply the job ID, you can use the fully qualified ID or the shortform. For example, job IDs listed in the Google Cloud console are fullyqualified, that is, they include the project and location:
my-project-1234:US.bquijob_123x456_123y123z123c
Job IDs in the bq command-line tool are listed using the short form.Project ID and location are not included:
bquijob_123x456_123y123z123c
To specify the job location, supply the--location flag and set the valueto yourlocation. This flag is optionalif you use the fully qualified job ID. If you include the--locationflag and you're using the fully qualified job ID, the--location flag isignored.
The following command deletes a job:
bq--location=location\--project_id=project_id\rm-jjob_id
Python
Before trying this sample, follow thePython setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryPython API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
fromgoogle.api_coreimportexceptionsfromgoogle.cloudimportbigquery# TODO(developer): Set the job ID to the ID of the job whose metadata you# wish to delete.job_id="abcd-efgh-ijkl-mnop"# TODO(developer): Set the location to the region or multi-region# containing the job.location="us-east1"client=bigquery.Client()client.delete_job_metadata(job_id,location=location)try:client.get_job(job_id,location=location)exceptexceptions.NotFound:print(f"Job metadata for job{location}:{job_id} was deleted.")Repeat jobs
It is not possible to repeat a job by using the same job ID. Instead, you create anew job with the same configuration. When you submit the new job in theGoogle Cloud console or the bq command-line tool, a new job ID is assigned. When yousubmit the job using the API or client libraries, you must generate a new jobID.
To repeat a job, follow these steps:
Console
To repeat a query job, follow these steps:
Go to theBigQuery page.
In the left pane, clickExplorer:

In theExplorer pane, clickJob history.
To list all your jobs, clickPersonal history. To list all jobs in a project, clickProject history.
Click a query job to open the job details.
To repeat a query, clickOpen as new query.
ClickRun.
To repeat a load job, do the following:
Go to theBigQuery page.
In the left pane, clickExplorer:

In theExplorer pane, clickJob history.
To list all your jobs, clickPersonal history. To list all jobs in a project, clickProject history.
Click a load job to open the job details.
To repeat a job, clickRepeat load job.
bq
Issue your command again and BigQuery automaticallygenerates a job with a new job ID.
API
There is no single-call method to repeat a job; if you want to repeat aspecific job:
Call
jobs.gettoretrieve the resource for the job to repeat.Remove theid,status, andstatistics field.Change thejobId field to a new value generated by your clientcode. Change any other fields as necessary.
Call
jobs.insertwiththe modified resource and the new job ID to start the new job.
What's next
- Learn how torun jobs programmatically.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.