Skip to content

Commit f928005

Browse files
authored
impl(bigtable): add response accessor to PreparedQuery (#15769)
1 parent 12b7259 commit f928005

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

google/cloud/bigtable/bound_query.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ class BoundQuery {
5252
std::unordered_map<std::string, Value> const& parameters() const {
5353
return parameters_;
5454
}
55+
56+
// This data may change if a Query Plan Refresh is performed. If the original
57+
// response data is needed for your application, consider copying the response
58+
// data immediately after a successful Client::PrepareQuery.
5559
StatusOr<google::bigtable::v2::PrepareQueryResponse> response();
5660

5761
google::bigtable::v2::ExecuteQueryRequest ToRequestProto() const;

google/cloud/bigtable/prepared_query.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@
1313
// limitations under the License.
1414

1515
#include "google/cloud/bigtable/prepared_query.h"
16+
#include "google/cloud/bigtable/internal/query_plan.h"
1617
#include "google/cloud/bigtable/sql_statement.h"
1718

1819
namespace google {
1920
namespace cloud {
2021
namespace bigtable {
2122
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
2223

24+
StatusOr<google::bigtable::v2::PrepareQueryResponse> PreparedQuery::response() {
25+
return query_plan_->response();
26+
}
27+
2328
BoundQuery PreparedQuery::BindParameters(
2429
std::unordered_map<std::string, Value> params) const {
2530
return BoundQuery(instance_, query_plan_, std::move(params));

google/cloud/bigtable/prepared_query.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ class PreparedQuery {
4949
InstanceResource const& instance() const { return instance_; }
5050
SqlStatement const& sql_statement() const { return sql_statement_; }
5151

52+
// This data may change if a Query Plan Refresh is performed. If the original
53+
// response data is needed for your application, consider copying the response
54+
// data immediately after a successful Client::PrepareQuery.
55+
StatusOr<google::bigtable::v2::PrepareQueryResponse> response();
56+
5257
// Creates an instance of BoundQuery using the query plan ID from the
5358
// response.
5459
BoundQuery BindParameters(

0 commit comments

Comments
 (0)