Skip to content

Commit 8bc512c

Browse files
authored
pkg/executor,tests: reset params in the PipelineWindow.Open (#54709) (#55319)
close #53600
1 parent b51e9e7 commit 8bc512c

File tree

4 files changed

+1104
-16
lines changed

4 files changed

+1104
-16
lines changed

executor/builder.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -4895,10 +4895,15 @@ func (b *executorBuilder) buildWindow(v *plannercore.PhysicalWindow) Executor {
48954895
baseExecutor: base,
48964896
groupChecker: newVecGroupChecker(b.ctx, groupByItems),
48974897
numWindowFuncs: len(v.WindowFuncDescs),
4898+
windowFuncs: windowFuncs,
4899+
partialResults: partialResults,
4900+
}
4901+
exec.slidingWindowFuncs = make([]aggfuncs.SlidingWindowAggFunc, len(exec.windowFuncs))
4902+
for i, windowFunc := range exec.windowFuncs {
4903+
if slidingWindowAggFunc, ok := windowFunc.(aggfuncs.SlidingWindowAggFunc); ok {
4904+
exec.slidingWindowFuncs[i] = slidingWindowAggFunc
4905+
}
48984906
}
4899-
4900-
exec.windowFuncs = windowFuncs
4901-
exec.partialResults = partialResults
49024907
if v.Frame == nil {
49034908
exec.start = &plannercore.FrameBound{
49044909
Type: ast.Preceding,

executor/pipelined_window.go

+4-13
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,10 @@ func (e *PipelinedWindowExec) Close() error {
8383

8484
// Open implements the Executor Open interface
8585
func (e *PipelinedWindowExec) Open(ctx context.Context) (err error) {
86-
e.rowToConsume = 0
87-
e.done = false
88-
e.accumulated = 0
89-
e.dropped = 0
90-
e.data = make([]dataInfo, 0)
91-
e.dataIdx = 0
92-
e.slidingWindowFuncs = make([]aggfuncs.SlidingWindowAggFunc, len(e.windowFuncs))
93-
for i, windowFunc := range e.windowFuncs {
94-
if slidingWindowAggFunc, ok := windowFunc.(aggfuncs.SlidingWindowAggFunc); ok {
95-
e.slidingWindowFuncs[i] = slidingWindowAggFunc
96-
}
97-
}
98-
e.rows = make([]chunk.Row, 0)
86+
e.done, e.newPartition, e.whole, e.initializedSlidingWindow = false, false, false, false
87+
e.dataIdx, e.curRowIdx, e.dropped, e.rowToConsume, e.accumulated = 0, 0, 0, 0, 0
88+
e.lastStartRow, e.lastEndRow, e.stagedStartRow, e.stagedEndRow, e.rowStart, e.rowCnt = 0, 0, 0, 0, 0, 0
89+
e.rows, e.data = make([]chunk.Row, 0), make([]dataInfo, 0)
9990
return e.baseExecutor.Open(ctx)
10091
}
10192

0 commit comments

Comments
 (0)