Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: invalid float number format by json-bigint #21996

Merged

Conversation

justinpark
Copy link
Member

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

After:

saft-p-90-guest-active-topline-trend-2022-10-28T19-10-14_909Z

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

if (value?.isInteger?.() === false) {
return Number(value);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just inline this?

      // `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)
      )),

@john-bodley john-bodley merged commit 3a02339 into apache:master Nov 2, 2022
john-bodley pushed a commit to airbnb/superset-fork that referenced this pull request Nov 2, 2022
john-bodley pushed a commit to airbnb/superset-fork that referenced this pull request Nov 2, 2022
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants