feat: implement UNIQUE dynamic array function (HF-68)#1708
Open
marcin-kordas-hoc wants to merge 4 commits into
Open
feat: implement UNIQUE dynamic array function (HF-68)#1708marcin-kordas-hoc wants to merge 4 commits into
marcin-kordas-hoc wants to merge 4 commits into
Conversation
✅ Deploy Preview for hyperformula-dev-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
Task linked: HF-28 Modern dynamic array functions |
marcin-kordas-hoc
force-pushed
the
feature/HF-68-unique
branch
from
July 13, 2026 18:48
728efaf to
994b88e
Compare
7 tasks
Performance comparison of head (5e96194) vs base (fd04f77) |
Add UNIQUE(array, [by_col], [exactly_once]) as a dynamic array function, mirroring the FILTER machinery for data-dependent result size. Deduplication preserves first-occurrence order and reuses ArithmeticHelper for equality (case-insensitive by default, honoring the caseSensitive config). Supports by_col (unique columns) and exactly_once (values occurring exactly once). Errors in the input range propagate; an empty exactly_once result yields #N/A. Includes i18n for all 17 language packs, docs (built-in-functions, known-limitations), a changelog entry, and the shared ADR. Source: https://app.clickup.com/t/86c89q1tq ADR: docs/adr/2026-07-13-sort-unique-array-functions.md Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
marcin-kordas-hoc
force-pushed
the
feature/HF-68-unique
branch
from
July 18, 2026 15:22
994b88e to
9eb508d
Compare
Without enableArrayArithmeticForArguments, an array expression passed as the first argument (e.g. =UNIQUE(A1:A3*2)) is coerced as a scalar and only the first cell is computed. Matches FILTER/VSTACK/HSTACK/SORT. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…s (HF-68) The compared vectors are always rows (or columns, after transpose) of the same rectangular range, so they never differ in length — the guard was dead code. Removes the last uncovered line in UniquePlugin. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1708 +/- ##
===========================================
+ Coverage 97.17% 97.19% +0.02%
===========================================
Files 176 177 +1
Lines 15483 15548 +65
Branches 3429 3445 +16
===========================================
+ Hits 15045 15112 +67
+ Misses 438 436 -2
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Implements UNIQUE (
HF-68, child of HF-28 "Modern dynamic array functions", sibling of the shipped SEQUENCE and of VSTACK/HSTACK). AddsUNIQUE(array, [by_col], [exactly_once])as a dynamic array function.Tests: handsontable/hyperformula-tests#25 (paired).
Sibling PR: #1707 (SORT / HF-69).
ADR:
docs/adr/2026-07-13-sort-unique-array-functions.md.Behavior
by_colisTRUE) of the input, preserving first-occurrence order.by_col:FALSE(default) compares rows;TRUEcompares columns.exactly_once:TRUEreturns only rows/columns occurring exactly once;FALSE(default) returns all distinct.ArithmeticHelper.eq→ case-insensitive by default (honorscaseSensitive), matching Excel's UNIQUE.Design
Mirrors the FILTER machinery for dynamic-size results:
sizeOfResultArrayMethod+vectorizationForbidden: true, runtime viarunFunction, parse-time size method returning a freshArraySize(drops the input'sisRefflag). Deduplication is O(n²) in the number of vectors because locale-aware equality is not trivially hashable — noted in code; acceptable for v1.Notes — divergences from Excel (surfaced here + inline + in tests)
exactly_oncewhen nothing occurs exactly once) →#N/A. Excel returns#CALC!, which HyperFormula has no type for; mirrors FILTER's empty-result mapping (ADRdec_8).con_1).dec_7).Definition of Done
UniquePlugin.ts, registered viaplugin/index.ts)built-in-functions.md,known-limitations.mdSource: https://app.clickup.com/t/86c89q1tq
Note
Low Risk
Isolated new function plugin with established dynamic-array patterns; no changes to auth, persistence, or core calculation paths beyond registering UNIQUE.
Overview
This PR implements
UNIQUE(array, [by_col], [exactly_once])as a dynamic array function (HF-68), following the same pattern as FILTER and SEQUENCE.A new
UniquePlugindeduplicates rows (or columns whenby_colis TRUE) usingArithmeticHelper.eq, keeps first-occurrence order, and supportsexactly_once. Parse-time sizing uses the input dimensions as an upper bound; runtime may return a smaller spilled array. The firstCellErrorin the input is propagated; an empty result underexactly_oncereturns#N/A(EmptyRange) instead of Excel’s#CALC!.UniquePluginis exported fromplugin/index.ts.UNIQUEis added to all 17 language packs. CHANGELOG,built-in-functions.md,known-limitations.md, and a shared SORT/UNIQUE ADR document behavior and Excel divergences.Reviewed by Cursor Bugbot for commit 5e96194. Bugbot is set up for automated code reviews on this repo. Configure here.