Search code examples
google-cloud-platformprotogoogle-cloud-spanner

Represent international phone numbers in Cloud Spanner


What would be the best way to represent international phone numbers in Google Cloud Spanner? I would like it to be consistent with the protos defined here.

I am going on the fact that the phone numbers that I need to capture are of the e164_number format and I have represented the extension (as in the proto) as a STRING column. This is a potential fix, but I feel like there could be a more correct solution. Any help would be appreciated.


Solution

  • It sounds like your use case is a good fit for JSON type which Cloud Spanner now supports. You should be able to create a corresponding JSON representation for the phone_number.proto that you have linked. Please see https://cloud.google.com/spanner/docs/working-with-json for how-to as well as examples of how to query individual fields during reads.