Note that the DataConnection is not associated with any resource ids. They are instead packaged as a TableResource and passed as a single object to Table.
Optional configuration
Note that there is only one Table constructor that accepts a DataConnection. All configuration is done via the Options parameter.
The retry, backoff, and idempotency policies are packaged in Options as shared_ptrs, instead of passed by value as variadic parameters to Table(..., Policies&&).
Also note that the retry and backoff policy types have changed. If you defined your own policy, extending RPCRetryPolicy or RPCBackoffPolicy, it will not be compatible with the new types. The new policies do not have a Setup(grpc::ClientContext&) function. This function has not been included because we believe that setting up the grpc::ClientContext...
Should not be tied to the retry policies.
Is unlikely to be needed by external customers.
If you do need a Setup() feature, please open a feature request explaining your use case, and we will be happy to accommodate you.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["\u003cp\u003eThis document guides users on migrating existing C++ code from \u003ccode\u003eDataClient\u003c/code\u003e to \u003ccode\u003eDataConnection\u003c/code\u003e within the Google Cloud Bigtable library.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eDataConnection\u003c/code\u003e is not directly associated with resource IDs; instead, they are encapsulated within a \u003ccode\u003eTableResource\u003c/code\u003e object that is passed to \u003ccode\u003eTable\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eConfiguration settings like application profile IDs are now managed through the \u003ccode\u003eOptions\u003c/code\u003e parameter, using a set method rather than specific constructors.\u003c/p\u003e\n"],["\u003cp\u003eRetry, backoff, and idempotency policies are now encapsulated as \u003ccode\u003eshared_ptr\u003c/code\u003es within \u003ccode\u003eOptions\u003c/code\u003e, and custom policy types might need to be adapted due to changes in the base policy classes.\u003c/p\u003e\n"],["\u003cp\u003eThe new policies no longer have the \u003ccode\u003eSetup(grpc::ClientContext&)\u003c/code\u003e function, and you should open a feature request to get it added if needed.\u003c/p\u003e\n"]]],[],null,["Version 2.20.0keyboard_arrow_down\n\n- [2.42.0-rc (latest)](/cpp/docs/reference/bigtable/latest/migrating-from-dataclient)\n- [2.41.0](/cpp/docs/reference/bigtable/2.41.0/migrating-from-dataclient)\n- [2.40.0](/cpp/docs/reference/bigtable/2.40.0/migrating-from-dataclient)\n- [2.39.0](/cpp/docs/reference/bigtable/2.39.0/migrating-from-dataclient)\n- [2.38.0](/cpp/docs/reference/bigtable/2.38.0/migrating-from-dataclient)\n- [2.37.0](/cpp/docs/reference/bigtable/2.37.0/migrating-from-dataclient)\n- [2.36.0](/cpp/docs/reference/bigtable/2.36.0/migrating-from-dataclient)\n- [2.35.0](/cpp/docs/reference/bigtable/2.35.0/migrating-from-dataclient)\n- [2.34.0](/cpp/docs/reference/bigtable/2.34.0/migrating-from-dataclient)\n- [2.33.0](/cpp/docs/reference/bigtable/2.33.0/migrating-from-dataclient)\n- [2.32.0](/cpp/docs/reference/bigtable/2.32.0/migrating-from-dataclient)\n- [2.31.0](/cpp/docs/reference/bigtable/2.31.0/migrating-from-dataclient)\n- [2.30.0](/cpp/docs/reference/bigtable/2.30.0/migrating-from-dataclient)\n- [2.29.0](/cpp/docs/reference/bigtable/2.29.0/migrating-from-dataclient)\n- [2.28.0](/cpp/docs/reference/bigtable/2.28.0/migrating-from-dataclient)\n- [2.27.0](/cpp/docs/reference/bigtable/2.27.0/migrating-from-dataclient)\n- [2.26.0](/cpp/docs/reference/bigtable/2.26.0/migrating-from-dataclient)\n- [2.25.1](/cpp/docs/reference/bigtable/2.25.1/migrating-from-dataclient)\n- [2.24.0](/cpp/docs/reference/bigtable/2.24.0/migrating-from-dataclient)\n- [2.23.0](/cpp/docs/reference/bigtable/2.23.0/migrating-from-dataclient)\n- [2.22.1](/cpp/docs/reference/bigtable/2.22.1/migrating-from-dataclient)\n- [2.21.0](/cpp/docs/reference/bigtable/2.21.0/migrating-from-dataclient)\n- [2.20.0](/cpp/docs/reference/bigtable/2.20.0/migrating-from-dataclient)\n- [2.19.0](/cpp/docs/reference/bigtable/2.19.0/migrating-from-dataclient)\n- [2.18.0](/cpp/docs/reference/bigtable/2.18.0/migrating-from-dataclient)\n- [2.17.0](/cpp/docs/reference/bigtable/2.17.0/migrating-from-dataclient)\n- [2.16.0](/cpp/docs/reference/bigtable/2.16.0/migrating-from-dataclient)\n- [2.15.1](/cpp/docs/reference/bigtable/2.15.1/migrating-from-dataclient)\n- [2.14.0](/cpp/docs/reference/bigtable/2.14.0/migrating-from-dataclient)\n- [2.13.0](/cpp/docs/reference/bigtable/2.13.0/migrating-from-dataclient)\n- [2.12.0](/cpp/docs/reference/bigtable/2.12.0/migrating-from-dataclient)\n- [2.11.0](/cpp/docs/reference/bigtable/2.11.0/migrating-from-dataclient) \n\nMigrating from DataClient to DataConnection\n===========================================\n\nIn this document we describe how to migrate existing code that uses `DataClient` to use `DataConnection`.\n\nAll examples use the following aliases: \n\n namespace gc = ::google::cloud;\n namespace cbt = ::google::cloud::bigtable;\n\n### Simple case\n\n cbt::Table OldCode() {\n auto data_client = cbt::MakeDataClient(\"project-id\", \"instance-id\");\n return cbt::Table(data_client, \"table-id\");\n }\n\n cbt::Table UpdatedCode() {\n auto connection = cbt::MakeDataConnection();\n return cbt::Table(\n connection, cbt::TableResource(\"project-id\", \"instance-id\", \"table-id\"));\n }\n\nNote that the `DataConnection` is not associated with any resource ids. They are instead packaged as a `TableResource` and passed as a single object to `Table`.\n\n### Optional configuration\n\nNote that there is only one `Table` constructor that accepts a `DataConnection`. All configuration is done via the `Options` parameter.\n\n#### Set an application profile id\n\n cbt::Table OldCode() {\n auto data_client = cbt::MakeDataClient(\"project-id\", \"instance-id\");\n return cbt::Table(data_client, \"app-profile-id\", \"table-id\");\n }\n\n cbt::Table UpdatedCode() {\n auto connection = cbt::MakeDataConnection();\n return cbt::Table(\n connection, cbt::TableResource(\"project-id\", \"instance-id\", \"table-id\"),\n gc::Options{}.set\u003ccbt::AppProfileIdOption\u003e(\"app-profile-id\"));\n }\n\n#### Set a custom retry policy\n\n cbt::Table OldCode() {\n auto data_client = cbt::MakeDataClient(\"project-id\", \"instance-id\");\n return cbt::Table(data_client, \"table-id\",\n cbt::LimitedErrorCountRetryPolicy(7));\n }\n\n cbt::Table UpdatedCode() {\n auto connection = cbt::MakeDataConnection();\n return cbt::Table(connection,\n cbt::TableResource(\"project-id\", \"instance-id\", \"table-id\"),\n gc::Options{}.set\u003ccbt::DataRetryPolicyOption\u003e(\n cbt::DataLimitedErrorCountRetryPolicy(7).clone()));\n }\n\nThe retry, backoff, and idempotency policies are packaged in `Options` as `shared_ptr`s, instead of passed by value as variadic parameters to `Table(..., Policies&&)`.\n\nAlso note that the retry and backoff policy types have changed. If you defined your own policy, extending `RPCRetryPolicy` or `RPCBackoffPolicy`, it will not be compatible with the new types. The new policies do not have a `Setup(grpc::ClientContext&)` function. This function has not been included because we believe that setting up the `grpc::ClientContext`...\n\n1. Should not be tied to the retry policies.\n2. Is unlikely to be needed by external customers.\n\nIf you do need a `Setup()` feature, please [open a feature request](https://github.com/googleapis/google-cloud-cpp/issues/new/choose) explaining your use case, and we will be happy to accommodate you."]]