Feature/choosecols function - #1734
Conversation
|
@Tobiadefami thanks for the pull request. No CLA step needed here — our records show you signed the Contributor License Agreement on 2026-07-31. That signature came from our previous signing form and has been carried over, so there is nothing for you to re-sign. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
hyperformula-docs | f915ac4 | Commit Preview URL Branch Preview URL |
Aug 17 2026, 12:28 PM |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort 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 8e0ff87. Configure here.
Performance comparison of head (f915ac4) vs base (61ead73) |
| * @param {Ast} argument - The column-index argument to inspect without evaluating formulas. | ||
| * @returns {ChooseColsLiteralIndex} A coerced literal value, an invalid marker, or an unresolved marker. | ||
| */ | ||
| private parseChooseColsLiteralIndex(argument: Ast): ChooseColsLiteralIndex { |
There was a problem hiding this comment.
codecov/patch is red because of exactly two untested lines: the PLUS_UNARY_OP branch (e.g. =CHOOSECOLS(A1:D3,+2)) and the PARENTHESIS branch (e.g. (2)). One or two literal-index tests for these should close it completely.
| * @param {ProcedureAst} ast - The parsed function-call AST node. | ||
| * @param {InterpreterState} state - The current interpreter evaluation state. | ||
| */ | ||
| public choosecolsArraySize(ast: ProcedureAst, state: InterpreterState): ArraySize { |
There was a problem hiding this comment.
Same finding as on #1722's TAKE: CHOOSECOLS(A:A,1) returns #VALUE! even on the same sheet, where real Excel spills correctly (confirmed live via MS Graph). SORT/UNIQUE/FILTER already support this in the same codebase — worth reusing whatever they do differently in array-size prediction rather than the current blanket rejection of non-finite dimensions.
known-limitations.md's new CHOOSECOLS entry is otherwise excellent, by the way — exactly the house style (HF's own behavior + consequence, no Excel-comparison framing). Once the same-sheet case is fixed, the "Spills the whole column when space is available" line in list-of-differences.md will need to become case-specific: same-sheet works, cross-sheet genuinely does not (confirmed #SPILL! in real Excel).
|
This PR also touches |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1734 +/- ##
===========================================
+ Coverage 97.31% 97.34% +0.03%
===========================================
Files 195 195
Lines 15719 15789 +70
Branches 3455 3413 -42
===========================================
+ Hits 15297 15370 +73
- Misses 414 419 +5
+ Partials 8 0 -8
🚀 New features to boost your workflow:
|

Context
HyperFormula does not currently support
CHOOSECOLS.This change adds
CHOOSECOLS, allowing columns to be selected from an array using positive or negativeindexes. It preserves the requested order and duplicate indexes and includes function metadata,
translations, documentation, and tests.
The implementation remains local to
ArrayPlugin.CHOOSEROWSis outside the scope of this change.How did you test your changes?
Added tests covering:
All 35 focused tests passed.
The full Jest and browser test suites, TypeScript compilation, linting, and documentation generation also
completed successfully.
Types of changes
expected anymore)
Related issues:
None.
Checklist:
hyperformula.handsontable.com/guide/contributing.html) and I confirm that my code follows the code style of
this project.
os/part4-formula/OpenDocument-v1.3-os-part4-formula.html) standard.
CHANGELOG.md) file.
Note
Medium Risk
New formula surface area in dynamic-array spill logic; bounded to ArrayPlugin but affects spill allocation and error reporting (#SPILL! vs runtime errors).
Overview
Adds the CHOOSECOLS dynamic-array function so formulas can return selected columns from a range in a given order (positive/negative indexes, duplicates allowed).
Implementation lives in
ArrayPlugin: evaluation builds the result from range data or dependency-graph column slices, andchoosecolsArraySizepredicts spill dimensions. Literal column indexes are validated before spill allocation; whole-column sources only spill on the same sheet in row 0, otherwise#SPILL!applies.Also ships function metadata, localized names across language packs, changelog entry, known-limitations notes (scalar index args only, spill behavior), and a list-of-differences row for whole-column spill vs Google Sheets.
Reviewed by Cursor Bugbot for commit f915ac4. Bugbot is set up for automated code reviews on this repo. Configure here.