You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/07/22 08:19:57 UTC

[GitHub] [incubator-superset] villebro opened a new pull request #10389: [WIP] fix: support non-numeric columns in pivot table

villebro opened a new pull request #10389:
URL: https://github.com/apache/incubator-superset/pull/10389


   ### SUMMARY
   Adds support for non-numeric metrics in pivot table. Since only `min` and `max` aggregation works for non-numeric dtypes in Pandas, choosing any other aggregator will default to `max`.
   
   WIP: requires bumping pivot table plugin when new version deployed: https://github.com/apache-superset/superset-ui/pull/695
   
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### BEFORE
   ![image](https://user-images.githubusercontent.com/33317356/88148193-ec076880-cc06-11ea-84de-abe58570be5d.png)
   
   ### AFTER
   ![image](https://user-images.githubusercontent.com/33317356/88148109-ce3a0380-cc06-11ea-952c-8037ad3f0c3b.png)
   
   ### TEST PLAN
   <!--- What steps should be taken to 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:
   - [ ] Changes UI
   - [ ] Requires DB Migration.
   - [ ] Confirm DB Migration upgrade and downgrade tested.
   - [ ] 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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] villebro commented on pull request #10389: [WIP] fix: support non-numeric columns in pivot table

Posted by GitBox <gi...@apache.org>.
villebro commented on pull request #10389:
URL: https://github.com/apache/incubator-superset/pull/10389#issuecomment-664809300


   Thanks @mistercrunch; broke out function and added unit tests


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] mistercrunch commented on a change in pull request #10389: [WIP] fix: support non-numeric columns in pivot table

Posted by GitBox <gi...@apache.org>.
mistercrunch commented on a change in pull request #10389:
URL: https://github.com/apache/incubator-superset/pull/10389#discussion_r459197658



##########
File path: superset/viz.py
##########
@@ -771,22 +783,29 @@ def get_data(self, df: pd.DataFrame) -> VizData:
         if self.form_data.get("granularity") == "all" and DTTM_ALIAS in df:
             del df[DTTM_ALIAS]
 
-        aggfunc = self.form_data.get("pandas_aggfunc") or "sum"
-
-        # Ensure that Pandas's sum function mimics that of SQL.
-        if aggfunc == "sum":
-            aggfunc = lambda x: x.sum(min_count=1)
+        metrics = [utils.get_metric_name(m) for m in self.form_data["metrics"]]
+        aggfuncs: Dict[str, Union[str, Callable]] = {}
+        for metric in metrics:

Review comment:
       Would be nice to break this out into a functional method and adding unit tests for it




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] villebro merged pull request #10389: feat: support non-numeric columns in pivot table

Posted by GitBox <gi...@apache.org>.
villebro merged pull request #10389:
URL: https://github.com/apache/incubator-superset/pull/10389


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org