mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-05 01:58:58 +00:00
Addresses CodeRabbit review on #3221, "Check the output size before with_subtotals builds subtotal lines": the size limit was checked only after every subtotal line existed. A row with 4000 key columns at total depth 4000 nested with_subtotals 4000 levels deep and overflowed the stack (the process aborted) before the late check could refuse it. with_subtotals now works without recursion: each line gets an id for its key prefix at every level, a stable sort by those ids keeps each group together in first-appearance order, and one walk adds the subtotals. The output size (with the header and total lines when present) is checked while the groups are counted, before any subtotal line is built. Test: groupby_subtotals_past_the_size_limit_are_refused_before_they_are_built. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>