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: improve pivot post-processing #16289

Merged
merged 3 commits into from
Aug 17, 2021
Merged

Conversation

betodealmeida
Copy link
Member

@betodealmeida betodealmeida commented Aug 17, 2021

SUMMARY

This PR fixes many cases when applying the pivot table post-processing.

I reimplemented the algorithm from scratch to make sure it matches the JS logic, testing as many combinations as I could and comparing the Python results with the JS visualization.

For each of those cases I added a unit test showing the pivot. The resulting table in each of the unit tests matches the table from the visualization.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

N/A

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

@codecov
Copy link

codecov bot commented Aug 17, 2021

Codecov Report

Merging #16289 (53b1379) into master (36bc7b0) will decrease coverage by 0.11%.
The diff coverage is 95.94%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16289      +/-   ##
==========================================
- Coverage   76.64%   76.53%   -0.12%     
==========================================
  Files         997      997              
  Lines       53246    53264      +18     
  Branches     6777     6777              
==========================================
- Hits        40808    40763      -45     
- Misses      12208    12271      +63     
  Partials      230      230              
Flag Coverage Δ
hive ?
mysql 81.62% <95.94%> (+0.06%) ⬆️
postgres 81.69% <95.94%> (+0.06%) ⬆️
python 81.77% <95.94%> (-0.22%) ⬇️
sqlite 81.33% <95.94%> (+0.06%) ⬆️

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

Impacted Files Coverage Δ
superset/charts/post_processing.py 94.17% <95.94%> (+17.70%) ⬆️
superset/db_engines/hive.py 0.00% <0.00%> (-82.15%) ⬇️
superset/db_engine_specs/hive.py 69.80% <0.00%> (-16.87%) ⬇️
superset/views/database/mixins.py 81.03% <0.00%> (-1.73%) ⬇️
superset/db_engine_specs/presto.py 83.47% <0.00%> (-1.05%) ⬇️
superset/db_engine_specs/base.py 88.00% <0.00%> (-0.39%) ⬇️
superset/connectors/sqla/models.py 88.04% <0.00%> (-0.24%) ⬇️
superset/utils/core.py 89.86% <0.00%> (-0.13%) ⬇️
superset/config.py 91.30% <0.00%> (ø)
superset/views/core.py 75.25% <0.00%> (ø)
... and 2 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 36bc7b0...53b1379. Read the comment docs.

]
parts: List[Any] = list(label)
metric = parts[-1]
parts[-1] = metrics.index(metric)
Copy link
Member

Choose a reason for hiding this comment

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

would it be more or less pythonic to pop and then push instead?

Copy link
Member

@eschutho eschutho left a comment

Choose a reason for hiding this comment

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

@betodealmeida walked me through this and it looks good. The tests are fantastic!

@betodealmeida betodealmeida merged commit ac8e54d into apache:master Aug 17, 2021
betodealmeida added a commit to preset-io/superset that referenced this pull request Aug 17, 2021
* fix: improve pivot post-processing

* Add tests

* Trim space from column name
@henryyeh
Copy link
Contributor

🏷️ 2021.31

henryyeh pushed a commit to preset-io/superset that referenced this pull request Aug 19, 2021
* fix: improve pivot post-processing

* Add tests

* Trim space from column name

(cherry picked from commit ac8e54d)
@PowerPlop
Copy link

@betodealmeida the new post processing seems to not export row headers when choosing the csv output?

postprocessing

@villebro villebro added the v1.3 label Sep 22, 2021
villebro pushed a commit that referenced this pull request Sep 22, 2021
* fix: improve pivot post-processing

* Add tests

* Trim space from column name

(cherry picked from commit ac8e54d)
@PowerPlop
Copy link

I see this one is tagged to be included in v1.3, but it seems to me that the missing headers is quite crucial for a csv export?

opus-42 pushed a commit to opus-42/incubator-superset that referenced this pull request Nov 14, 2021
* fix: improve pivot post-processing

* Add tests

* Trim space from column name
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 28, 2021
* fix: improve pivot post-processing

* Add tests

* Trim space from column name
@mistercrunch mistercrunch added 🍒 1.3.1 🍒 1.3.2 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 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:2021.31 size/XXL v1.3 🍒 1.3.1 🍒 1.3.2 🚢 1.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants