What's the meaning of metric and metrics in parameters?

186 views
Skip to first unread message

Yu Wang

unread,
May 24, 2017, 11:46:36 PM5/24/17
to airbnb_superset
Take the provided data "Birth_names" as example, in Slice Edit page, you have below
Parameters -->
"metric": "sum__num",
    "metrics": [
        "sum__sum_girls",
        "sum__sum_boys"
]
Commented as :"These parameters are generated dynamically when clicking the save or overwrite button in the explore view. This JSON object is exposed here for reference and for power users who may want to alter specific parameters."

And if I check birth_names.csv, I have"state,year,name,gender,num" columns; check birth_names.json, there is "ds,gender,name,num,state,sum_boys,sum_girls"
Check data/__init__.py, I found params = get_slice_json(... metrics = ['sum__sum_girls', 'sum__sum_boys']...). I guess this is where metrics parameter are added. But is this "sum__" a predefined prefix? Same for "avg__"? Can I define other metrics? What's the difference between metric and metrics?

And where is the explore view?

Thanks a lot for any comment.

Maxime Beauchemin

unread,
May 25, 2017, 1:03:06 AM5/25/17
to airbnb_superset
Hi Yu,

The metrics for a Table are defined in the UI. Click on the edit button on a table and look for the `Metrics` tab. You can click on the checkboxes in the `Columns` tab (say sum/avg/min/max) and save the table to have new metrics created automatically, or manually enter new metrics as SQL expression under the `Metrics` tab. There's a some related information/screenshots here:

For the examples, as you found out, the table entries are created programmatically in `data/__init__.py`

We're planning on re-writing the whole datasource management/configuration portion of Superset soon. It currently works alright but the UX is not great at all.

Max

Yu Wang

unread,
May 25, 2017, 2:14:54 AM5/25/17
to airbnb_superset
Thanks Max,
  Yes, I did manipulate "List Sql Metric" a little bit. But the default metrics list is not exactly same as what written in load_*() function.  I guess this is my main confusion.

  For example, in birth_names table, I saw explicitly that you added "sum__sum_boys" and "sum__sum_girls" metrics but it turns out "avg__" are added automatically, which I can't find in data/__init__.py. And, as in the "List Sql Metric" view, when you want to add one metric, you'll need to enter the "SQL Expression". But somehow in __init__.py, I can't find this step. 

  And data/__init__.py "Slice(...)" code looks quite match to "Edit Slice" view. And as I mentioned, there was a "Parameters" box where user can enter "metrics" too. I may need to try it out to see how the "List Sql Metric"->"Add" action interacts with "Edit Slice"->Parameter edit.

Thanks a lot for the response. I guess now I understand it better now.

Yu Wang

unread,
May 25, 2017, 5:14:41 AM5/25/17
to airbnb_superset
One use case is that for example I have 1000+ metrics and 1000+filters and 1000+group by to add, manual work would be not possible. So a helper script would be greatly improve production. Or is there other method to do batch operations?

Maxime Beauchemin

unread,
May 30, 2017, 12:48:23 PM5/30/17
to airbnb_superset
Sounds like your best will be to take the programatic approach and do something similar to what we do in `data/__init__.py`

Max

Yu Wang

unread,
May 31, 2017, 1:28:56 AM5/31/17
to airbnb_superset
Since you say so. I guess it's the best shot. More time will be spent on that then :)
Reply all
Reply to author
Forward
0 new messages