ReviewOS

stacks/bun-query-builder

Generalized window functions (lag/lead/sumOver/avgOver/countOver)

#1050
Closed glennmichael123 opened this 2 months ago ·
2 months ago

Summary

Window support is limited to rowNumber/rank/denseRank, which already build OVER (PARTITION BY ... ORDER BY ...). Generalize into a window(fn, { partitionBy, orderBy, frame }) or add lag/lead/sumOver/avgOver helpers reusing the existing overParts builder.

Effort: M (OVER-clause assembly already present). Location: src/client.ts:~2889-2924. Found via internal code audit.

8 days ago

Done in 0974c06. Added a shared OVER-clause builder plus generalized window functions: over() (generic — any expression, e.g. NTILE(4)), lag/lead (with offset + default value), sumOver/avgOver/countOver/minOver/maxOver, and firstValue/lastValue — each taking { partitionBy, orderBy, alias }. They compose with the existing rowNumber/rank/denseRank via the same select-injection path. Regression test added; full suite green.

Sign in to comment on this issue.