github.com/dolthub/go-mysql-server@v0.18.0/sql/planbuilder/window_frame_factory.og.go (about) 1 // Code generated by optgen; DO NOT EDIT. 2 3 package planbuilder 4 5 import ( 6 "fmt" 7 8 ast "github.com/dolthub/vitess/go/vt/sqlparser" 9 10 "github.com/dolthub/go-mysql-server/sql" 11 "github.com/dolthub/go-mysql-server/sql/plan" 12 ) 13 14 func (b *Builder) NewFrame(inScope *scope, f *ast.Frame) sql.WindowFrame { 15 if f == nil { 16 return nil 17 } 18 isRange := f.Unit == ast.RangeUnit 19 isRows := f.Unit == ast.RowsUnit 20 unboundedPreceding := b.getFrameUnboundedPreceding(inScope, f) 21 startNPreceding := b.getFrameStartNPreceding(inScope, f) 22 startCurrentRow := b.getFrameStartCurrentRow(inScope, f) 23 startNFollowing := b.getFrameStartNFollowing(inScope, f) 24 endNPreceding := b.getFrameEndNPreceding(inScope, f) 25 endCurrentRow := b.getFrameEndCurrentRow(inScope, f) 26 endNFollowing := b.getFrameEndNFollowing(inScope, f) 27 unboundedFollowing := b.getFrameUnboundedFollowing(inScope, f) 28 switch { 29 case isRows && unboundedPreceding && endNPreceding != nil: 30 return plan.NewRowsUnboundedPrecedingToNPrecedingFrame(endNPreceding) 31 case isRows && unboundedPreceding && endCurrentRow: 32 return plan.NewRowsUnboundedPrecedingToCurrentRowFrame() 33 case isRows && unboundedPreceding && endNFollowing != nil: 34 return plan.NewRowsUnboundedPrecedingToNFollowingFrame(endNFollowing) 35 case isRows && unboundedPreceding && unboundedFollowing: 36 return plan.NewRowsUnboundedPrecedingToUnboundedFollowingFrame() 37 case isRows && startNPreceding != nil && endNPreceding != nil: 38 return plan.NewRowsNPrecedingToNPrecedingFrame(startNPreceding, endNPreceding) 39 case isRows && startNPreceding != nil && endCurrentRow: 40 return plan.NewRowsNPrecedingToCurrentRowFrame(startNPreceding) 41 case isRows && startNPreceding != nil && endNFollowing != nil: 42 return plan.NewRowsNPrecedingToNFollowingFrame(startNPreceding, endNFollowing) 43 case isRows && startNPreceding != nil && unboundedFollowing: 44 return plan.NewRowsNPrecedingToUnboundedFollowingFrame(startNPreceding) 45 case isRows && startCurrentRow && endNPreceding != nil: 46 return plan.NewRowsCurrentRowToNPrecedingFrame(endNPreceding) 47 case isRows && startCurrentRow && endCurrentRow: 48 return plan.NewRowsCurrentRowToCurrentRowFrame() 49 case isRows && startCurrentRow && endNFollowing != nil: 50 return plan.NewRowsCurrentRowToNFollowingFrame(endNFollowing) 51 case isRows && startCurrentRow && unboundedFollowing: 52 return plan.NewRowsCurrentRowToUnboundedFollowingFrame() 53 case isRows && startNFollowing != nil && endNPreceding != nil: 54 return plan.NewRowsNFollowingToNPrecedingFrame(startNFollowing, endNPreceding) 55 case isRows && startNFollowing != nil && endCurrentRow: 56 return plan.NewRowsNFollowingToCurrentRowFrame(startNFollowing) 57 case isRows && startNFollowing != nil && endNFollowing != nil: 58 return plan.NewRowsNFollowingToNFollowingFrame(startNFollowing, endNFollowing) 59 case isRows && startNFollowing != nil && unboundedFollowing: 60 return plan.NewRowsNFollowingToUnboundedFollowingFrame(startNFollowing) 61 case isRange && unboundedPreceding && endNPreceding != nil: 62 return plan.NewRangeUnboundedPrecedingToNPrecedingFrame(endNPreceding) 63 case isRange && unboundedPreceding && endCurrentRow: 64 return plan.NewRangeUnboundedPrecedingToCurrentRowFrame() 65 case isRange && unboundedPreceding && endNFollowing != nil: 66 return plan.NewRangeUnboundedPrecedingToNFollowingFrame(endNFollowing) 67 case isRange && unboundedPreceding && unboundedFollowing: 68 return plan.NewRangeUnboundedPrecedingToUnboundedFollowingFrame() 69 case isRange && startNPreceding != nil && endNPreceding != nil: 70 return plan.NewRangeNPrecedingToNPrecedingFrame(startNPreceding, endNPreceding) 71 case isRange && startNPreceding != nil && endCurrentRow: 72 return plan.NewRangeNPrecedingToCurrentRowFrame(startNPreceding) 73 case isRange && startNPreceding != nil && endNFollowing != nil: 74 return plan.NewRangeNPrecedingToNFollowingFrame(startNPreceding, endNFollowing) 75 case isRange && startNPreceding != nil && unboundedFollowing: 76 return plan.NewRangeNPrecedingToUnboundedFollowingFrame(startNPreceding) 77 case isRange && startCurrentRow && endNPreceding != nil: 78 return plan.NewRangeCurrentRowToNPrecedingFrame(endNPreceding) 79 case isRange && startCurrentRow && endCurrentRow: 80 return plan.NewRangeCurrentRowToCurrentRowFrame() 81 case isRange && startCurrentRow && endNFollowing != nil: 82 return plan.NewRangeCurrentRowToNFollowingFrame(endNFollowing) 83 case isRange && startCurrentRow && unboundedFollowing: 84 return plan.NewRangeCurrentRowToUnboundedFollowingFrame() 85 case isRange && startNFollowing != nil && endNPreceding != nil: 86 return plan.NewRangeNFollowingToNPrecedingFrame(startNFollowing, endNPreceding) 87 case isRange && startNFollowing != nil && endCurrentRow: 88 return plan.NewRangeNFollowingToCurrentRowFrame(startNFollowing) 89 case isRange && startNFollowing != nil && endNFollowing != nil: 90 return plan.NewRangeNFollowingToNFollowingFrame(startNFollowing, endNFollowing) 91 case isRange && startNFollowing != nil && unboundedFollowing: 92 return plan.NewRangeNFollowingToUnboundedFollowingFrame(startNFollowing) 93 default: 94 err := fmt.Errorf("no matching constructor found for frame: %v", f) 95 b.handleErr(err) 96 return nil 97 } 98 }