Reads rows from the database using key lookups and scans, as a simple key/value style alternative to sessions.executeSql
. This method cannot be used to return a result set larger than 10 MiB; if the read matches more data than that, the read fails with a FAILED_PRECONDITION
error.
Reads inside read-write transactions might return ABORTED
. If this occurs, the application should restart the transaction from the beginning. See Transaction
for more details.
Larger result sets can be yielded in streaming fashion by calling sessions.streamingRead
instead.
HTTP request
POST https://spanner.googleapis.com/v1/{session=projects/*/instances/*/databases/*/sessions/*}:read
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters | |
---|---|
session |
Required. The session in which the read should be performed. Authorization requires the following IAM permission on the specified resource
|
Request body
The request body contains data with the following structure:
JSON representation |
---|
{ "transaction": { object ( |
Fields | |
---|---|
transaction |
The transaction to use. If none is provided, the default is a temporary read-only transaction with strong concurrency. |
table |
Required. The name of the table in the database to be read. |
index |
If non-empty, the name of an index on |
columns[] |
Required. The columns of |
key |
Required. If the It is not an error for the |
limit |
If greater than zero, only the first |
resume |
If this request is resuming a previously interrupted read, A base64-encoded string. |
partition |
If present, results will be restricted to the specified partition previously created using sessions.partitionRead(). There must be an exact match for the values of fields common to this message and the PartitionReadRequest message used to create this partitionToken. A base64-encoded string. |
request |
Common options for this request. |
directed |
Directed read options for this request. |
data |
If this is for a partitioned read and this field is set to If the field is set to |
Response body
If successful, the response body contains an instance of ResultSet
.
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/spanner.data
https://www.googleapis.com/auth/cloud-platform
For more information, see the Authentication Overview.