require"google/cloud/spanner"spanner=Google::Cloud::Spanner.newdb=spanner.client"my-instance","my-database"results=db.execute_query"SELECT * FROM users"results.fields.pairs.eachdo|name,type|puts"Column #{name} is type #{type}"end
Methods
#fields
deffields()->Fields
Returns the configuration object (Fields) of the names and types of
the rows in the returned data.
require"google/cloud/spanner"spanner=Google::Cloud::Spanner.newdb=spanner.client"my-instance","my-database"results=db.execute_query"SELECT * FROM users"results.fields.pairs.eachdo|name,type|puts"Column #{name} is type #{type}"end
#rows
defrows(){|row|...}
The values returned from the request.
Yields
(row) — An enumerator for the rows.
Yield Parameter
row (Data) — object that contains the data values.
Example
require"google/cloud/spanner"spanner=Google::Cloud::Spanner.newdb=spanner.client"my-instance","my-database"results=db.execute_query"SELECT * FROM users"results.rows.eachdo|row|puts"User #{row[:id]} is #{row[:name]}"end
#timestamp
deftimestamp()->Time
The read timestamp chosen for single-use snapshots (read-only
transactions).
[[["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 API - Class Google::Cloud::Spanner::Results (v2.27.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.27.0 (latest)](/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Results)\n- [2.26.0](/ruby/docs/reference/google-cloud-spanner/2.26.0/Google-Cloud-Spanner-Results)\n- [2.25.0](/ruby/docs/reference/google-cloud-spanner/2.25.0/Google-Cloud-Spanner-Results)\n- [2.24.0](/ruby/docs/reference/google-cloud-spanner/2.24.0/Google-Cloud-Spanner-Results)\n- [2.23.0](/ruby/docs/reference/google-cloud-spanner/2.23.0/Google-Cloud-Spanner-Results)\n- [2.22.0](/ruby/docs/reference/google-cloud-spanner/2.22.0/Google-Cloud-Spanner-Results)\n- [2.21.0](/ruby/docs/reference/google-cloud-spanner/2.21.0/Google-Cloud-Spanner-Results)\n- [2.20.0](/ruby/docs/reference/google-cloud-spanner/2.20.0/Google-Cloud-Spanner-Results)\n- [2.19.1](/ruby/docs/reference/google-cloud-spanner/2.19.1/Google-Cloud-Spanner-Results)\n- [2.18.1](/ruby/docs/reference/google-cloud-spanner/2.18.1/Google-Cloud-Spanner-Results)\n- [2.17.0](/ruby/docs/reference/google-cloud-spanner/2.17.0/Google-Cloud-Spanner-Results)\n- [2.16.1](/ruby/docs/reference/google-cloud-spanner/2.16.1/Google-Cloud-Spanner-Results)\n- [2.15.0](/ruby/docs/reference/google-cloud-spanner/2.15.0/Google-Cloud-Spanner-Results)\n- [2.14.0](/ruby/docs/reference/google-cloud-spanner/2.14.0/Google-Cloud-Spanner-Results)\n- [2.13.0](/ruby/docs/reference/google-cloud-spanner/2.13.0/Google-Cloud-Spanner-Results)\n- [2.12.1](/ruby/docs/reference/google-cloud-spanner/2.12.1/Google-Cloud-Spanner-Results)\n- [2.11.0](/ruby/docs/reference/google-cloud-spanner/2.11.0/Google-Cloud-Spanner-Results) \nReference documentation and code samples for the Cloud Spanner API class Google::Cloud::Spanner::Results.\n\nResults\n-------\n\nRepresents the result set from an operation returning data.\n\nSee [Client#execute_query](/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Client#Google__Cloud__Spanner__Client_execute_query_instance_ \"Google::Cloud::Spanner::Client#execute_query (method)\") and\n[Client#read](/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Client#Google__Cloud__Spanner__Client_read_instance_ \"Google::Cloud::Spanner::Client#read (method)\"). \n\nInherits\n--------\n\n- Object\n\nExample\n-------\n\n```ruby\nrequire \"google/cloud/spanner\"\n\nspanner = Google::Cloud::Spanner.new\n\ndb = spanner.client \"my-instance\", \"my-database\"\n\nresults = db.execute_query \"SELECT * FROM users\"\n\nresults.fields.pairs.each do |name, type|\n puts \"Column #{name} is type #{type}\"\nend\n```\n\nMethods\n-------\n\n### #fields\n\n def fields() -\u003e Fields\n\nReturns the configuration object ([Fields](/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Fields \"Google::Cloud::Spanner::Fields (class)\")) of the names and types of\nthe rows in the returned data. \n**Returns**\n\n- ([Fields](./Google-Cloud-Spanner-Fields)) --- The fields of the returned data.\n**Example** \n\n```ruby\nrequire \"google/cloud/spanner\"\n\nspanner = Google::Cloud::Spanner.new\n\ndb = spanner.client \"my-instance\", \"my-database\"\n\nresults = db.execute_query \"SELECT * FROM users\"\n\nresults.fields.pairs.each do |name, type|\n puts \"Column #{name} is type #{type}\"\nend\n```\n\n### #rows\n\n def rows() { |row| ... }\n\nThe values returned from the request. \n**Yields**\n\n- (row) --- An enumerator for the rows. \n**Yield Parameter**\n\n- **row** ([Data](./Google-Cloud-Spanner-Data)) --- object that contains the data values.\n**Example** \n\n```ruby\nrequire \"google/cloud/spanner\"\n\nspanner = Google::Cloud::Spanner.new\n\ndb = spanner.client \"my-instance\", \"my-database\"\n\nresults = db.execute_query \"SELECT * FROM users\"\n\nresults.rows.each do |row|\n puts \"User #{row[:id]} is #{row[:name]}\"\nend\n```\n\n### #timestamp\n\n def timestamp() -\u003e Time\n\nThe read timestamp chosen for single-use snapshots (read-only\ntransactions). \n**Returns**\n\n- (Time) --- The chosen timestamp."]]