Skip to content

Commit 586602d

Browse files
angelamayxieJames Cor
authored andcommitted
Revert "return EOF for materializeOutput when input length is 0"
This reverts commit d586996.
1 parent dfcd54a commit 586602d

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
@@ -232,7 +232,9 @@ func (i *WindowPartitionIter) initializePartitions(ctx *sql.Context) ([]sql.Wind
232232
// At this stage, result rows are appended with the original row index for resorting. The size of
233233
// [i.output] will be smaller than [i.input] if the outer sql.Node is a plan.GroupBy with fewer partitions than rows.
234234
func (i *WindowPartitionIter) materializeOutput(ctx *sql.Context) (sql.WindowBuffer, error) {
235-
if len(i.input) == 0 {
235+
// handle nil input specially if no partition clause
236+
// ex: COUNT(*) on nil rows returns 0, not nil
237+
if len(i.input) == 0 && len(i.w.PartitionBy) > 0 {
236238
return nil, io.EOF
237239
}
238240

0 commit comments

Comments
 (0)