Creates a set of partition tokens that can be used to execute a query operation in parallel. Each of the returned partition tokens can be used by sessions.executeStreamingSql
to specify a subset of the query result to read. The same session and read-only transaction must be used by the PartitionQueryRequest used to create the partition tokens and the ExecuteSqlRequests that use the partition tokens.
Partition tokens become invalid when the session used to create them is deleted, is idle for too long, begins a new transaction, or becomes too old. When any of these happen, it is not possible to resume the query, and the whole operation must be restarted from the beginning.
HTTP request
POST https://spanner.googleapis.com/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionQuery
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters | |
---|---|
session |
Required. The session used to create the partitions. 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 |
sessions.read only snapshot transactions are supported, read/write and single use transactions are not. |
sql |
Required. The query request to generate partitions for. The request fails if the query is not root partitionable. For a query to be root partitionable, it needs to satisfy a few conditions. For example, if the query execution plan contains a distributed union operator, then it must be the first operator in the plan. For more information about other conditions, see sessions.read data in parallel. The query request must not contain DML commands, such as |
params |
Parameter names and values that bind to placeholders in the SQL string. A parameter placeholder consists of the Parameters can appear anywhere that a literal value is expected. The same parameter name can be used more than once, for example:
It is an error to execute a SQL statement with unbound parameters. |
param |
It is not always possible for Cloud Spanner to infer the right SQL type from a JSON value. For example, values of type In these cases, |
partition |
Additional options that affect how many partitions are created. |
Response body
If successful, the response body contains an instance of PartitionResponse
.
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.