villebro opened a new pull request, #20077: URL: https://github.com/apache/superset/pull/20077
### SUMMARY Currently the contribution operation is applied after flattening, despite only being meant to apply to numeric columns. By ensuring that the dataframe is unflattened, the index columns will always be absent from the columns, which ensures that the index is not used in the contribution calculation. In addition, falsy post transformation ops are removed to clean up the request payload. There is already a check that should remove any non-numeric columns: https://github.com/apache/superset/blob/4435e53901df4d64992a540694fbd3d5489c2220/superset/utils/pandas_postprocessing/contribution.py#L51 However, for some reason this currently also returns string-columns (`object`), possibly due to the `Decimal` type extending `object` (seems weird, I know, but the only reason I could come up with). However, I didn't want to make any changes to this logic in this PR, as refining it will probably require additional tests to be added + we should potentially bump Pandas to 1.4 before changing this. ### AFTER Now calculating contributions works when `GENERIC_CHART_AXES` enabled: <img width="1281" alt="image" src="https://user-images.githubusercontent.com/33317356/168591012-563cf83e-44fd-4c19-839d-4d1e363b2f31.png"> ### BEFORE Previously it would fail: <img width="1276" alt="image" src="https://user-images.githubusercontent.com/33317356/168591129-f8f1f0eb-c898-41b9-8c26-689884498516.png"> ### TESTING INSTRUCTIONS <!--- Required! What steps can be taken to manually verify the changes? --> ### ADDITIONAL INFORMATION <!--- Check any relevant boxes with "x" --> <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue --> - [ ] 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
