1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- #include " google/cloud/bigtable/internal/defaults.h"
1615#include " google/cloud/bigtable/client.h"
16+ #include " google/cloud/bigtable/internal/defaults.h"
1717#include " google/cloud/bigtable/testing/table_integration_test.h"
1818#include " google/cloud/log.h"
1919#include " google/cloud/testing_util/chrono_literals.h"
@@ -31,12 +31,14 @@ namespace {
3131using ::google::cloud::bigtable::testing::TableIntegrationTest;
3232using ::google::cloud::bigtable::testing::TableTestEnvironment;
3333using ::google::cloud::testing_util::chrono_literals::operator " " _ms;
34+ using ::google::cloud::testing_util::IsOkAndHolds;
3435using ::std::chrono::duration_cast;
3536using ::std::chrono::microseconds;
3637using ::std::chrono::milliseconds;
3738using ::testing::Contains;
3839using ::testing::ElementsAre;
3940using ::testing::HasSubstr;
41+ using ms = std::chrono::milliseconds;
4042
4143class DataIntegrationTest : public TableIntegrationTest ,
4244 public ::testing::WithParamInterface<std::string> {
@@ -188,7 +190,11 @@ TEST_P(DataIntegrationTest, TableReadRowTest) {
188190}
189191
190192TEST_P (DataIntegrationTest, ClientQueryTest) {
191- auto table = GetTable (GetParam ());
193+ auto const table_id = testing::TableTestEnvironment::table_id ();
194+ auto conn = MakeDataConnection (Options{}.set <DataRetryPolicyOption>(
195+ DataLimitedErrorCountRetryPolicy (0 ).clone ()));
196+ auto table = Table (std::move (conn),
197+ TableResource (project_id (), instance_id (), table_id));
192198 std::string const row_key = " row-key-for-client-query-test" ;
193199 std::string const family = kFamily4 ;
194200 std::string const column1 = " c1" ;
@@ -200,19 +206,27 @@ TEST_P(DataIntegrationTest, ClientQueryTest) {
200206 {row_key, family, column1, 0 , value1},
201207 {row_key, family, column2, 0 , value2},
202208 };
203- // CreateCells(table, created);
204209 BulkApply (table, created);
205-
206210 auto data_connection = table.connection ();
207- auto client = Client (data_connection);
208- std::vector<std::string> full_table_path =
211+ auto client =
212+ Client (data_connection,
213+ Options{}
214+ .set <DataRetryPolicyOption>(
215+ DataLimitedErrorCountRetryPolicy (0 ).clone ())
216+ .set <DataBackoffPolicyOption>(
217+ google::cloud::internal::ExponentialBackoffPolicy (
218+ ms (0 ), ms (0 ), 2.0 )
219+ .clone ()));
220+ std::vector<std::string> full_table_path =
209221 absl::StrSplit (table.table_name (), " /" );
210222 auto table_name = full_table_path.back ();
223+ std::string quoted_table_name = " `" + table_name + " `" ;
211224 Project project (project_id ());
212225 InstanceResource instance_resource (project, instance_id ());
213226 auto prepared_query = client.PrepareQuery (
214227 instance_resource,
215- SqlStatement (" SELECT " + column1 + " FROM " + table_name + " WHERE row_key = '" + row_key + " '" ));
228+ SqlStatement (" SELECT CAST(family4['c0'] AS STRING) AS c0 FROM " +
229+ quoted_table_name + " WHERE _key = '" + row_key + " '" ));
216230 ASSERT_STATUS_OK (prepared_query);
217231
218232 auto bound_query = prepared_query->BindParameters ({});
@@ -224,6 +238,9 @@ TEST_P(DataIntegrationTest, ClientQueryTest) {
224238 }
225239
226240 ASSERT_EQ (rows.size (), 1 );
241+ ASSERT_STATUS_OK (rows[0 ]);
242+ auto const & row1 = *rows[0 ];
243+ EXPECT_THAT (row1.columns ().at (0 ), " c0" );
227244}
228245
229246TEST_P (DataIntegrationTest, TableReadRowNotExistTest) {
0 commit comments