diff --git a/google/cloud/bigquery_unified/client.cc b/google/cloud/bigquery_unified/client.cc index 5abc202..cda34c0 100644 --- a/google/cloud/bigquery_unified/client.cc +++ b/google/cloud/bigquery_unified/client.cc @@ -58,7 +58,8 @@ StatusOr Client::GetJob( Status Client::DeleteJob( google::cloud::bigquery::v2::DeleteJobRequest const& request, Options opts) { - return internal::UnimplementedError("not implemented"); + return connection_->DeleteJob( + request, internal::MergeOptions(std::move(opts), options_)); } StreamRange Client::ListJobs( diff --git a/google/cloud/bigquery_unified/integration_tests/job_integration_test.cc b/google/cloud/bigquery_unified/integration_tests/job_integration_test.cc index 66066e8..ebceb2f 100644 --- a/google/cloud/bigquery_unified/integration_tests/job_integration_test.cc +++ b/google/cloud/bigquery_unified/integration_tests/job_integration_test.cc @@ -41,7 +41,7 @@ TEST_F(JobIntegrationTest, GetJob) { auto client = google::cloud::bigquery_unified::Client(connection); // TODO: hard coding this id is brittle but currently necessary. - std::string const job_id = "job_TyRhPS6z-5_e9JSwtT8ieuwDOdLD"; + std::string const job_id = "bquxjob_606db6e8_19465e708c7"; bigquery_proto::GetJobRequest get_request; get_request.set_project_id(project_id_); get_request.set_job_id(job_id); @@ -50,6 +50,22 @@ TEST_F(JobIntegrationTest, GetJob) { EXPECT_THAT(job->status().state(), Eq("DONE")); } +TEST_F(JobIntegrationTest, DeleteJob) { + namespace bigquery_proto = google::cloud::bigquery::v2; + std::shared_ptr connection = + google::cloud::bigquery_unified::MakeConnection(); + auto client = google::cloud::bigquery_unified::Client(connection); + + // TODO: hard coding this id is brittle but currently necessary. + std::string const job_id = "bquxjob_606db6e8_19465e708c7"; + + bigquery_proto::DeleteJobRequest delete_request; + delete_request.set_project_id(project_id_); + delete_request.set_job_id(job_id); + auto status = client.DeleteJob(delete_request); + ASSERT_STATUS_OK(status); +} + } // namespace GOOGLE_CLOUD_CPP_BIGQUERY_INLINE_NAMESPACE_END } // namespace google::cloud::bigquery_unified diff --git a/google/cloud/bigquery_unified/internal/connection_impl.cc b/google/cloud/bigquery_unified/internal/connection_impl.cc index 5a6dbef..272903e 100644 --- a/google/cloud/bigquery_unified/internal/connection_impl.cc +++ b/google/cloud/bigquery_unified/internal/connection_impl.cc @@ -43,6 +43,16 @@ StatusOr ConnectionImpl::GetJob( return job_connection_->GetJob(request); } +Status ConnectionImpl::DeleteJob( + google::cloud::bigquery::v2::DeleteJobRequest const& request, + Options opts) { + // TODO: Instead of creating an OptionsSpan, pass opts when job_connection_ + // supports it. + internal::OptionsSpan span(internal::MergeOptions( + std::move(opts), internal::MergeOptions(options_, job_options_))); + return job_connection_->DeleteJob(request); +} + std::shared_ptr MakeDefaultConnectionImpl( Options options) { auto job_options = diff --git a/google/cloud/bigquery_unified/internal/connection_impl.h b/google/cloud/bigquery_unified/internal/connection_impl.h index 2b98260..b39d52a 100644 --- a/google/cloud/bigquery_unified/internal/connection_impl.h +++ b/google/cloud/bigquery_unified/internal/connection_impl.h @@ -40,6 +40,9 @@ class ConnectionImpl : public bigquery_unified::Connection { google::cloud::bigquery::v2::GetJobRequest const& request, Options opts) override; + Status DeleteJob(google::cloud::bigquery::v2::DeleteJobRequest const& request, + Options opts) override; + private: std::shared_ptr job_connection_; std::shared_ptr job_stub_;