-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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(generic-axes): apply contribution before flatten #20077
fix(generic-axes): apply contribution before flatten #20077
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
prophetOperator(formData, baseQueryObject), | ||
], | ||
].filter(op => op), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! The filter should apply in a separate PR and apply in all post operators.
Codecov Report
@@ Coverage Diff @@
## master #20077 +/- ##
=======================================
Coverage 66.37% 66.38%
=======================================
Files 1715 1715
Lines 64179 64180 +1
Branches 6753 6753
=======================================
+ Hits 42602 42603 +1
Misses 19859 19859
Partials 1718 1718
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
(cherry picked from commit d5802f7)
(cherry picked from commit d5802f7)
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. Also, in the case of using a numeric index, applying the contribution calculation after flattening would cause the index to leak into the contribution calculation. In addition to the fix, falsy post transformation ops are removed to clean up the request payload (these cause unnecessary cache misses).
There is already a check that should remove any non-numeric columns:
superset/superset/utils/pandas_postprocessing/contribution.py
Line 51 in 4435e53
However, for some reason this currently also returns string-columns (
object
), possibly due to theDecimal
type extendingobject
(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:BEFORE
Previously it would fail:
TESTING INSTRUCTIONS
GENERIC_CHART_AXES
feature flagADDITIONAL INFORMATION