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

[Dataset][Time filter] Allow setting a global or dataset-level default time range #13125

Closed
ktmud opened this issue Feb 15, 2021 · 13 comments
Closed
Assignees
Labels
data:databases Related to database configurations and connections enhancement:committed Enhancement planned / committed by a contributor explore:time Related to the time filters in Explore inactive Inactive for >= 30 days

Comments

@ktmud
Copy link
Member

ktmud commented Feb 15, 2021

Is your feature request related to a problem? Please describe.

Currently new charts are created with the default time range filter value set to "Last week". This may make sense for some businesses, but often cause confusion when users didn't notice this filter is being implicitly applied. Experienced users may even have learned the first thing they do when creating a new chart is to reset this to No filter (or whatever is the best for their dataset).

Describe the solution you'd like

It would be ideal if we can provide a global, as well as database and dataset-level settings on the default Time Range filter when creating a new chart. For dataset-level configuration, we may even allow it to be configurable for each datetime column.

We can start simple with global level configuration that each business can adjust for their own needs. In the future, in the spirit of doing less implicit things, we should probably also consider setting the default global config to "No filter".

Or we can focus on implementing the dataset level config, and set it as "Last week" for all existing datasets.

Describe alternatives you've considered

Simply changing the default to "No filter" may not be desired because time filters have impact on the performance of db queries and setting "No filter" as global default may cause undesired long running queries, especially when a chart start running new queries right after creation (e.g. table chart).

Additional context

Ref: #13109 (comment)

@ktmud ktmud added data:databases Related to database configurations and connections data:dataset:edit explore:time Related to the time filters in Explore labels Feb 15, 2021
@junlincc junlincc added the enhancement:committed Enhancement planned / committed by a contributor label Feb 15, 2021
@junlincc
Copy link
Member

I agree with this change - setting time range filter at the dataset-level. the reason we set filter to default "Last week" is to prevent users from running expensive explorational query. Not sure about changing default to"No filter" though, shouldn't we allow user to set default? or similar to ad-hoc filter, store value in local storage as user's own default?

@junlincc
Copy link
Member

#12542 related

@ktmud
Copy link
Member Author

ktmud commented Feb 17, 2021

@junlincc the idea IS to allow users to set default. I was just proposing we don't set the initial default. Once the global setting for default time filter is added, Superset may ship with the global config as "No filter" because it is the most neutral choice. It also forces organizations to pick a default value that makes the most sense to them.

We could also just focus on Dataset level settings and maybe make the default time range filter a required field when creating a new dataset.

(Updated the issue description to reflect these clarifications.)

@junlincc
Copy link
Member

junlincc commented Feb 17, 2021

We could also just focus on Dataset level settings and make the default time range filter a required field when creating a new dataset.

@ktmud
Will asking new users to setup default time range filter be too confusing at the first place? since the user need is coming from those who have been forced to switch range from "Last week" to "No Filter". Why not store users' own "default" at local storage?

@ktmud
Copy link
Member Author

ktmud commented Feb 17, 2021

I think remembering users' last selected time filter MAY work, but it doesn't solve the problem of the initial default "last week" not making sense to certain datasets (i.e. those who don't update every week). We still need a dataset-level default.

We can drop the idea of making it a required field as I imagine it'd be quite hard to implement a good UX for it---especially considering most virtual datasets are created from SQL Lab. Whether the global initial default is "Last week" or "No filter" is debatable, but I guess it doesn't matter much as long as there is a way to change it in Superset configs.

@junlincc
Copy link
Member

what about setting [max date -7, max date) of any dataset by default? @ktmud

@ktmud
Copy link
Member Author

ktmud commented Mar 15, 2021

That's a great idea, but I'm not sure how easy it is implement, though--both engineering and design-wise. We need a clean design to communicate this default value to users clearly, and it needs to be performant (which means there has to be some kind of cache, you can't just query what is the min/max date on the fly).

@junlincc
Copy link
Member

engineering wise, shouldn't be too hard. and if min and max dates in dataset can be detected, do we still need any configuration?

@villebro
Copy link
Member

I like the idea of being able to define a global default time range in superset_config.py (this would be the one e.g. the native filter defaults to), and then being able to override it per dataset.

@ktmud
Copy link
Member Author

ktmud commented Mar 17, 2021

@junlincc It's not easy engineering wise.

@zhaoyongjie zhaoyongjie self-assigned this Jun 3, 2021
@stale
Copy link

stale bot commented Apr 17, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

@stale stale bot added the inactive Inactive for >= 30 days label Apr 17, 2022
Usiel added a commit to Usiel/superset that referenced this issue Oct 20, 2022
Related to issue apache#13125

First change to complete apache#13125: We add a new configuration `DEFAULT_TIME_FILTER` to allow admins to set a global deafult time filter for any explore charts. By default this is set to `None`, which replicates the previous behavior. To get a default filter of -1w the configuration can be set to `'Last week'`.

There is a minor change in behavior `UPDATE_FORM_DATA_BY_DATASOURCE`, the time filter is not reset anymore (the time dimension does still). This is similar to the behavior of other globally configured filters such as the row limit for explore.
@Usiel
Copy link
Contributor

Usiel commented Oct 21, 2022

I was thinking about trying my luck with database and dataset overrides for the new global default time filter (#21879). Is this still something people are interested in, or have there been any inklings to go a different route?
Asking because this issue is slightly older and working on database/dataset overrides seems a bit more complex than the global configuration change I did.

@geido
Copy link
Member

geido commented Feb 12, 2024

Thanks to everyone who has contributed to the discussion. Closing this issue as it seems this should be accounted for in most recent versions of Superset.

@geido geido closed this as completed Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:databases Related to database configurations and connections enhancement:committed Enhancement planned / committed by a contributor explore:time Related to the time filters in Explore inactive Inactive for >= 30 days
Projects
None yet
Development

No branches or pull requests

6 participants