Reference documentation and code samples for the Cloud Spanner V1 API module Google::Cloud::Spanner::V1::TypeCode.
TypeCode is used as part of Type to
indicate the type of a Cloud Spanner value.
Each legal value of a type can be encoded to or decoded from a JSON
value, using the encodings described below. All Cloud Spanner values can
be null, regardless of type; nulls are always encoded as a JSON
null.
Constants
TYPE_CODE_UNSPECIFIED
value: 0 Not specified.
BOOL
value: 1 Encoded as JSON true or false.
INT64
value: 2 Encoded as string, in decimal format.
FLOAT64
value: 3 Encoded as number, or the strings "NaN", "Infinity", or
"-Infinity".
FLOAT32
value: 15 Encoded as number, or the strings "NaN", "Infinity", or
"-Infinity".
TIMESTAMP
value: 4 Encoded as string in RFC 3339 timestamp format. The time zone
must be present, and must be "Z".
If the schema has the column option
allow_commit_timestamp=true, the placeholder string
"spanner.commit_timestamp()" can be used to instruct the system
to insert the commit timestamp associated with the transaction
commit.
DATE
value: 5 Encoded as string in RFC 3339 date format.
STRING
value: 6 Encoded as string.
BYTES
value: 7 Encoded as a base64-encoded string, as described in RFC 4648,
section 4.
ARRAY
value: 8 Encoded as list, where the list elements are represented
according to
array_element_type.
STRUCT
value: 9 Encoded as list, where list element i is represented according
to [struct_type.fields[i]][google.spanner.v1.StructType.fields].
NUMERIC
value: 10 Encoded as string, in decimal format or scientific notation format.
Decimal format:
[+-]Digits[.[Digits]] or
[+-][Digits].Digits
Scientific notation:
[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits] or
[+-][Digits].Digits[ExponentIndicator[+-]Digits]
(ExponentIndicator is "e" or "E")
JSON
value: 11
Encoded as a JSON-formatted string as described in RFC 7159. The
following rules are applied when parsing JSON input:
Whitespace characters are not preserved.
If a JSON object has duplicate keys, only the first key is preserved.
Members of a JSON object are not guaranteed to have their order
preserved.
JSON array elements will have their order preserved.
PROTO
value: 13 Encoded as a base64-encoded string, as described in RFC 4648,
section 4.
ENUM
value: 14 Encoded as string, in decimal format.
INTERVAL
value: 16 Encoded as string, in ISO8601 duration format -
P[n]Y[n]M[n]DT[n]H[n]M[n[.fraction]]S
where n is an integer.
For example, P1Y2M3DT4H5M6.5S represents time duration of 1 year, 2
months, 3 days, 4 hours, 5 minutes, and 6.5 seconds.
UUID
value: 17 Encoded as string, in lower-case hexa-decimal format, as described
in RFC 9562, section 4.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Cloud Spanner V1 API - Module Google::Cloud::Spanner::V1::TypeCode (v1.10.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.10.0 (latest)](/ruby/docs/reference/google-cloud-spanner-v1/latest/Google-Cloud-Spanner-V1-TypeCode)\n- [1.9.1](/ruby/docs/reference/google-cloud-spanner-v1/1.9.1/Google-Cloud-Spanner-V1-TypeCode)\n- [1.8.0](/ruby/docs/reference/google-cloud-spanner-v1/1.8.0/Google-Cloud-Spanner-V1-TypeCode)\n- [1.7.1](/ruby/docs/reference/google-cloud-spanner-v1/1.7.1/Google-Cloud-Spanner-V1-TypeCode)\n- [1.6.0](/ruby/docs/reference/google-cloud-spanner-v1/1.6.0/Google-Cloud-Spanner-V1-TypeCode)\n- [1.5.0](/ruby/docs/reference/google-cloud-spanner-v1/1.5.0/Google-Cloud-Spanner-V1-TypeCode)\n- [1.4.0](/ruby/docs/reference/google-cloud-spanner-v1/1.4.0/Google-Cloud-Spanner-V1-TypeCode)\n- [1.3.0](/ruby/docs/reference/google-cloud-spanner-v1/1.3.0/Google-Cloud-Spanner-V1-TypeCode)\n- [1.2.0](/ruby/docs/reference/google-cloud-spanner-v1/1.2.0/Google-Cloud-Spanner-V1-TypeCode)\n- [1.1.0](/ruby/docs/reference/google-cloud-spanner-v1/1.1.0/Google-Cloud-Spanner-V1-TypeCode)\n- [1.0.2](/ruby/docs/reference/google-cloud-spanner-v1/1.0.2/Google-Cloud-Spanner-V1-TypeCode)\n- [0.27.0](/ruby/docs/reference/google-cloud-spanner-v1/0.27.0/Google-Cloud-Spanner-V1-TypeCode)\n- [0.26.0](/ruby/docs/reference/google-cloud-spanner-v1/0.26.0/Google-Cloud-Spanner-V1-TypeCode)\n- [0.25.0](/ruby/docs/reference/google-cloud-spanner-v1/0.25.0/Google-Cloud-Spanner-V1-TypeCode)\n- [0.24.0](/ruby/docs/reference/google-cloud-spanner-v1/0.24.0/Google-Cloud-Spanner-V1-TypeCode)\n- [0.23.0](/ruby/docs/reference/google-cloud-spanner-v1/0.23.0/Google-Cloud-Spanner-V1-TypeCode)\n- [0.22.2](/ruby/docs/reference/google-cloud-spanner-v1/0.22.2/Google-Cloud-Spanner-V1-TypeCode)\n- [0.21.0](/ruby/docs/reference/google-cloud-spanner-v1/0.21.0/Google-Cloud-Spanner-V1-TypeCode)\n- [0.20.1](/ruby/docs/reference/google-cloud-spanner-v1/0.20.1/Google-Cloud-Spanner-V1-TypeCode)\n- [0.19.0](/ruby/docs/reference/google-cloud-spanner-v1/0.19.0/Google-Cloud-Spanner-V1-TypeCode)\n- [0.18.0](/ruby/docs/reference/google-cloud-spanner-v1/0.18.0/Google-Cloud-Spanner-V1-TypeCode)\n- [0.17.0](/ruby/docs/reference/google-cloud-spanner-v1/0.17.0/Google-Cloud-Spanner-V1-TypeCode)\n- [0.16.0](/ruby/docs/reference/google-cloud-spanner-v1/0.16.0/Google-Cloud-Spanner-V1-TypeCode)\n- [0.15.1](/ruby/docs/reference/google-cloud-spanner-v1/0.15.1/Google-Cloud-Spanner-V1-TypeCode)\n- [0.14.1](/ruby/docs/reference/google-cloud-spanner-v1/0.14.1/Google-Cloud-Spanner-V1-TypeCode)\n- [0.13.0](/ruby/docs/reference/google-cloud-spanner-v1/0.13.0/Google-Cloud-Spanner-V1-TypeCode)\n- [0.12.0](/ruby/docs/reference/google-cloud-spanner-v1/0.12.0/Google-Cloud-Spanner-V1-TypeCode)\n- [0.11.0](/ruby/docs/reference/google-cloud-spanner-v1/0.11.0/Google-Cloud-Spanner-V1-TypeCode)\n- [0.10.0](/ruby/docs/reference/google-cloud-spanner-v1/0.10.0/Google-Cloud-Spanner-V1-TypeCode)\n- [0.9.0](/ruby/docs/reference/google-cloud-spanner-v1/0.9.0/Google-Cloud-Spanner-V1-TypeCode)\n- [0.8.1](/ruby/docs/reference/google-cloud-spanner-v1/0.8.1/Google-Cloud-Spanner-V1-TypeCode)\n- [0.7.4](/ruby/docs/reference/google-cloud-spanner-v1/0.7.4/Google-Cloud-Spanner-V1-TypeCode) \nReference documentation and code samples for the Cloud Spanner V1 API module Google::Cloud::Spanner::V1::TypeCode.\n\n`TypeCode` is used as part of [Type](/ruby/docs/reference/google-cloud-spanner-v1/latest/Google-Cloud-Spanner-V1-Type \"Google::Cloud::Spanner::V1::Type (class)\") to\nindicate the type of a Cloud Spanner value.\n\n\n\u003cbr /\u003e\n\nEach legal value of a type can be encoded to or decoded from a JSON\nvalue, using the encodings described below. All Cloud Spanner values can\nbe `null`, regardless of type; `null`s are always encoded as a JSON\n`null`.\n\nConstants\n---------\n\n### TYPE_CODE_UNSPECIFIED\n\n**value:** 0 \nNot specified.\n\n### BOOL\n\n**value:** 1 \nEncoded as JSON `true` or `false`.\n\n### INT64\n\n**value:** 2 \nEncoded as `string`, in decimal format.\n\n### FLOAT64\n\n**value:** 3 \nEncoded as `number`, or the strings `\"NaN\"`, `\"Infinity\"`, or\n`\"-Infinity\"`.\n\n### FLOAT32\n\n**value:** 15 \nEncoded as `number`, or the strings `\"NaN\"`, `\"Infinity\"`, or\n`\"-Infinity\"`.\n\n### TIMESTAMP\n\n**value:** 4 \nEncoded as `string` in RFC 3339 timestamp format. The time zone\nmust be present, and must be `\"Z\"`.\n\n\n\u003cbr /\u003e\n\nIf the schema has the column option\n`allow_commit_timestamp=true`, the placeholder string\n`\"spanner.commit_timestamp()\"` can be used to instruct the system\nto insert the commit timestamp associated with the transaction\ncommit.\n\n### DATE\n\n**value:** 5 \nEncoded as `string` in RFC 3339 date format.\n\n### STRING\n\n**value:** 6 \nEncoded as `string`.\n\n### BYTES\n\n**value:** 7 \nEncoded as a base64-encoded `string`, as described in RFC 4648,\nsection 4.\n\n### ARRAY\n\n**value:** 8 \nEncoded as `list`, where the list elements are represented\naccording to\n[array_element_type](/ruby/docs/reference/google-cloud-spanner-v1/latest/Google-Cloud-Spanner-V1-Type#Google__Cloud__Spanner__V1__Type_array_element_type_instance_ \"Google::Cloud::Spanner::V1::Type#array_element_type (method)\").\n\n### STRUCT\n\n**value:** 9 \nEncoded as `list`, where list element `i` is represented according\nto \\[struct_type.fields\\[i\\]\\]\\[google.spanner.v1.StructType.fields\\].\n\n### NUMERIC\n\n**value:** 10 \nEncoded as `string`, in decimal format or scientific notation format.\nDecimal format:\n`[+-]Digits[.[Digits]]` or\n`[+-][Digits].Digits`\n\n\n\u003cbr /\u003e\n\nScientific notation:\n`[+-]Digits[.[Digits]][ExponentIndicator[+-]Digits]` or\n`[+-][Digits].Digits[ExponentIndicator[+-]Digits]`\n(ExponentIndicator is `\"e\"` or `\"E\"`)\n\n### JSON\n\n**value:** 11 \n\nEncoded as a JSON-formatted `string` as described in RFC 7159. The\nfollowing rules are applied when parsing JSON input:\n\n\u003cbr /\u003e\n\n- Whitespace characters are not preserved.\n- If a JSON object has duplicate keys, only the first key is preserved.\n- Members of a JSON object are not guaranteed to have their order preserved.\n- JSON array elements will have their order preserved.\n\n### PROTO\n\n**value:** 13 \nEncoded as a base64-encoded `string`, as described in RFC 4648,\nsection 4.\n\n### ENUM\n\n**value:** 14 \nEncoded as `string`, in decimal format.\n\n### INTERVAL\n\n**value:** 16 \nEncoded as `string`, in `ISO8601` duration format -\n`P[n]Y[n]M[n]DT[n]H[n]M[n[.fraction]]S`\nwhere `n` is an integer.\nFor example, `P1Y2M3DT4H5M6.5S` represents time duration of 1 year, 2\nmonths, 3 days, 4 hours, 5 minutes, and 6.5 seconds.\n\n### UUID\n\n**value:** 17 \nEncoded as `string`, in lower-case hexa-decimal format, as described\nin RFC 9562, section 4."]]