Cloud Spanner does not offer a NUMERIC
type or a DECIMAL
type.
One workaround is to store your quantities in an INT64
column, and store them in the finest-granularity unit with which you will ever work. For example, if you are dealing with US Dollars, you could store the quantities in cents ($0.01). So $7.13 would be presented as 713 cents in your column. For some applications, you might want even finer granularity (e.g. micro-dollars) in order to minimize rounding issues.
There are other workarounds possible. For example, you could somehow serialize your numeric values to a string and store these in a STRING
or BYTES
column. Naively, just storing "7.13"
could work, but there are of course more complex representations possible (e.g. a JSON object like "{'dollars': 7, 'cents': 13'}"
).