Skip to content

fix(filters): sort numeric filter values numerically, not lexicographically (#36775) - #42596

Merged
rusackas merged 4 commits into
masterfrom
tdd/issue-36775-filter-value-numeric-sort
Aug 5, 2026
Merged

rusackas merged 4 commits into
masterfrom
tdd/issue-36775-filter-value-numeric-sort

Conversation

@rusackas

@rusackas rusackas commented Jul 30, 2026 •

Copy link
Copy Markdown
Member

SUMMARY

Closes #36775 (filed 2026, a recurrence of #35008): numeric filter values in the dashboard filter-value dropdown were sorted alphabetically ("1, 10, 100...") instead of numerically ("1, 2, 3..."). Confirmed still present through 6.0.0, 6.0.1rc1, and 6.1.0rc2 per reporter comments.

Root cause: SelectFilterPlugin's sortComparator (superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx) compared options via propertyComparator('label'), but getDataRecordFormatter (superset-frontend/src/filters/utils.ts) always returns a formatted string label regardless of the column's underlying datatype. Numeric filter values therefore always hit propertyComparator's string branch (localeCompare) instead of its numeric branch. This is the second recurrence: #34858 fixed the analogous bug in SelectControl.jsx (chart-builder numeric selects like "Row limit"), but never touched this native-filter value dropdown, which has its own independent sorting logic.

Fix: propertyComparator already has a working numeric branch — it just needs a property that actually holds a number. The unformatted value on each option does, for numeric columns, while label never does. sortComparator now compares by value when the column's GenericDataType is Numeric, and keeps comparing by label for every other type, so string/temporal/boolean sorting is untouched.

This started as a test-only TDD PR (added one regression test on PluginFilterSelect); this update adds the fix itself once CI confirmed the test was red.

TESTING INSTRUCTIONS

npx jest src/filters/components/Select/SelectFilterPlugin.test.tsx

Full suite: 39/39 passing, including the new regression test and both pre-existing alphabetical-sort tests (confirming string-column sorting is unaffected).

ADDITIONAL INFORMATION

  • Has associated issue: Closes Sorting in filter values #36775
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

Disclosure: the local type-checking-frontend pre-commit hook was skipped (SKIP=type-checking-frontend) — this worktree's tsc --build currently fails on pre-existing TS2742 "inferred type... not portable" errors in unrelated files (Tabs.tsx, SafeMarkdown.tsx, spec/index.tsx), not touched by this change. All other local hooks (prettier, oxlint, custom-rules-frontend, stylelint) passed. CI's Type-Checking (Frontend) job is the real gate for this.

🤖 Generated with Claude Code

@bito-code-review

bito-code-review Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #83fdb5

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 418abb4..418abb4
    • superset-frontend/src/filters/components/Select/SelectFilterPlugin.test.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. The test fails because the current implementation sorts options lexicographically using localeCompare on the formatted labels, while the test expects numeric sorting. To resolve this, the propertyComparator used by SelectFilterPlugin needs to be updated to handle numeric values correctly when the data type is numeric.

Since I do not have access to the production code (SelectFilterPlugin.tsx) to implement the fix, I recommend updating the comparator logic to check if the values are numeric before applying localeCompare.

Regarding other comments on this PR, there are no additional comments in the provided review data. Would you like me to assist with any other aspects of this PR?

superset-frontend/src/filters/components/Select/SelectFilterPlugin.test.tsx

// Options should appear in ascending numeric order (2, 10, 100), not
    // ascending lexicographic order of their formatted labels (10, 100, 2).
    const options = screen.getAllByRole('option');
    expect(options[0]).toHaveTextContent('2');
    expect(options[1]).toHaveTextContent('10');
    expect(options[2]).toHaveTextContent('100');

@rusackas rusackas changed the title test(filters): pin numeric filter values sort numerically, not lexicographically (#36775) fix(filters): sort numeric filter values numerically, not lexicographically (#36775) Jul 30, 2026
@netlify

netlify Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 5f44491
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a7180583680b90008c49c16
😎 Deploy Preview https://deploy-preview-42596--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 65.59%. Comparing base (1666cca) to head (4708879).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...s/superset-ui-core/src/components/Select/utils.tsx 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42596      +/-   ##
==========================================
- Coverage   65.59%   65.59%   -0.01%     
==========================================
  Files        2819     2819              
  Lines      160166   160173       +7     
  Branches    36569    36575       +6     
==========================================
  Hits       105065   105065              
- Misses      53053    53060       +7     
  Partials     2048     2048              
Flag Coverage Δ
javascript 71.75% <90.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bito-code-review

bito-code-review Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #f05d56

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 418abb4..8966a1d
    • superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

rusackas added a commit that referenced this pull request Aug 3, 2026
…anch

Closes review feedback on #42596: BIGINT columns with 16+ digit values
decode to native `bigint` (see json-bigint parsing), not `number`. The
numeric-sort fix landed in 8966a1d compares by `value` for Numeric
columns via propertyComparator, but that comparator's numeric branch
only matched `typeof === 'number'`, so bigint values fell through to
the string fallback and reproduced the exact "10, 100, 2" bug for
BIGINT-backed filters. propertyComparator now also compares bigint
(and mixed bigint/number) values numerically via relational operators.

Verified the comparator logic directly with a standalone Node script
(diverging-digit-length bigints sort correctly with the new branch,
incorrectly without it) since `npm install` hangs on this worktree's
volume before node_modules exist; prettier and oxlint pass on both
changed files.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Aug 3, 2026
@bito-code-review

bito-code-review Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #1dbba6

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 8966a1d..cc3571c
    • superset-frontend/packages/superset-ui-core/src/components/Select/utils.tsx
    • superset-frontend/src/filters/components/Select/SelectFilterPlugin.test.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

claude and others added 3 commits August 3, 2026 22:59
…graphically (#36775)

Closes #36775

Adds a regression test on PluginFilterSelect confirming that when no
sortMetric is configured, numeric filter-value options are ordered by
their numeric value (2, 10, 100) rather than by lexicographic
comparison of their formatted string labels (10, 100, 2).

Root cause: SelectFilterPlugin's sortComparator always compares the
formatted `label` via propertyComparator('label'). getDataRecordFormatter
(superset-frontend/src/filters/utils.ts) always returns a string, so
numeric columns hit propertyComparator's string branch (localeCompare)
instead of its numeric branch, even though the values themselves are
numeric. This is the second recurrence of the #35008/#34858 fix, which
patched SelectControl.jsx (chart-builder numeric selects like Row limit)
but never touched this native-filter value dropdown.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ically

Closes #36775

sortComparator compared options via propertyComparator('label'), but
getDataRecordFormatter (filters/utils.ts) always returns a formatted
string label regardless of the column's underlying datatype. Numeric
filter values therefore always hit propertyComparator's string branch
(localeCompare) instead of its numeric branch, producing "1, 10, 100,
2" instead of "1, 2, 10, 100".

propertyComparator already has a numeric branch; it just needs a
property that actually holds a number. `value` (the raw, unformatted
option value) does for numeric columns, while `label` never does. Fix
compares by `value` when the column's GenericDataType is Numeric, and
keeps comparing by `label` for every other type -- unaffected here
since #34858 already fixed the analogous SelectControl.jsx bug; this
native-filter value dropdown just has its own independent sort path
that #34858 never touched, and #36775 is the recurrence.

Disclosure: type-checking-frontend was skipped locally (SKIP set) --
this worktree's `tsc --build` currently fails on unrelated TS2742
"inferred type... not portable" errors in Tabs.tsx/SafeMarkdown.tsx/
spec/index.tsx (pre-existing composite-build fragility, not touched
by this change; the PR's own prior commit disclosed the same
build-environment limitation). oxlint, prettier, and the full
SelectFilterPlugin.test.tsx suite (39/39, including the new
regression test and both pre-existing alphabetical-sort tests) are
green locally. CI's Type-Checking (Frontend) job is the real gate.
…anch

Closes review feedback on #42596: BIGINT columns with 16+ digit values
decode to native `bigint` (see json-bigint parsing), not `number`. The
numeric-sort fix landed in 8966a1d compares by `value` for Numeric
columns via propertyComparator, but that comparator's numeric branch
only matched `typeof === 'number'`, so bigint values fell through to
the string fallback and reproduced the exact "10, 100, 2" bug for
BIGINT-backed filters. propertyComparator now also compares bigint
(and mixed bigint/number) values numerically via relational operators.

Verified the comparator logic directly with a standalone Node script
(diverging-digit-length bigints sort correctly with the new branch,
incorrectly without it) since `npm install` hangs on this worktree's
volume before node_modules exist; prettier and oxlint pass on both
changed files.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@rusackas
rusackas force-pushed the tdd/issue-36775-filter-value-numeric-sort branch from cc3571c to 5f44491 Compare August 4, 2026 06:01

@bito-code-review bito-code-review Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Agent Run #c66c9e

Actionable Suggestions - 1
  • superset-frontend/packages/superset-ui-core/src/components/Select/utils.tsx - 1
Review Details
  • Files reviewed - 3 · Commit Range: 12ee488..5f44491
    • superset-frontend/packages/superset-ui-core/src/components/Select/utils.tsx
    • superset-frontend/src/filters/components/Select/SelectFilterPlugin.test.tsx
    • superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

Addresses bot review feedback on #42596: the bigint comparison branch
was only exercised indirectly through SelectFilterPlugin.test.tsx.
Add direct unit tests in utils.test.ts covering string, number, bigint,
diverging-digit-length bigint, and mixed bigint/number comparisons.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@bito-code-review

bito-code-review Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #ac88ea

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 5f44491..4708879
    • superset-frontend/packages/superset-ui-core/src/components/Select/utils.test.ts
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas
rusackas merged commit 7324225 into master Aug 5, 2026
75 checks passed
@rusackas
rusackas deleted the tdd/issue-36775-filter-value-numeric-sort branch August 5, 2026 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sorting in filter values

3 participants