This repository was archived by the owner on Feb 7, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -134,6 +134,53 @@ class Job extends Operation {
134134 let location : string ;
135135
136136 const methods = {
137+ /**
138+ * @callback DeleteJobCallback
139+ * @param {?Error } err Request error, if any.
140+ * @param {object } apiResponse The full API response.
141+ */
142+ /**
143+ * @typedef {array } DeleteJobResponse
144+ * @property {object } 0 The full API response.
145+ */
146+ /**
147+ * Delete the job.
148+ *
149+ * @see [Jobs: delete API Documentation]{@link https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/delete}
150+ *
151+ * @method Job#delete
152+ * @param {DeleteJobCallback } [callback] The callback function.
153+ * @param {?error } callback.err An error returned while making this
154+ * request.
155+ * @param {object } callback.apiResponse The full API response.
156+ * @returns {Promise<DeleteJobResponse> }
157+ *
158+ * @example
159+ * const {BigQuery} = require('@google-cloud/bigquery');
160+ * const bigquery = new BigQuery();
161+ *
162+ * const job = bigquery.job(jobId);
163+ * job.delete((err, apiResponse) => {
164+ * if (!err) {
165+ * // The job was deleted successfully.
166+ * }
167+ * });
168+ *
169+ * @example If the callback is omitted a Promise will be returned
170+ * const [apiResponse] = await job.delete();
171+ */
172+ delete : {
173+ reqOpts : {
174+ method : 'DELETE' ,
175+ uri : '/delete' ,
176+ qs : {
177+ get location ( ) {
178+ return location ;
179+ } ,
180+ } ,
181+ } ,
182+ } ,
183+
137184 /**
138185 * @callback JobExistsCallback
139186 * @param {?Error } err Request error, if any.
Original file line number Diff line number Diff line change @@ -646,6 +646,25 @@ describe('BigQuery', () => {
646646 } ) ;
647647 } ) ;
648648
649+ describe ( 'BigQuery/Job' , ( ) => {
650+ it ( 'should delete a job' , async ( ) => {
651+ const opts = {
652+ configuration : {
653+ query : {
654+ query : 'SELECT 100 as foo' ,
655+ } ,
656+ } ,
657+ location : 'us-east1' ,
658+ } ;
659+
660+ const [ job ] = await bigquery . createJob ( opts ) ;
661+ const [ resp ] = await job . delete ( ) ;
662+ const [ exists ] = await job . exists ( ) ;
663+ assert . deepStrictEqual ( resp , { } ) ;
664+ assert . strictEqual ( exists , false ) ;
665+ } ) ;
666+ } ) ;
667+
649668 describe ( 'BigQuery/Model' , ( ) => {
650669 let model : Model ;
651670 const bucket = storage . bucket ( generateName ( 'bucket' ) ) ;
Original file line number Diff line number Diff line change @@ -123,6 +123,13 @@ describe('BigQuery/Job', () => {
123123 assert . strictEqual ( calledWith . baseUrl , '/jobs' ) ;
124124 assert . strictEqual ( calledWith . id , JOB_ID ) ;
125125 assert . deepStrictEqual ( calledWith . methods , {
126+ delete : {
127+ reqOpts : {
128+ method : 'DELETE' ,
129+ uri : '/delete' ,
130+ qs : { location : undefined } ,
131+ } ,
132+ } ,
126133 exists : true ,
127134 get : true ,
128135 getMetadata : {
You can’t perform that action at this time.
0 commit comments