Repository navigation
Add CHOOSEROWS function (HF-385) - #1827
Conversation
This reverts commit f915ac4.
Add CHOOSEROWS to ArrayPlugin. CHOOSECOLS's evaluation and spill-size prediction move into private helpers parameterised by axis, which both functions now use; CHOOSECOLS's results are unchanged. Also add the catalogue entry, the localized names, the known limitations, two list-of-differences rows and the changelog entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@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. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
hyperformula-docs | 7811bab | Commit Preview URL Branch Preview URL |
Nov 16 2026, 11:49 AM |
Performance comparison of head (7811bab) vs base (d31ed15) |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The evaluation returned #SPILL! for any whole-column source below row 1, also inside SUM where nothing spills. The size prediction now keeps the unbounded height there instead, so only a spilled result returns #SPILL!. Correct the whole-column row in the list of differences (HyperFormula spills the source's current height, Excel all rows) and say in the known limitations that an array of indexes uses its first index. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Below the first row a spilled result over an empty whole column returns #SPILL!, like any other whole-column result there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-function # Conflicts: # CHANGELOG.md
…o feature/HF-385 # Conflicts: # docs/guide/list-of-differences.md # hyperformula/src/interpreter/plugin/ArrayPlugin.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-function # Conflicts: # CHANGELOG.md # docs/guide/known-limitations.md # hyperformula/src/license/functionCapabilities.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
marcin-kordas-hoc
left a comment
There was a problem hiding this comment.
blocking: the branch is 18 commits behind #1734 and conflicts with develop in CHANGELOG.md, known-limitations.md and functionCapabilities.ts, so merging #1734's current head and develop here would let CI run on the tree that would be merged.
blocking: the description needs the current template, whose AI assistance section the Definition of Done asks for when an AI tool wrote the change; all 3 commits of this PR are co-authored by Claude, and the Compatibility, Public API changes and Out of scope sections are missing too.
nit: the description still says the license capability entry comes with a later merge, but 9367449 already adds CHOOSEROWS to the table.
question: counting negative indexes from the top fails 7 of the 120 CHOOSEROWS tests when I mutate chooseAlongAxis, while the description says 12; was the description's mutant a different one?
I measured 149 cases in Excel Online through ROWS, COLUMNS and INDEX, and HyperFormula matches 143; the other six are the documented array of indexes and behaviours CHOOSECOLS has too. The full Jest suite passes at both heads (6,914 tests).
…-function # Conflicts: # CHANGELOG.md
…o feature/HF-385 # Conflicts: # docs/guide/list-of-differences.md # hyperformula/src/license/functionCapabilities.ts
|
Merged #1734's current head, which includes today's |
marcin-kordas-hoc
left a comment
There was a problem hiding this comment.
The branch now has #1734's current head, and CI passed on the tree merged with develop at f94e5f3 with 7,395 tests. The description follows the template, with the AI assistance section, and no longer says the license entry comes later. Counting negative indexes from the top fails 7 of the 120 CHOOSEROWS tests and 6 of the 54 CHOOSECOLS tests here, which answers my question and matches the description. It merges after #1734.
…-function # Conflicts: # CHANGELOG.md
…-function # Conflicts: # CHANGELOG.md
### Context This PR adds `CHOOSECOLS`, allowing columns to be selected from an array with positive or negative indexes while preserving the requested order and duplicate indexes. The implementation remains local to `ArrayPlugin`; `CHOOSEROWS` is outside this PR's scope. It includes function metadata, translations, changelog and compatibility documentation. Behavior covered: - Positive, negative, mixed, duplicate, fractional, coerced, referenced, and calculated indexes. - Scalar, range, whole-row, whole-column, and calculated-array inputs. - Static spill-size prediction, including validating an empty or literal-error index before spill allocation. - Bounds checks, error propagation, blocked spills, lazy reads, and argument validation. - Whole-column sources spill from row 1 and return `#SPILL!` below row 1. - A whole-column result that outgrows the area reserved for it, for example after another spill makes the source taller, returns `#SPILL!` instead of throwing, including when the formula is entered with `setCellContents`. ### How did you test your changes? - Tests PR: handsontable/hyperformula-tests#34, 54 focused `CHOOSECOLS` tests. - Full Jest suite with the private tests, after merging `develop`: 528 suites, 7,275 tests passed, 3 skipped. - `npm run verify:typings`, `npm run lint` (0 errors) and `git diff --check` pass. ### AI assistance Claude Code wrote the code, tests and docs. I reviewed it. ### Compatibility with Excel and Google Sheets Excel: Microsoft Excel Online. Google Sheets: the values in the list of differences. In the examples, A1:C3 holds 1 to 9 row by row. | Formula | Excel | Google Sheets | HyperFormula | |---|---|---|---| | `=SUM(CHOOSECOLS(A:A,1))` | 12 | – | 12 | | `=SUM(CHOOSECOLS(A:C,2))` | 15 | – | 15 | | `=COLUMNS(CHOOSECOLS(A1:C3,{1,2}))` | 2 | 2 | 1 | Excel also confirmed the same-sheet and cross-sheet whole-column behavior, whole-row indexes, and that an empty column index returns `#VALUE!` even when the predicted spill range is blocked. The deliberate differences (whole-column and whole-row sources, an array or range of indexes, an empty whole-column source) are listed in `list-of-differences.md` and `known-limitations.md`. ### Public API changes None. One new built-in function. ### Out of scope and follow-ups - `CHOOSEROWS` is in #1827. - An array or range of indexes in one argument is not supported; it is listed in the known limitations. ### Types of changes - [ ] Breaking change (existing functionality no longer works as before) – agreed with the maintainers - [x] New feature or improvement (a non-breaking change that adds functionality) - [ ] Bug fix (a non-breaking change that fixes an issue) - [x] Additional language file, or a change to an existing language file (translations) - [x] Change to the documentation ### Related issues 1. HF-141 (`CHOOSECOLS`). 2. Tests: handsontable/hyperformula-tests#34 ### Checklist - [x] My pull request meets the [Definition of Done](https://github.com/handsontable/hyperformula/blob/develop/dev-docs/DEFINITION-OF-DONE.md). External contributors: see also [Contributing to HyperFormula](https://handsontable.com/docs/hyperformula/guide/contributing.html). - [ ] I have signed the [Contributor License Agreement](https://goo.gl/forms/yuutGuN0RjsikVpM2). - [ ] I read my own diff end to end before requesting a review. - [x] I added a [CHANGELOG.md](https://github.com/handsontable/hyperformula/blob/develop/CHANGELOG.md) entry, written by [the changelog rules](https://github.com/handsontable/hyperformula/blob/develop/dev-docs/DOC-STANDARDS.md#the-changelog) – or none is needed (docs, tests or tooling only). - [x] I updated the documentation and JSDoc to match the change. - [ ] Breaking change only: I added a section to the migration guide. - [x] I updated the `dev-docs/` pages this change affects – or none needed it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > New formula engine behavior around spill reservation and whole-column edge cases can affect existing sheets using dynamic arrays; scope is localized to ArrayPlugin but user-visible results differ from Excel in documented cases. > > **Overview** > Adds **`CHOOSECOLS`** as a dynamic-array lookup function in `ArrayPlugin`, selecting one or more columns from a range by positive/negative indexes (with duplicates allowed) and returning a spilled 2D result. > > Spill sizing is handled by **`choosecolsArraySize`**, which validates literal column indexes before allocation, derives height from whole-column sources (including effective height on row 1), and leaves unbounded height below row 1 so formulas surface **`#SPILL!`** when the result would extend past the sheet edge. Runtime evaluation mirrors Excel-style bounds checks and maps empty sources to **`#N/A`**. > > Docs and product surfacing are updated: **CHANGELOG**, **known limitations**, a **list-of-differences** vs Excel/Sheets, **function metadata**, **localized names** across language packs, and inclusion of **`CHOOSECOLS`** in the **license** capability list for ungrouped functions. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6452f39. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Kuba Sekowski <jakub.sekowski@handsontable.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
… into feature/HF-385
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1827 +/- ##
===========================================
+ Coverage 97.44% 97.46% +0.01%
===========================================
Files 209 209
Lines 16742 16778 +36
Branches 3748 3777 +29
===========================================
+ Hits 16314 16352 +38
+ Misses 428 426 -2
🚀 New features to boost your workflow:
|
Context
This PR adds the
CHOOSEROWSdynamic-array function (HF-385).CHOOSEROWS(array, row_num1, [row_num2], ...)returns the requested rows of an array, in argument order.Important
Stacked on #1734 (
CHOOSECOLS). CHOOSEROWS is CHOOSECOLS on the other axis and shares its code, so this branch is based onfeature/choosecols-function. Until #1734 merges, this diff also shows CHOOSECOLS's commits. The CHOOSEROWS changes are the commitsfeat: add CHOOSEROWS function (HF-385),docs: link the CHOOSEROWS pull request in the changelogand the license table entry. Once #1734 merges,developwill be merged into this branch and only these changes will remain in the diff.Behavior, checked against Microsoft Excel Online (en-US):
CHOOSEROWS(A1:C3, -1)is the last row.0.5,-0.5), and an index past either end return#VALUE!.TRUEcoerce to row numbers.FALSE,"", a blank cell, an empty index and non-numeric text return#VALUE!.CHOOSEROWS(A1:C3, 0, NA())returns#N/A.Note: Microsoft's CHOOSEROWS page describes its
CHOOSEROWS(A2:B7,-1,-2)example as returning row four and then row three. On the page's six-row data, Excel returns rows 6 and 5, as the formula says, and this implementation follows Excel.Implementation:
CHOOSEROWSlives inArrayPlugin, next toCHOOSECOLS, with the same metadata.chooseAlongAxisandchooseArraySize, andchoosecols/choosecolsArraySizenow delegate to them.parseChooseColsLiteralIndexis renamedparseChooseLiteralIndex; its body is unchanged. CHOOSECOLS's spec passes unchanged.#SPILL!. Rows are read only for the chosen indexes.#SPILL!elsewhere. Indexes into a whole-column source count against the sheet's used rows. Both are listed inlist-of-differences.md.#VALUE!for it when the result has more than one cell.CHOOSEROWS functionsection inknown-limitations.mdand two rows inlist-of-differences.mdare included.ZEILENWAHL/SPALTENWAHLandSCEGLI.RIGA/SCEGLI.COL). Indonesian keeps the English name, because Excel Online shows English function names in that locale.Known limitations, documented in
known-limitations.md:CHOOSEROWS(A1:C3, {1,3})); CHOOSEROWS follows CHOOSECOLS here and doesn't support it.#VALUE!when the result has more than one cell.How did you test your changes?
CHOOSEROWStests: 99 assert Excel's result, and 21 pin documented differences (arrays and ranges of indexes, whole-column and whole-row sources, a missing row index, and a date before March 1900).develop: 529 suites, 7,395 tests passed, 3 skipped. CHOOSECOLS's 54 tests pass unchanged.CHOOSEROWStests (and 6 ofCHOOSECOLS's, which share the code).npm run verify:typings,npm run lint(0 errors),npm run docs:generate-function-docsandgit diff --checkpass.AI assistance
Claude Code wrote the code, tests and docs. I reviewed it.
Compatibility with Excel and Google Sheets
Excel: Microsoft Excel Online (en-US). Google Sheets: not checked. In the examples, A1:C3 holds 1 to 9 row by row.
=CHOOSEROWS(SEQUENCE(6,2),1,3,5,1)=CHOOSEROWS(SEQUENCE(6,2),-1,-2)=CHOOSEROWS(A1:C3,-1)=CHOOSEROWS(A1:C3,200%)=CHOOSEROWS(A1:C3,TRUE())=CHOOSEROWS(A1:C3,0)#VALUE!#VALUE!=CHOOSEROWS(A1:C3,0,NA())#N/A#N/AThe deliberate differences (an array or range of indexes, whole-row and whole-column sources, a source whose size can't be predicted) are listed in
list-of-differences.mdandknown-limitations.md.Public API changes
None. One new built-in function.
Out of scope and follow-ups
CHOOSECOLS; it is listed in the known limitations.Types of changes
Related issues
CHOOSEROWS).CHOOSECOLS).Checklist
dev-docs/pages this change affects – or none needed it.🤖 Generated with Claude Code
Note
Medium Risk
New dynamic-array spill and size-prediction paths touch array evaluation and worksheet-edge behavior; regressions would affect formulas using these functions but not existing callers unless shared helpers mis-handle CHOOSECOLS.
Overview
Adds Excel-style
CHOOSECOLSandCHOOSEROWSdynamic-array functions that return selected columns or rows (in index order, with negative indexing and duplicates), wired throughArrayPluginwith sharedchooseAlongAxis/chooseArraySizehelpers, literal-index parsing for spill-size prediction, andvectorizationForbidden.Documents spill and indexing limits (scalar indexes only, whole row/column behavior,
#SPILL!vs runtime errors) in known-limitations, Excel/Sheets differences in list-of-differences, and changelog entries. Registers metadata, localized names across language packs, and lists both functions in the license ungrouped capability table.Reviewed by Cursor Bugbot for commit 9367449. Bugbot is set up for automated code reviews on this repo. Configure here.