File tree 2 files changed +40
-0
lines changed
2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -2582,6 +2582,29 @@ func TestIntegration_ListJobs(t *testing.T) {
2582
2582
}
2583
2583
}
2584
2584
2585
+ func TestIntegration_DeleteJob (t * testing.T ) {
2586
+ if client == nil {
2587
+ t .Skip ("Integration tests skipped" )
2588
+ }
2589
+ ctx := context .Background ()
2590
+
2591
+ q := client .Query ("SELECT 17 as foo" )
2592
+ q .Location = "us-east1"
2593
+
2594
+ job , err := q .Run (ctx )
2595
+ if err != nil {
2596
+ t .Fatalf ("job Run failure: %v" , err )
2597
+ }
2598
+ _ , err = job .Wait (ctx )
2599
+ if err != nil {
2600
+ t .Fatalf ("job completion failure: %v" , err )
2601
+ }
2602
+
2603
+ if err := job .Delete (ctx ); err != nil {
2604
+ t .Fatalf ("job.Delete failed: %v" , err )
2605
+ }
2606
+ }
2607
+
2585
2608
const tokyo = "asia-northeast1"
2586
2609
2587
2610
func TestIntegration_Location (t * testing.T ) {
Original file line number Diff line number Diff line change @@ -233,6 +233,23 @@ func (j *Job) Cancel(ctx context.Context) error {
233
233
})
234
234
}
235
235
236
+ // Delete deletes the job.
237
+ func (j * Job ) Delete (ctx context.Context ) (err error ) {
238
+ ctx = trace .StartSpan (ctx , "cloud.google.com/go/bigquery.Job.Delete" )
239
+ defer func () { trace .EndSpan (ctx , err ) }()
240
+
241
+ call := j .c .bqs .Jobs .Delete (j .projectID , j .jobID ).Context (ctx )
242
+ if j .location != "" {
243
+ call = call .Location (j .location )
244
+ }
245
+ setClientHeader (call .Header ())
246
+
247
+ return runWithRetry (ctx , func () (err error ) {
248
+ err = call .Do ()
249
+ return err
250
+ })
251
+ }
252
+
236
253
// Wait blocks until the job or the context is done. It returns the final status
237
254
// of the job.
238
255
// If an error occurs while retrieving the status, Wait returns that error. But
You can’t perform that action at this time.
0 commit comments