EBoisseauSierra opened a new issue #15294: URL: https://github.com/apache/superset/issues/15294
I have been able to define custom time grains (e.g. 15-minute time buckets — cf. #15037), as per [the `config.py` instructions](https://github.com/apache/superset/blob/1.1/superset/config.py#L498-L522): ```python # Define how to compute the custom time buckets TIME_GRAIN_ADDON_EXPRESSIONS = { 'postgresql': { 'PT6H': "date_trunc('day', {col}) + date_trunc('hour', {col})::int / 6 * interval '6 h'", 'PT15M': "date_trunc('hour', {col}) + date_part('minute', {col})::int / 15 * interval '15 min'", }, } # Register these custom time grain TIME_GRAIN_ADDONS = { "PT6H": "6 hours", "PT15M": "15 minutes", } ``` My custom time grains are then sorted *after* the default time grains:  ### Expected results I would expect all time grains to be sorted by increasing duration. In the example above: […] * minute * 15 minutes * hour * 6 hours * day […] ### Actual results My custom time grains are sorted after any default ones. Their relative order is defined by the by `TIME_GRAIN_ADDON_EXPRESSIONS` keys' order, and not `TIME_GRAIN_ADDONS`'s ones. #### How to reproduce the bug 1. Define custom time grain in `superset_config.py`, as above, 2. Go to Explore / {any Time Series chart} 3. Click on the Time Grain dropdown menu. ### Environment - superset version: `superset 1.1.0` ### Checklist - [x] I have checked the superset logs for python stacktraces and included it here as text if there are any. - [x] I have reproduced the issue with at least the latest released version of superset. - [x] I have checked the issue tracker for the same issue and I haven't found one similar. -- 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: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
