diff --git a/google-cloud-bigquery/clirr-ignored-differences.xml b/google-cloud-bigquery/clirr-ignored-differences.xml
index 2801782f4..4d66f0620 100644
--- a/google-cloud-bigquery/clirr-ignored-differences.xml
+++ b/google-cloud-bigquery/clirr-ignored-differences.xml
@@ -3,13 +3,13 @@
- 7013
- com/google/cloud/bigquery/ExternalTableDefinition
- com.google.common.collect.ImmutableList getDecimalTargetTypes()
+ 7012
+ com/google/cloud/bigquery/BigQuery
+ boolean delete(com.google.cloud.bigquery.JobId)
- 7013
- com/google/cloud/bigquery/ExternalTableDefinition$Builder
- com.google.cloud.bigquery.ExternalTableDefinition$Builder setDecimalTargetTypes(java.util.List)
+ 7012
+ com/google/cloud/bigquery/spi/v2/BigQueryRpc
+ boolean deleteJob(java.lang.String, java.lang.String, java.lang.String)
\ No newline at end of file
diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java
index 70a29fd9f..4e88f000f 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java
@@ -982,6 +982,14 @@ public int hashCode() {
*/
boolean delete(RoutineId routineId);
+ /**
+ * Deletes the requested job.
+ *
+ * @return {@code true} if job was deleted, {@code false} if it was not found
+ * @throws BigQueryException upon failure
+ */
+ boolean delete(JobId jobId);
+
/**
* Updates dataset information.
*
diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java
index 12eb09c5a..4086c6a73 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java
@@ -585,6 +585,30 @@ public Boolean call() {
}
}
+ @Override
+ public boolean delete(JobId jobId) {
+ final JobId completeJobId =
+ jobId.setProjectId(
+ Strings.isNullOrEmpty(jobId.getProject())
+ ? getOptions().getProjectId()
+ : jobId.getProject());
+ try {
+ return runWithRetries(
+ new Callable() {
+ @Override
+ public Boolean call() {
+ return bigQueryRpc.deleteJob(
+ completeJobId.getProject(), completeJobId.getJob(), completeJobId.getLocation());
+ }
+ },
+ getOptions().getRetrySettings(),
+ EXCEPTION_HANDLER,
+ getOptions().getClock());
+ } catch (RetryHelper.RetryHelperException e) {
+ throw BigQueryException.translateAndThrow(e);
+ }
+ }
+
@Override
public Dataset update(DatasetInfo datasetInfo, DatasetOption... options) {
final com.google.api.services.bigquery.model.Dataset datasetPb =
diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/BigQueryRpc.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/BigQueryRpc.java
index c9b0f0a21..06488c5b4 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/BigQueryRpc.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/BigQueryRpc.java
@@ -270,6 +270,14 @@ TableDataList listTableData(
*/
boolean cancel(String projectId, String jobId, String location);
+ /**
+ * Sends a job delete request.
+ *
+ * @return {@code true} if delete was successful, {@code false} if the job was not found
+ * @throws BigQueryException upon failure
+ */
+ boolean deleteJob(String projectId, String jobName, String location);
+
/**
* Returns results of the query associated with the provided job.
*
diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java
index 4d9558454..24d7dd6b0 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/spi/v2/HttpBigQueryRpc.java
@@ -607,6 +607,21 @@ public boolean cancel(String projectId, String jobId, String location) {
}
}
+ @Override
+ public boolean deleteJob(String projectId, String jobName, String location) {
+ try {
+ bigquery
+ .jobs()
+ .delete(projectId, jobName)
+ .setLocation(location)
+ .setPrettyPrint(false)
+ .execute();
+ return true;
+ } catch (IOException ex) {
+ throw translate(ex);
+ }
+ }
+
@Override
public GetQueryResultsResponse getQueryResults(
String projectId, String jobId, String location, Map