1*d5c09012SAndroid Build Coastguard Worker// Copyright 2022 Google LLC 2*d5c09012SAndroid Build Coastguard Worker// 3*d5c09012SAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License"); 4*d5c09012SAndroid Build Coastguard Worker// you may not use this file except in compliance with the License. 5*d5c09012SAndroid Build Coastguard Worker// You may obtain a copy of the License at 6*d5c09012SAndroid Build Coastguard Worker// 7*d5c09012SAndroid Build Coastguard Worker// http://www.apache.org/licenses/LICENSE-2.0 8*d5c09012SAndroid Build Coastguard Worker// 9*d5c09012SAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software 10*d5c09012SAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS, 11*d5c09012SAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*d5c09012SAndroid Build Coastguard Worker// See the License for the specific language governing permissions and 13*d5c09012SAndroid Build Coastguard Worker// limitations under the License. 14*d5c09012SAndroid Build Coastguard Worker 15*d5c09012SAndroid Build Coastguard Workersyntax = "proto3"; 16*d5c09012SAndroid Build Coastguard Worker 17*d5c09012SAndroid Build Coastguard Workerpackage google.spanner.v1; 18*d5c09012SAndroid Build Coastguard Worker 19*d5c09012SAndroid Build Coastguard Workerimport "google/protobuf/struct.proto"; 20*d5c09012SAndroid Build Coastguard Worker 21*d5c09012SAndroid Build Coastguard Workeroption csharp_namespace = "Google.Cloud.Spanner.V1"; 22*d5c09012SAndroid Build Coastguard Workeroption go_package = "cloud.google.com/go/spanner/apiv1/spannerpb;spannerpb"; 23*d5c09012SAndroid Build Coastguard Workeroption java_multiple_files = true; 24*d5c09012SAndroid Build Coastguard Workeroption java_outer_classname = "QueryPlanProto"; 25*d5c09012SAndroid Build Coastguard Workeroption java_package = "com.google.spanner.v1"; 26*d5c09012SAndroid Build Coastguard Workeroption php_namespace = "Google\\Cloud\\Spanner\\V1"; 27*d5c09012SAndroid Build Coastguard Workeroption ruby_package = "Google::Cloud::Spanner::V1"; 28*d5c09012SAndroid Build Coastguard Worker 29*d5c09012SAndroid Build Coastguard Worker// Node information for nodes appearing in a [QueryPlan.plan_nodes][google.spanner.v1.QueryPlan.plan_nodes]. 30*d5c09012SAndroid Build Coastguard Workermessage PlanNode { 31*d5c09012SAndroid Build Coastguard Worker // The kind of [PlanNode][google.spanner.v1.PlanNode]. Distinguishes between the two different kinds of 32*d5c09012SAndroid Build Coastguard Worker // nodes that can appear in a query plan. 33*d5c09012SAndroid Build Coastguard Worker enum Kind { 34*d5c09012SAndroid Build Coastguard Worker // Not specified. 35*d5c09012SAndroid Build Coastguard Worker KIND_UNSPECIFIED = 0; 36*d5c09012SAndroid Build Coastguard Worker 37*d5c09012SAndroid Build Coastguard Worker // Denotes a Relational operator node in the expression tree. Relational 38*d5c09012SAndroid Build Coastguard Worker // operators represent iterative processing of rows during query execution. 39*d5c09012SAndroid Build Coastguard Worker // For example, a `TableScan` operation that reads rows from a table. 40*d5c09012SAndroid Build Coastguard Worker RELATIONAL = 1; 41*d5c09012SAndroid Build Coastguard Worker 42*d5c09012SAndroid Build Coastguard Worker // Denotes a Scalar node in the expression tree. Scalar nodes represent 43*d5c09012SAndroid Build Coastguard Worker // non-iterable entities in the query plan. For example, constants or 44*d5c09012SAndroid Build Coastguard Worker // arithmetic operators appearing inside predicate expressions or references 45*d5c09012SAndroid Build Coastguard Worker // to column names. 46*d5c09012SAndroid Build Coastguard Worker SCALAR = 2; 47*d5c09012SAndroid Build Coastguard Worker } 48*d5c09012SAndroid Build Coastguard Worker 49*d5c09012SAndroid Build Coastguard Worker // Metadata associated with a parent-child relationship appearing in a 50*d5c09012SAndroid Build Coastguard Worker // [PlanNode][google.spanner.v1.PlanNode]. 51*d5c09012SAndroid Build Coastguard Worker message ChildLink { 52*d5c09012SAndroid Build Coastguard Worker // The node to which the link points. 53*d5c09012SAndroid Build Coastguard Worker int32 child_index = 1; 54*d5c09012SAndroid Build Coastguard Worker 55*d5c09012SAndroid Build Coastguard Worker // The type of the link. For example, in Hash Joins this could be used to 56*d5c09012SAndroid Build Coastguard Worker // distinguish between the build child and the probe child, or in the case 57*d5c09012SAndroid Build Coastguard Worker // of the child being an output variable, to represent the tag associated 58*d5c09012SAndroid Build Coastguard Worker // with the output variable. 59*d5c09012SAndroid Build Coastguard Worker string type = 2; 60*d5c09012SAndroid Build Coastguard Worker 61*d5c09012SAndroid Build Coastguard Worker // Only present if the child node is [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] and corresponds 62*d5c09012SAndroid Build Coastguard Worker // to an output variable of the parent node. The field carries the name of 63*d5c09012SAndroid Build Coastguard Worker // the output variable. 64*d5c09012SAndroid Build Coastguard Worker // For example, a `TableScan` operator that reads rows from a table will 65*d5c09012SAndroid Build Coastguard Worker // have child links to the `SCALAR` nodes representing the output variables 66*d5c09012SAndroid Build Coastguard Worker // created for each column that is read by the operator. The corresponding 67*d5c09012SAndroid Build Coastguard Worker // `variable` fields will be set to the variable names assigned to the 68*d5c09012SAndroid Build Coastguard Worker // columns. 69*d5c09012SAndroid Build Coastguard Worker string variable = 3; 70*d5c09012SAndroid Build Coastguard Worker } 71*d5c09012SAndroid Build Coastguard Worker 72*d5c09012SAndroid Build Coastguard Worker // Condensed representation of a node and its subtree. Only present for 73*d5c09012SAndroid Build Coastguard Worker // `SCALAR` [PlanNode(s)][google.spanner.v1.PlanNode]. 74*d5c09012SAndroid Build Coastguard Worker message ShortRepresentation { 75*d5c09012SAndroid Build Coastguard Worker // A string representation of the expression subtree rooted at this node. 76*d5c09012SAndroid Build Coastguard Worker string description = 1; 77*d5c09012SAndroid Build Coastguard Worker 78*d5c09012SAndroid Build Coastguard Worker // A mapping of (subquery variable name) -> (subquery node id) for cases 79*d5c09012SAndroid Build Coastguard Worker // where the `description` string of this node references a `SCALAR` 80*d5c09012SAndroid Build Coastguard Worker // subquery contained in the expression subtree rooted at this node. The 81*d5c09012SAndroid Build Coastguard Worker // referenced `SCALAR` subquery may not necessarily be a direct child of 82*d5c09012SAndroid Build Coastguard Worker // this node. 83*d5c09012SAndroid Build Coastguard Worker map<string, int32> subqueries = 2; 84*d5c09012SAndroid Build Coastguard Worker } 85*d5c09012SAndroid Build Coastguard Worker 86*d5c09012SAndroid Build Coastguard Worker // The `PlanNode`'s index in [node list][google.spanner.v1.QueryPlan.plan_nodes]. 87*d5c09012SAndroid Build Coastguard Worker int32 index = 1; 88*d5c09012SAndroid Build Coastguard Worker 89*d5c09012SAndroid Build Coastguard Worker // Used to determine the type of node. May be needed for visualizing 90*d5c09012SAndroid Build Coastguard Worker // different kinds of nodes differently. For example, If the node is a 91*d5c09012SAndroid Build Coastguard Worker // [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] node, it will have a condensed representation 92*d5c09012SAndroid Build Coastguard Worker // which can be used to directly embed a description of the node in its 93*d5c09012SAndroid Build Coastguard Worker // parent. 94*d5c09012SAndroid Build Coastguard Worker Kind kind = 2; 95*d5c09012SAndroid Build Coastguard Worker 96*d5c09012SAndroid Build Coastguard Worker // The display name for the node. 97*d5c09012SAndroid Build Coastguard Worker string display_name = 3; 98*d5c09012SAndroid Build Coastguard Worker 99*d5c09012SAndroid Build Coastguard Worker // List of child node `index`es and their relationship to this parent. 100*d5c09012SAndroid Build Coastguard Worker repeated ChildLink child_links = 4; 101*d5c09012SAndroid Build Coastguard Worker 102*d5c09012SAndroid Build Coastguard Worker // Condensed representation for [SCALAR][google.spanner.v1.PlanNode.Kind.SCALAR] nodes. 103*d5c09012SAndroid Build Coastguard Worker ShortRepresentation short_representation = 5; 104*d5c09012SAndroid Build Coastguard Worker 105*d5c09012SAndroid Build Coastguard Worker // Attributes relevant to the node contained in a group of key-value pairs. 106*d5c09012SAndroid Build Coastguard Worker // For example, a Parameter Reference node could have the following 107*d5c09012SAndroid Build Coastguard Worker // information in its metadata: 108*d5c09012SAndroid Build Coastguard Worker // 109*d5c09012SAndroid Build Coastguard Worker // { 110*d5c09012SAndroid Build Coastguard Worker // "parameter_reference": "param1", 111*d5c09012SAndroid Build Coastguard Worker // "parameter_type": "array" 112*d5c09012SAndroid Build Coastguard Worker // } 113*d5c09012SAndroid Build Coastguard Worker google.protobuf.Struct metadata = 6; 114*d5c09012SAndroid Build Coastguard Worker 115*d5c09012SAndroid Build Coastguard Worker // The execution statistics associated with the node, contained in a group of 116*d5c09012SAndroid Build Coastguard Worker // key-value pairs. Only present if the plan was returned as a result of a 117*d5c09012SAndroid Build Coastguard Worker // profile query. For example, number of executions, number of rows/time per 118*d5c09012SAndroid Build Coastguard Worker // execution etc. 119*d5c09012SAndroid Build Coastguard Worker google.protobuf.Struct execution_stats = 7; 120*d5c09012SAndroid Build Coastguard Worker} 121*d5c09012SAndroid Build Coastguard Worker 122*d5c09012SAndroid Build Coastguard Worker// Contains an ordered list of nodes appearing in the query plan. 123*d5c09012SAndroid Build Coastguard Workermessage QueryPlan { 124*d5c09012SAndroid Build Coastguard Worker // The nodes in the query plan. Plan nodes are returned in pre-order starting 125*d5c09012SAndroid Build Coastguard Worker // with the plan root. Each [PlanNode][google.spanner.v1.PlanNode]'s `id` corresponds to its index in 126*d5c09012SAndroid Build Coastguard Worker // `plan_nodes`. 127*d5c09012SAndroid Build Coastguard Worker repeated PlanNode plan_nodes = 1; 128*d5c09012SAndroid Build Coastguard Worker} 129