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 | 0df4d1f | Commit Preview URL Branch Preview URL |
Aug 17 2026, 07:28 PM |
Performance comparison of head (0df4d1f) 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 |
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 0df4d1f. Configure here.
| } | ||
| } | ||
|
|
||
| return new ArraySize(ast.args.length - 1, effectiveHeight) |
There was a problem hiding this comment.
Finite height breaks column spills
High Severity
choosecolsArraySize now materializes whole-column results with a finite effectiveHeight snapshot instead of keeping an unbounded height. Array size is fixed when the formula is set, so when the source sheet later grows, evaluation returns more rows than predicted and ArrayValue.resize throws. SORT/UNIQUE/FILTER keep POSITIVE_INFINITY here so spill stays an AbsoluteColumnRange and can expand.
Reviewed by Cursor Bugbot for commit 0df4d1f. Configure here.
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 15790 +71
Branches 3455 3414 -41
===========================================
+ Hits 15297 15371 +74
- 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 dynamic-array behavior touches spill allocation and range materialization in a core interpreter plugin; scope is localized but errors can surface as #SPILL! when the reserved range is blocked.
Overview
Adds the CHOOSECOLS dynamic-array function so formulas can return selected columns from a range, with positive/negative indexing, duplicate indexes, and spill sizing aligned with other array functions in
ArrayPlugin.Implementation lives in
ArrayPlugin(choosecols/choosecolsArraySize), including literal column-index parsing for pre-spill validation, whole-column spill rules (row 1 vs#SPILL!below), and reading only the chosen columns from worksheet ranges. CHOOSEROWS is explicitly out of scope.Also updates changelog, function metadata, localized names across language packs, and docs on limitations and Excel/Sheets parity for whole-column
CHOOSECOLS.Reviewed by Cursor Bugbot for commit 0df4d1f. Bugbot is set up for automated code reviews on this repo. Configure here.