bito-code-review[bot] commented on code in PR #42596:
URL: https://github.com/apache/superset/pull/42596#discussion_r3711224629
##########
superset-frontend/packages/superset-ui-core/src/components/Select/utils.tsx:
##########
@@ -91,6 +91,18 @@ export const propertyComparator =
if (typeof propertyA === 'number' && typeof propertyB === 'number') {
return propertyA - propertyB;
}
+ // BIGINT columns can decode to native `bigint` values (see json-bigint
+ // parsing of large numeric values). Compare numerically rather than
+ // falling through to the string fallback below, which would sort them
+ // lexicographically (e.g. "10", "100", "2").
+ if (
+ (typeof propertyA === 'bigint' || typeof propertyA === 'number') &&
+ (typeof propertyB === 'bigint' || typeof propertyB === 'number')
+ ) {
+ if (propertyA < propertyB) return -1;
+ if (propertyA > propertyB) return 1;
+ return 0;
+ }
Review Comment:
<!-- Bito Reply -->
The suggestion to add unit tests for the `bigint` comparison logic is
appropriate and improves the robustness of the code. Since the
`propertyComparator` now explicitly handles `bigint` types to prevent
lexicographical sorting issues, having dedicated tests ensures that future
changes do not inadvertently revert to the previous sorting behavior. Applying
this suggestion is recommended to maintain the integrity of the numeric sorting
fix.
**superset-frontend/packages/superset-ui-core/src/components/Select/utils.tsx**
```
if (
(typeof propertyA === 'bigint' || typeof propertyA === 'number') &&
(typeof propertyB === 'bigint' || typeof propertyB === 'number')
) {
if (propertyA < propertyB) return -1;
if (propertyA > propertyB) return 1;
return 0;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]