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

Order custom time grains by increasing duration #15294

Open
3 tasks done
EBoisseauSierra opened this issue Jun 22, 2021 · 0 comments
Open
3 tasks done

Order custom time grains by increasing duration #15294

EBoisseauSierra opened this issue Jun 22, 2021 · 0 comments

Comments

@EBoisseauSierra
Copy link
Task lists! Give feedback
Contributor

@EBoisseauSierra EBoisseauSierra commented Jun 22, 2021

I have been able to define custom time grains (e.g. 15-minute time buckets — cf. #15037), as per the config.py instructions:

# 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:

time_grain_shadow

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

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven't found one similar.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants