Skip to content

Reject oversized TEXTSPLIT results before building the padded grid (#538) - #620

Merged
h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
MarekSpodBiedry:issue-538
Oct 13, 2026
Merged

h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
MarekSpodBiedry:issue-538

Conversation

@MarekSpodBiedry

Copy link
Copy Markdown
Contributor

Fixes #538.

TEXTSPLIT pads ragged rows to the widest row, reserved and filled the whole nrows * ncols grid, and only then let array_val reject it with #NUM!. A text under the 32,767-character cell limit (one 8,000-column row followed by 8,000 one-cell rows) asked for about 64 million cells before being rejected.

The fix checks nrows.saturating_mul(ncols) > MAX_CELLS right after the dimensions are known and returns #NUM! before any allocation. This is the same guard the sibling array builders already use (dynamic.rs MAKEARRAY/SEQUENCE/EXPAND, info.rs). Results within the limit, padding and the default #N/A fill are unchanged.

Test: split_rejects_oversized_padded_grid feeds the 8,000 x 8,001 case and expects #NUM!. Without the fix the result is still #NUM!, but only after building the ~64M-cell grid, so the test is slow and memory-heavy rather than red.

@MarekSpodBiedry
MarekSpodBiedry marked this pull request as ready for review October 12, 2026 06:54
@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit c8f249f into storytold:main Oct 13, 2026
1 check failed
@echelon

echelon commented Oct 13, 2026

Copy link
Copy Markdown
Member

Merged — thank you @MarekSpodBiedry for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(functions): TEXTSPLIT builds oversized padded grids before rejecting them

3 participants