feat(functions): implement VSTACK and HSTACK (HF-71)#1698
feat(functions): implement VSTACK and HSTACK (HF-71)#1698marcin-kordas-hoc wants to merge 1 commit into
Conversation
Add the VSTACK and HSTACK array-manipulation functions to ArrayPlugin, mirroring the existing FILTER implementation pattern. - VSTACK stacks input arrays vertically: result height = sum of input heights, width = max input width. Narrower rows are padded on the right with #N/A. - HSTACK stacks input arrays horizontally: result width = sum of input widths, height = max input height. Shorter columns are padded at the bottom with #N/A. - Both are variadic (repeatLastArgs: 1) and accept ranges, array literals and scalars (FunctionArgumentType.RANGE, enableArrayArithmeticForArguments). - Result dimensions are declared at parse time via the sizeOfResultArrayMethod (vstackArraySize / hstackArraySize) so the result spills correctly, consistent with HyperFormula's parse-time array sizing. Padding uses ErrorType.NA (HyperFormula has no #CALC!). - Add translations for all 17 built-in language packs (English name in every locale, matching Excel/Sheets, which do not localize these functions). enUS inherits enGB. - Document both functions in the built-in functions guide and add a changelog entry. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
✅ Deploy Preview for hyperformula-dev-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Task linked: HF-71 Implement VSTACK and HSTACK functions |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4abdae5. Configure here.
| const sourceRow = row < data.length ? data[row] : undefined | ||
| for (let col = 0; col < range.width(); col++) { | ||
| result[row].push(sourceRow !== undefined ? sourceRow[col] : new CellError(ErrorType.NA, ErrorMessage.ValueNotFound)) | ||
| } |
There was a problem hiding this comment.
HSTACK omits NA row padding
Medium Severity
In hstack, when a row exists but has fewer columns than the range width (including an empty row array), cells beyond the row length are taken from sourceRow[col] and become undefined instead of #N/A. vstack pads short rows via padRowToWidth, so stacked results can disagree with Excel and with VSTACK on jagged inputs such as FILTER output.
Reviewed by Cursor Bugbot for commit 4abdae5. Configure here.
Performance comparison of head (4abdae5) vs base (72205bd) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1698 +/- ##
========================================
Coverage 97.16% 97.16%
========================================
Files 176 176
Lines 15322 15365 +43
Branches 3387 3393 +6
========================================
+ Hits 14887 14930 +43
Misses 435 435
🚀 New features to boost your workflow:
|


What
Implements two new array-spilling functions,
VSTACKandHSTACK, inArrayPlugin.#N/A.#N/A.Behaviour matches Excel 365 / Google Sheets, with the documented HyperFormula nuances below.
Scope
src/interpreter/plugin/ArrayPlugin.ts—VSTACK/HSTACKmetadata, methods, and*ArraySizeparse-time size calculations (sharedstackSubChecks+padRowToWidthhelpers).src/i18n/languages/*.ts— function-name entries for all 18 language packs (enUSinherits fromenGB). The names are identical across locales, matching Excel's convention for these functions.docs/guide/built-in-functions.md— entries for both functions.CHANGELOG.md—Addedentry under[Unreleased].HyperFormula nuances vs. Excel
null) rather than coercing to0. HyperFormula preserves the empty value; Excel (which has no empty-result cell) displays0. The stacked structure is identical.runFunction-based function behaves (e.g.ABS,FILTER). Errors located inside an input range pass through per cell, preserving their type (matches Excel).Test coverage
Unit tests live in the private tests repository: handsontable/hyperformula-tests#18 (54 cases: 27 VSTACK + 27 HSTACK), mirroring a validated Excel 365 oracle. They cover same-width/height stacks, dimension mismatch with
#N/Apadding, scalars, single-arg passthrough, mixed types, error passthrough, empty cells, nestedVSTACK/HSTACK, and integration withSEQUENCE/TRANSPOSE.🤖 Generated with Claude Code