You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by jl...@apache.org on 2025/06/11 23:53:34 UTC
(superset) 01/03: fix(table-chart): time shift is not working (#33425)
This is an automated email from the ASF dual-hosted git repository.
jli pushed a commit to branch 4.1
in repository https://gitbox.apache.org/repos/asf/superset.git
commit df86bef65e233a5ac2d9504bbf32f99814431c52
Author: JUST.in DO IT <ju...@airbnb.com>
AuthorDate: Wed May 14 10:19:21 2025 -0700
fix(table-chart): time shift is not working (#33425)
(cherry picked from commit dc4474889d84c258b94228d31017bef71117cd32)
---
.../src/connection/callApi/parseResponse.ts | 20 +++++++++++++++-----
.../test/connection/callApi/parseResponse.test.ts | 3 ++-
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/superset-frontend/packages/superset-ui-core/src/connection/callApi/parseResponse.ts b/superset-frontend/packages/superset-ui-core/src/connection/callApi/parseResponse.ts
index 52dc348084..4ee81b80b3 100644
--- a/superset-frontend/packages/superset-ui-core/src/connection/callApi/parseResponse.ts
+++ b/superset-frontend/packages/superset-ui-core/src/connection/callApi/parseResponse.ts
@@ -57,11 +57,21 @@ export default async function parseResponse<T extends ParseMethod = 'json'>(
const json = JSONbig.parse(rawData);
const result: JsonResponse = {
response,
- // `json-bigint` could not handle floats well, see sidorares/json-bigint#62
- // TODO: clean up after json-bigint>1.0.1 is released
- json: cloneDeepWith(json, (value: any) =>
- value?.isInteger?.() === false ? Number(value) : undefined,
- ),
+ json: cloneDeepWith(json, (value: any) => {
+ if (
+ value?.isInteger?.() === true &&
+ (value?.isGreaterThan?.(Number.MAX_SAFE_INTEGER) ||
+ value?.isLessThan?.(Number.MIN_SAFE_INTEGER))
+ ) {
+ return BigInt(value);
+ }
+ // // `json-bigint` could not handle floats well, see sidorares/json-bigint#62
+ // // TODO: clean up after json-bigint>1.0.1 is released
+ if (value?.isNaN?.() === false) {
+ return value?.toNumber?.();
+ }
+ return undefined;
+ }),
};
return result as ReturnType;
}
diff --git a/superset-frontend/packages/superset-ui-core/test/connection/callApi/parseResponse.test.ts b/superset-frontend/packages/superset-ui-core/test/connection/callApi/parseResponse.test.ts
index b08b5b8cb8..29f3ab4fe5 100644
--- a/superset-frontend/packages/superset-ui-core/test/connection/callApi/parseResponse.test.ts
+++ b/superset-frontend/packages/superset-ui-core/test/connection/callApi/parseResponse.test.ts
@@ -141,7 +141,7 @@ describe('parseResponse()', () => {
const mockBigIntUrl = '/mock/get/bigInt';
const mockGetBigIntPayload = `{
"value": 9223372036854775807, "minus": { "value": -483729382918228373892, "str": "something" },
- "number": 1234, "floatValue": { "plus": 0.3452211361231223, "minus": -0.3452211361231223 },
+ "number": 1234, "floatValue": { "plus": 0.3452211361231223, "minus": -0.3452211361231223, "even": 1234567890123456.0000000 },
"string.constructor": "data.constructor",
"constructor": "constructor"
}`;
@@ -159,6 +159,7 @@ describe('parseResponse()', () => {
expect(responseBigNumber.json.floatValue.minus).toEqual(
-0.3452211361231223,
);
+ expect(responseBigNumber.json.floatValue.even).toEqual(1234567890123456);
expect(
responseBigNumber.json.floatValue.plus +
responseBigNumber.json.floatValue.minus,