bito-code-review[bot] commented on code in PR #44044:
URL: https://github.com/apache/superset/pull/44044#discussion_r4160046521


##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts:
##########
@@ -471,12 +471,15 @@ export function extractDataTotalValues(
         }
         const value = datum[curr] || 0;
         // Query results with integers beyond Number.MAX_SAFE_INTEGER are
-        // parsed as native BigInt (see
+        // parsed as native BigInt or decimal strings (see
         // packages/superset-ui-core/src/connection/callApi/parseResponse.ts).
-        // Normalize to Number before summing so BigInt and Number values
+        // Normalize to Number before summing so BigInt/string and Number 
values
         // can be combined without throwing (see #36401).
         const numericValue =
-          typeof value === 'bigint' ? Number(value) : (value as number);
+          typeof value === 'bigint' ||
+          (typeof value === 'string' && /^-?\d+$/.test(value))
+            ? Number(value)
+            : (value as number);

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Duplicated normalization logic</b></div>
   <div id="fix">
   
   The BigInt/string-integer normalization expression (incl. the `/^-?\d+$/` 
regex) is duplicated verbatim at lines 478-482, 739-743 and 805-809 in this 
same file. Extract one `normalizeNumericValue(value)` helper and a named 
`INTEGER_STRING_RE` constant so the three sites can't drift apart.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #6089c6</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



##########
superset-frontend/packages/superset-ui-core/test/number-format/factories/createD3NumberFormatter.test.ts:
##########
@@ -99,4 +99,21 @@ describe('createD3NumberFormatter(config)', () => {
       expect(formatter(-1234.5)).toEqual('-1,234.50');
     });
   });
+  describe('BigInt values (integers beyond Number.MAX_SAFE_INTEGER)', () => {
+    // BigInt values from json-bigint are normalized to Number in 
formatValue.ts
+    // before reaching any formatter factory (see #44007, #42594). These tests
+    // verify that formatters correctly handle Number(bigint) — the actual 
value
+    // they receive at runtime from the table chart formatter pipeline.
+    test('formats Number(bigint) with a float format string without throwing', 
() => {
+      const formatter = createD3NumberFormatter({ formatString: ',.2f' });
+      // Number(BigInt('9007199254740993')) is the value the formatter 
actually receives
+      expect(() => 
formatter(Number(BigInt('9007199254740993')))).not.toThrow();

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Weak test assertion</b></div>
   <div id="fix">
   
   This test only asserts `.not.toThrow()`, so it passes even if the formatter 
returns a wrong string. The sibling SI test at line 116 asserts its exact 
output, and every existing test in this file (lines 35, 43, 85, 94, 99) asserts 
concrete values. Per the repo rule on asserting behavior logic in tests, assert 
the formatted result of `createD3NumberFormatter({ formatString: ',.2f' })` 
instead of only checking for absence of an exception.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #6089c6</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
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]

Reply via email to