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

Added average metric AVG() to default metrics #1413

Merged
merged 3 commits into from
Oct 26, 2016

Conversation

vera-liu
Copy link
Contributor

@vera-liu vera-liu commented Oct 24, 2016

Issue: #804

Done: Added avg to default metrics in models->SqlaTable

screen shot 2016-10-25 at 11 29 16 am
screen shot 2016-10-25 at 11 29 31 am

needs-review @bkyryliuk @mistercrunch

@vera-liu vera-liu mentioned this pull request Oct 24, 2016
@@ -1101,6 +1101,13 @@ def fetch_metadata(self):
metric_type='sum',
expression="SUM({})".format(quoted)
))
if dbcol.sum:
Copy link
Member

Choose a reason for hiding this comment

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

s/dbcol.sum/dbcol.avg ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm thinking that the condition for dbcol.sum and dbcol.avg are both dbcol.isnum, so it makes sense to use one variable, as long as there's a sum, there can be an avg metrics as well

Copy link
Member

Choose a reason for hiding this comment

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

dbcol.max and dbcol.min are also in similar relation.
@mistercrunch - should avg be a separate field in the TableColumn ?

Copy link
Member

Choose a reason for hiding this comment

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

I've talked to Max, please implement a separate checkbox for AVG metric.
User may not expect to add 2 metrics when setting the sum checkbox and will be tricky to explain him if you want to add avg metrics - please select sum.

@@ -1101,6 +1101,13 @@ def fetch_metadata(self):
metric_type='sum',
expression="SUM({})".format(quoted)
))
if dbcol.sum:
Copy link
Member

Choose a reason for hiding this comment

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

it would be great to have a unit test here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we have tests covering metrics/groupby of db queries? I was trying to look for them but didn't seem to exist core_tests.py

Copy link
Member

Choose a reason for hiding this comment

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

nope, you'll be a first one if you'll decide to do it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since it will be tests covering all metrics, I'll separate it to another PR ;)

@vera-liu
Copy link
Contributor Author

Added a new commit, making avg a column for SqlaTable and Druid class @bkyryliuk

@bkyryliuk
Copy link
Member

please fix the tests

@vera-liu vera-liu force-pushed the vliu_add_avg branch 2 times, most recently from 608e0e2 to 6f4c86c Compare October 25, 2016 18:41
@vera-liu
Copy link
Contributor Author

Added migration 😃 @bkyryliuk

@bkyryliuk
Copy link
Member

LGTM

@vera-liu vera-liu merged commit bb23685 into apache:master Oct 26, 2016
@vera-liu vera-liu deleted the vliu_add_avg branch November 1, 2016 19:00
@mohadelrezk
Copy link

mohadelrezk commented May 1, 2018

Hi,
I am using latest version of superset (0.24)
but average is not activated as a metric when I create a chart/slice from druid datasource

note: it is available when I load data from csv files directly

@mistercrunch
Copy link
Member

You have to create post-aggregations for averages on Druid.

zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 17, 2021
…apache#1413)

* Update SupersetClientClass.ts

* Update SupersetClientClass.ts

* add comment

* update test
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 24, 2021
…apache#1413)

* Update SupersetClientClass.ts

* Update SupersetClientClass.ts

* add comment

* update test
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 25, 2021
…apache#1413)

* Update SupersetClientClass.ts

* Update SupersetClientClass.ts

* add comment

* update test
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 26, 2021
…apache#1413)

* Update SupersetClientClass.ts

* Update SupersetClientClass.ts

* add comment

* update test
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.12.0 labels Feb 19, 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 🚢 0.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants