sadpandajoe commented on code in PR #42594:
URL: https://github.com/apache/superset/pull/42594#discussion_r3684821931


##########
superset-frontend/plugins/plugin-chart-echarts/test/utils/series.test.ts:
##########
@@ -694,6 +695,39 @@ describe('extractGroupbyLabel', () => {
   });
 });
 
+describe('extractDataTotalValues', () => {
+  test('sums numeric metric values across a stacked datum', () => {
+    const { totalStackedValues, thresholdValues } = extractDataTotalValues(
+      [{ __timestamp: '2000-01-01', metric_a: 10, metric_b: 20 }],
+      { stack: true, percentageThreshold: 50, xAxisCol: '__timestamp' },
+    );
+    expect(totalStackedValues).toEqual([30]);
+    expect(thresholdValues).toEqual([15]);
+  });
+
+  // Regression for #36401: query results containing integers beyond
+  // Number.MAX_SAFE_INTEGER are parsed as native BigInt (see
+  // packages/superset-ui-core/src/connection/callApi/parseResponse.ts).
+  // Summing a BigInt datum value against the Number accumulator here
+  // throws instead of producing a stacked total.
+  test('does not throw when a stacked datum contains a BigInt metric value', 
() => {
+    const data: DataRecord[] = [
+      {
+        __timestamp: '2000-01-01',
+        metric_a: 10,
+        metric_b: BigInt('9007199254740993'),
+      },
+    ];
+    expect(() =>
+      extractDataTotalValues(data, {
+        stack: true,
+        percentageThreshold: 50,
+        xAxisCol: '__timestamp',
+      }),
+    ).not.toThrow();

Review Comment:
   This test deterministically fails against the unchanged 
`extractDataTotalValues` implementation, so the required Jest shard is red and 
this PR cannot close #36401 as written. Could the production normalization fix 
be included so the regression test passes?



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