You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/11/01 21:08:00 UTC

[GitHub] [superset] justinpark opened a new pull request, #21996: fix: invalid float number format by json-bigint

justinpark opened a new pull request, #21996:
URL: https://github.com/apache/superset/pull/21996

   ### SUMMARY
   
   In #21968, it replaces the `json-bigint` by `json-bigint-native` to fix the invalid float number handling by escaping BigNumber(BigInt) wrapper.
   However, `json-bigint-native` uses native BigInt only which has limit compatibility of Math functions that throws [TypeError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_convert_BigInt_to_number) several cases.
   
   This commit reverts the commit in order to keep it back to use `BigNumber` (which is compatible with Math functions).
   Instead it adds a custom logic to escape the BigNumber for floating numbers. It also adds a `todo` comment to fix the root cause by open source in the future.
   
   cc: @john-bodley @ktmud @villebro @zhaoyongjie 
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Before: (returns NaN values)
   
   ![saft-p-90-guest-active-topline-trend-2022-10-28T19-10-08_622Z](https://user-images.githubusercontent.com/1392866/198724457-5618f7c5-61b1-4fc4-9c3f-1cabd9813086.jpg)
   
   After:
   
   ![saft-p-90-guest-active-topline-trend-2022-10-28T19-10-14_909Z](https://user-images.githubusercontent.com/1392866/198724363-5d2a6a77-94aa-4868-a1fe-7225919137b5.jpg)
   
   ### TESTING INSTRUCTIONS
   Create a chart with floating numbers
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] ktmud commented on a diff in pull request #21996: fix: invalid float number format by json-bigint

Posted by GitBox <gi...@apache.org>.
ktmud commented on code in PR #21996:
URL: https://github.com/apache/superset/pull/21996#discussion_r1010907163


##########
superset-frontend/packages/superset-ui-core/src/connection/callApi/parseResponse.ts:
##########
@@ -16,10 +16,18 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import JSONbig from 'json-bigint-native';
+import JSONbig from 'json-bigint';
+import { cloneDeepWith } from 'lodash';
 
 import { ParseMethod, TextResponse, JsonResponse } from '../types';
 
+// eslint-disable-next-line consistent-return
+function parseFloatBigNumber(value: any) {
+  if (value?.isInteger?.() === false) {
+    return Number(value);
+  }
+}

Review Comment:
   Can we just inline this?
   
   
   ```ts
         // `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 instanceof BigNumber && !value.isInteger() ? Number(value) : value)
         )),
   ```



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley merged pull request #21996: fix: invalid float number format by json-bigint

Posted by GitBox <gi...@apache.org>.
john-bodley merged PR #21996:
URL: https://github.com/apache/superset/pull/21996


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org