Skip to content

Commit 7db3859

Browse files
committed
Revert "return EOF for materializeOutput when input length is 0"
This reverts commit d586996.
1 parent d586996 commit 7db3859

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sql/expression/function/aggregation/window_partition.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,9 @@ func (i *WindowPartitionIter) initializePartitions(ctx *sql.Context) ([]sql.Wind
233233
// At this stage, result rows are appended with the original row index for resorting. The size of
234234
// [i.output] will be smaller than [i.input] if the outer sql.Node is a plan.GroupBy with fewer partitions than rows.
235235
func (i *WindowPartitionIter) materializeOutput(ctx *sql.Context) (sql.WindowBuffer, error) {
236-
if len(i.input) == 0 {
236+
// handle nil input specially if no partition clause
237+
// ex: COUNT(*) on nil rows returns 0, not nil
238+
if len(i.input) == 0 && len(i.w.PartitionBy) > 0 {
237239
return nil, io.EOF
238240
}
239241

0 commit comments

Comments
 (0)