Skip to content

Commit

Permalink
executor: fix wrong logic of pipelined window function (#26974)
Browse files Browse the repository at this point in the history
  • Loading branch information
ichn-hu authored Aug 11, 2021
1 parent f570e8f commit 1c90b8e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion executor/pipelined_window.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ func (e *PipelinedWindowExec) Open(ctx context.Context) (err error) {
}

func (e *PipelinedWindowExec) firstResultChunkNotReady() bool {
if !e.done && len(e.data) == 0 {
return true
}
// chunk can't be ready unless, 1. all of the rows in the chunk is filled, 2. e.rows doesn't contain rows in the chunk
return len(e.data) > 0 && (e.data[0].remaining != 0 || e.data[0].accumulated > e.dropped)
}
Expand All @@ -107,7 +110,7 @@ func (e *PipelinedWindowExec) firstResultChunkNotReady() bool {
func (e *PipelinedWindowExec) Next(ctx context.Context, chk *chunk.Chunk) (err error) {
chk.Reset()

for !e.done || e.firstResultChunkNotReady() {
for e.firstResultChunkNotReady() {
// we firstly gathering enough rows and consume them, until we are able to produce.
// for unbounded frame, it needs consume the whole partition before being able to produce, in this case
// e.p.enoughToProduce will be false until so.
Expand Down

0 comments on commit 1c90b8e

Please sign in to comment.