vitess.io/vitess@v0.16.2/go/vt/vtgate/planbuilder/operators/ops/op.go (about) 1 /* 2 Copyright 2022 The Vitess Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package ops 18 19 import ( 20 "vitess.io/vitess/go/vt/sqlparser" 21 "vitess.io/vitess/go/vt/vtgate/planbuilder/plancontext" 22 ) 23 24 type ( 25 // Operator forms the tree of operators, representing the declarative query provided. 26 // While planning, the operator tree starts with logical operators, and later moves to physical operators. 27 // The difference between the two is that when we get to a physical operator, we have made decisions on in 28 // which order to do the joins, and how to split them up across shards and keyspaces. 29 // In some situation we go straight to the physical operator - when there are no options to consider, 30 // we can go straight to the end result. 31 Operator interface { 32 Clone(inputs []Operator) Operator 33 Inputs() []Operator 34 35 // AddPredicate is used to push predicates. It pushed it as far down as is possible in the tree. 36 // If we encounter a join and the predicate depends on both sides of the join, the predicate will be split into two parts, 37 // where data is fetched from the LHS of the join to be used in the evaluation on the RHS 38 AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (Operator, error) 39 40 // AddColumn tells an operator to also output an additional column specified. 41 // The offset to the column is returned. 42 AddColumn(ctx *plancontext.PlanningContext, expr sqlparser.Expr) (int, error) 43 } 44 45 // PhysicalOperator means that this operator is ready to be turned into a logical plan 46 PhysicalOperator interface { 47 Operator 48 IPhysical() 49 } 50 )