Most of the time, parameters have a few valid inputs that you’d like to choose from. It’d be nice to allow a select input for parameters.
I think at first having simple per-parameter configuration would be best, but maybe down the road it would useful to either allow query results to be in the select or have a way to update multiple query enums at once.
I had very similar thoughts about this. I was actually thinking to start from implementing support for loading values for the parameter from a query, as it serves both use cases. While it’s cucumbersome, you can implement the static list as a “static” query:
SELECT 1 as value, 'V1' as name
UNION ALL
SELECT 2 as value, 'V2' as name
...
But you’re welcome to implement the “enum” first as I believe from implementation point of view, it will be easier.
This along with the global/dashboard parameters, keep leading me to the idea of having a dedicated place in Redash to define parameters. So you can have definitions for parameters in one place, which you can reuse in queries. This way you need to define if a parameter is global only once, or edit the enum only once.
The user should still be able to define an “adhoc” parameter in a query, but he can also choose from existing ones.
I do like the idea of configurating parameters only once, I’m not exactly sure how the linking bit between queries and parameters would work. But this idea of 1st class parameters is what I was eventually getting at.
What do you think about changing the parameter type to ‘Query’ in the parameter settings page, and then you get a dropdown (w/ autocomplete) of queries to pick from? I think that is more explicit and should help with feature discovery, then you can use any query that you’ve already made to do this.
Also how would refreshing the query work? Would it have to be a scheduled query to be updated, or should there be an explict refresh button the parameter settings.
Now I read again and realized that by “linking parameters to queries” we were talking about different things… in the context of linking parameter to query for values, the way you described it is exactly what I had in mind.
I think it’s reasonable to expect the user to set a refresh schedule if it’s needed.
Currently you can only add a static drop-down list. I have been planning on adding this to redash, but am waiting for another PR to be merged first. If you’d like to contribute this, feel free!
@rockwotj sure, I’d love to help. Mind pointing me to the PR that needs to be merged first and also roughly what parts of the code I would need to touch? Thanks!