Skip to content

Commit fb79b5d

Browse files
committed
docs: state which limits an aggregate accepts
The upgrade note described the accepted shapes loosely: it did not separate a direction-less limit on a `SELECT DISTINCT` aggregate from a top-k limit, and it listed none of the conditions a top-k limit also has to meet. List the three shapes that build, and what each one requires. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D7arPq4Frxu8byr17mqVKA
1 parent 5832f0f commit fb79b5d

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

  • docs/source/library-user-guide/upgrading

‎docs/source/library-user-guide/upgrading/56.0.0.md‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,28 @@ optimizer rules work, not a public API. The builder, `AggregateExec::builder`,
438438
- Anyone building an `AggregateExec` with a limit that the aggregate cannot
439439
execute, or decoding such a plan from protobuf: this is now an error at plan
440440
time instead of an internal error, a panic, or silently ignored `FILTER`
441-
expressions at execution time. A limit is only executable on an aggregate
442-
with no aggregate expressions (a `SELECT DISTINCT`-style aggregate), where the
443-
groups themselves are the result, or on one with a single `MIN`/`MAX`
444-
expression and a single group by expression, where the limit either carries no
445-
ordering direction or carries the one that aggregate already implies.
441+
expressions at execution time.
442+
443+
A limit is accepted on three shapes of aggregate:
444+
445+
- An aggregate with no group by expressions. It produces a single row, so the
446+
limit is ignored.
447+
- A `SELECT DISTINCT`-style aggregate: a group by, no aggregate expressions, no
448+
`FILTER`, and no ordering direction on the limit. The groups themselves are
449+
the result, so the stream stops once it holds enough of them.
450+
- A top-k aggregate, which needs an ordering direction and takes it from a
451+
single `MIN`/`MAX` aggregate expression, from the limit, or from both. When it
452+
comes from both they have to agree: the top-k stream uses the direction of the
453+
aggregate and ignores the one on the limit, so a limit that disagrees keeps
454+
the wrong K groups. A top-k aggregate must also have a limit above `0`,
455+
exactly one group by expression and no grouping sets, no `FILTER` on any
456+
aggregate expression, and a group key and value type the top-k queue
457+
supports.
458+
459+
Every other shape is rejected. A limit on an aggregate that has to accumulate,
460+
such as `COUNT`, is the important one: the grouped streams honor a limit by no
461+
longer reading input once they hold enough groups, which returns partial
462+
aggregate values for the groups they kept.
446463

447464
**Migration guide:**
448465

0 commit comments

Comments
 (0)