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: Box Plot Chart throws an error when the average (AVG) / SUM is being calculated on the Metrics #20235

Conversation

diegomedina248
Copy link
Contributor

SUMMARY

When creating a Box Plot Chart, users can set aggregations on the column(s) that will be applied on the Metrics field. However, if the Average aggregation function is set, the Chart won't load and below error message will be displayed:

ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

This may be triggered by:
Issue 1011 - Superset encountered an unexpected error.

The issue is that the boxplot post processing function uses, for most of their operators, the nanpercentile function.
That function won't work on objects, which is the data type for bigints in postgresql.
By coercing the type to it's numeric form we get rid of that issue.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:

Screen.Recording.2022-06-01.at.20.28.19.mov

After:

new.mov

TESTING INSTRUCTIONS

  1. Access your Workspace.
  2. Navigate to Charts.
  3. Click on the + CHART button in the top right corner to create a new Chart.
  4. Choose the Flights Dataset, and the Box Plot Chart.
  5. Click on CREATE NEW CHART button.
  6. Click on the Metrics pop up.
  7. Switch to the SIMPLE tab.
  8. Select the FLIGHT_NUMBER column.
  9. Set the AVG aggregation.
  10. Click on SAVE.
  11. Click on RUN.

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

@pull-request-size pull-request-size bot added size/M and removed size/XS labels Jun 2, 2022
@codecov
Copy link

codecov bot commented Jun 2, 2022

Codecov Report

Merging #20235 (287d02a) into master (c8fe518) will decrease coverage by 11.90%.
The diff coverage is 56.81%.

❗ Current head 287d02a differs from pull request most recent head d46bd78. Consider uploading reports for the commit d46bd78 to get more accurate results

@@             Coverage Diff             @@
##           master   #20235       +/-   ##
===========================================
- Coverage   66.47%   54.56%   -11.91%     
===========================================
  Files        1727     1726        -1     
  Lines       64724    64782       +58     
  Branches     6822     6828        +6     
===========================================
- Hits        43024    35349     -7675     
- Misses      19969    27698     +7729     
- Partials     1731     1735        +4     
Flag Coverage Δ
hive 53.68% <40.38%> (-0.02%) ⬇️
mysql ?
postgres ?
presto 53.54% <40.38%> (-0.02%) ⬇️
python 58.02% <65.38%> (-24.62%) ⬇️
sqlite ?
unit 50.00% <55.76%> (+0.54%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ugins/legacy-plugin-chart-sunburst/src/Sunburst.js 0.00% <0.00%> (ø)
...s/legacy-plugin-chart-sunburst/src/controlPanel.ts 20.00% <0.00%> (-80.00%) ⬇️
superset-frontend/src/SqlLab/actions/sqlLab.js 60.50% <ø> (ø)
...ontend/src/SqlLab/components/QuerySearch/index.tsx 73.07% <ø> (ø)
...rontend/src/SqlLab/components/QueryTable/index.tsx 70.17% <ø> (ø)
superset-frontend/src/SqlLab/reducers/sqlLab.js 33.15% <ø> (ø)
...erset-frontend/src/components/Chart/chartAction.js 55.26% <ø> (ø)
...rset-frontend/src/components/Chart/chartReducer.ts 25.00% <ø> (ø)
...erset-frontend/src/components/EmptyState/index.tsx 76.19% <ø> (ø)
superset-frontend/src/components/Timer/index.tsx 78.94% <ø> (ø)
... and 315 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c8fe518...d46bd78. Read the comment docs.

Copy link
Member

@zhaoyongjie zhaoyongjie left a comment

Choose a reason for hiding this comment

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

Thanks for the fixing. LGTM

@zhaoyongjie zhaoyongjie merged commit 8638f59 into apache:master Jun 2, 2022
philipher29 pushed a commit to ValtechMobility/superset that referenced this pull request Jun 9, 2022
…eing calculated on the Metrics (apache#20235)

* fix: Box Plot Chart throws an error when the average (AVG) / SUM is being calculated on the Metrics

* add test
michael-s-molina pushed a commit that referenced this pull request Aug 30, 2022
…eing calculated on the Metrics (#20235)

* fix: Box Plot Chart throws an error when the average (AVG) / SUM is being calculated on the Metrics

* add test

(cherry picked from commit 8638f59)
@mistercrunch mistercrunch added 🍒 1.5.2 🍒 1.5.3 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.0.0 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 Preset-Patch size/M 🍒 1.5.2 🍒 1.5.3 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants