codeant-ai-for-open-source[bot] commented on code in PR #44665:
URL: https://github.com/apache/superset/pull/44665#discussion_r4134330601
##########
superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx:
##########
@@ -1140,6 +1176,19 @@ export default function TableChart<D extends DataRecord
= DataRecord>(
} else {
valueToFormat = value;
}
+ // String cells that read as numbers ("1.00") must compare
+ // numerically, or comparator rules like `= 1` never match.
+ if (
+ formatter.objectFormatting ===
+ ObjectFormattingEnum.CELL_BAR &&
+ valueToFormat !== null &&
+ valueToFormat !== undefined
+ ) {
+ const coerced = parseNumeric(valueToFormat);
+ if (coerced !== undefined) {
+ valueToFormat = coerced;
+ }
+ }
Review Comment:
Yes. Coercion should be limited to operators that require numeric
comparison. String comparators must receive the original value so
numeric-looking strings remain strings.
For example:
```typescript
const stringComparators = new Set([
Comparator.BeginsWith,
Comparator.EndsWith,
Comparator.Containing,
Comparator.NotContaining,
]);
if (
formatter.objectFormatting === ObjectFormattingEnum.CELL_BAR &&
!stringComparators.has(formatter.operator) &&
valueToFormat !== null &&
valueToFormat !== undefined
) {
const coerced = parseNumeric(valueToFormat);
if (coerced !== undefined) {
valueToFormat = coerced;
}
}
```
This preserves behavior such as `Containing("23")` against `"1234.00"`,
while still allowing numeric operators like `Equal`, `GreaterThan`, and
`LessThan` to match `"1234.00"` against numeric targets. A focused regression
test should cover a numeric-looking string column with each affected string
comparator.
--
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]