MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / getValueByOffset

Method getValueByOffset

pkg/sql/sem/tree/window_funcs.go:84–106  ·  view source on GitHub ↗

getValueByOffset returns a datum calculated as the value of the current row in the column over which rows are ordered plus/minus logic offset, and an error if encountered. It should be used only in RANGE mode.

(
	ctx context.Context, evalCtx *EvalContext, offset Datum, negative bool,
)

Source from the content-addressed store, hash-verified

82// in the column over which rows are ordered plus/minus logic offset, and an
83// error if encountered. It should be used only in RANGE mode.
84func (wfr *WindowFrameRun) getValueByOffset(
85 ctx context.Context, evalCtx *EvalContext, offset Datum, negative bool,
86) (Datum, error) {
87 if wfr.OrdDirection == encoding.Descending {
88 // If rows are in descending order, we want to perform the "opposite"
89 // addition/subtraction to default ascending order.
90 negative = !negative
91 }
92 var binOp *BinOp
93 if negative {
94 binOp = wfr.MinusOp
95 } else {
96 binOp = wfr.PlusOp
97 }
98 value, err := wfr.valueAt(ctx, wfr.RowIdx)
99 if err != nil {
100 return nil, err
101 }
102 if value == DNull {
103 return DNull, nil
104 }
105 return binOp.Fn(evalCtx, value, offset)
106}
107
108// FrameStartIdx returns the index of starting row in the frame (which is the first to be included).
109func (wfr *WindowFrameRun) FrameStartIdx(ctx context.Context, evalCtx *EvalContext) (int, error) {

Callers 2

FrameStartIdxMethod · 0.95
FrameEndIdxMethod · 0.95

Calls 1

valueAtMethod · 0.95

Tested by

no test coverage detected