|
| 1 | +/* |
| 2 | +Copyright 2025 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 operators |
| 18 | + |
| 19 | +import ( |
| 20 | + "vitess.io/vitess/go/vt/sqlparser" |
| 21 | + "vitess.io/vitess/go/vt/vtgate/planbuilder/plancontext" |
| 22 | +) |
| 23 | + |
| 24 | +type Window struct { |
| 25 | + unaryOperator |
| 26 | + QP *QueryProjection |
| 27 | +} |
| 28 | + |
| 29 | +func newWindow(source Operator, qp *QueryProjection) *Window { |
| 30 | + return &Window{ |
| 31 | + unaryOperator: newUnaryOp(source), |
| 32 | + QP: qp, |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +func (w *Window) Clone(inputs []Operator) Operator { |
| 37 | + return newWindow(inputs[0], w.QP) |
| 38 | +} |
| 39 | + |
| 40 | +func (w *Window) AddPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr) Operator { |
| 41 | + w.Source = w.Source.AddPredicate(ctx, expr) |
| 42 | + return w |
| 43 | +} |
| 44 | + |
| 45 | +func (w *Window) AddColumn(ctx *plancontext.PlanningContext, reuseExisting bool, addToGroupBy bool, expr *sqlparser.AliasedExpr) int { |
| 46 | + return w.Source.AddColumn(ctx, reuseExisting, addToGroupBy, expr) |
| 47 | +} |
| 48 | + |
| 49 | +func (w *Window) AddWSColumn(ctx *plancontext.PlanningContext, offset int, underRoute bool) int { |
| 50 | + return w.Source.AddWSColumn(ctx, offset, underRoute) |
| 51 | +} |
| 52 | + |
| 53 | +func (w *Window) FindCol(ctx *plancontext.PlanningContext, expr sqlparser.Expr, underRoute bool) int { |
| 54 | + return w.Source.FindCol(ctx, expr, underRoute) |
| 55 | +} |
| 56 | + |
| 57 | +func (w *Window) GetColumns(ctx *plancontext.PlanningContext) []*sqlparser.AliasedExpr { |
| 58 | + return w.Source.GetColumns(ctx) |
| 59 | +} |
| 60 | + |
| 61 | +func (w *Window) GetSelectExprs(ctx *plancontext.PlanningContext) []sqlparser.SelectExpr { |
| 62 | + return w.Source.GetSelectExprs(ctx) |
| 63 | +} |
| 64 | + |
| 65 | +func (w *Window) ShortDescription() string { |
| 66 | + return "Window" |
| 67 | +} |
| 68 | + |
| 69 | +func (w *Window) GetOrdering(ctx *plancontext.PlanningContext) []OrderBy { |
| 70 | + return w.Source.GetOrdering(ctx) |
| 71 | +} |
0 commit comments