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: string aggregation is incorrect in PivotTableV2 #19102

Conversation

diegomedina248
Copy link
Contributor

SUMMARY

The aggregation functions for PivotTableV2 only take into account numeric values.
This PR adds support for strings, only for the aggregation functions that were supported on PivotTable originally.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screen.Recording.2022-03-10.at.12.53.11.mov

TESTING INSTRUCTIONS

Follow the example described in the issue

ADDITIONAL INFORMATION

Fixes #18572

  • 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

@diegomedina248 diegomedina248 force-pushed the fix/stirng-aggregation-incorrect-pivot-v2 branch from a4865a1 to e4bed2d Compare March 15, 2022 17:52
@rusackas rusackas requested a review from kgabryje March 16, 2022 05:01
@@ -353,7 +370,7 @@ const baseAggregatorTemplates = {
throw new Error('unknown mode for runningStat');
}
},
format: formatter,
format: x => (typeof x === 'string' ? x : formatter(x)),
Copy link
Member

Choose a reason for hiding this comment

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

Nit: since we do the same operation in line 241, could you extract that logic to a function?

Copy link
Member

@kgabryje kgabryje left a comment

Choose a reason for hiding this comment

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

Added 1 minor comment. Looks great!

Copy link
Member

@kgabryje kgabryje left a comment

Choose a reason for hiding this comment

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

Just noticed 1 issue - selecting Median results in returning nulls
image

Also, selecting List unique values or Sum as fraction of total returns NaNs

@diegomedina248
Copy link
Contributor Author

Just noticed 1 issue - selecting Median results in returning nulls image

Also, selecting List unique values or Sum as fraction of total returns NaNs

@kgabryje I only made the changes for the ones present in v1. Can make it for all options if you're ok with it.

@diegomedina248 diegomedina248 force-pushed the fix/stirng-aggregation-incorrect-pivot-v2 branch from e4bed2d to 2d2df68 Compare April 6, 2022 00:05
@diegomedina248 diegomedina248 force-pushed the fix/stirng-aggregation-incorrect-pivot-v2 branch from 2d2df68 to c049209 Compare May 3, 2022 01:19
@codecov
Copy link

codecov bot commented May 3, 2022

Codecov Report

Merging #19102 (7729197) into master (1fa841e) will increase coverage by 0.00%.
The diff coverage is 16.27%.

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

@@           Coverage Diff           @@
##           master   #19102   +/-   ##
=======================================
  Coverage   66.51%   66.52%           
=======================================
  Files        1715     1715           
  Lines       65060    65076   +16     
  Branches     6723     6723           
=======================================
+ Hits        43272    43289   +17     
  Misses      20076    20076           
+ Partials     1712     1711    -1     
Flag Coverage Δ
javascript 51.24% <0.00%> (-0.03%) ⬇️

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

Impacted Files Coverage Δ
...ns/legacy-plugin-chart-heatmap/src/controlPanel.ts 66.66% <ø> (ø)
.../legacy-plugin-chart-histogram/src/controlPanel.ts 60.00% <ø> (ø)
...gins/legacy-preset-chart-nvd3/src/NVD3Controls.tsx 100.00% <ø> (ø)
...frontend/plugins/plugin-chart-echarts/src/types.ts 100.00% <ø> (ø)
...hart-pivot-table/src/react-pivottable/utilities.js 0.00% <0.00%> (ø)
superset/db_engine_specs/base.py 88.35% <0.00%> (ø)
superset/utils/cache.py 75.00% <ø> (ø)
superset/models/core.py 89.33% <50.00%> (ø)
superset/views/core.py 77.06% <50.00%> (ø)
superset/datasets/dao.py 93.79% <100.00%> (ø)
... and 10 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 1fa841e...c049209. Read the comment docs.

@yousoph
Copy link
Member

yousoph commented May 13, 2022

@kgabryje can you re-review this when you get a chance? thanks!

Copy link
Member

@kgabryje kgabryje left a comment

Choose a reason for hiding this comment

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

Lgtm, thanks for the fix... and sorry for a very late review

@rusackas rusackas merged commit 22b7496 into apache:master May 23, 2022
philipher29 pushed a commit to ValtechMobility/superset that referenced this pull request Jun 9, 2022
* fix: string aggregation is incorrect in PivotTableV2

* cleanup

* fix

* updates
@mistercrunch mistercrunch added 🏷️ 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 size/M 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PivotTable vs PivotTableV2. String aggregation is incorrect in PivotTableV2
5 participants