I'm using Python3.6 on MacOS High Sierra. When using the query API, I cannot retrieve cached results for a query if it has parameters.
/api/queries/<dummy_query_id>/results.csv and everything is fine{'message': 'No cached result found for this query. You have requested this URI [/api/queries/364/results.csv] but did you mean /api/query_results or /api/queries/<query_id>/refresh or /api/query_results/<query_result_id> ?'}Thank yuo, @cinspire93. Is there a reason you've closed this without other comments? Did you get it to work?
Hi Richard, I have gotten it to work with a workaround indeed. That said, I guess a new suggestion would be adding the ability to query for cached results even if a query has parameters. We have some pipelines internally that could benefit a lot from the speed that comes with Redash's cached results.
Thanks, @cinspire93. I'm not sure if that is an issue yet. Let's keep this open; if it is a duplicate, we can close it, but if not, it'll be a good placeholder to remind us that. Sound good?
Hi Richard, sorry for the terribly late reply. Your suggestion sounds good. It is definitely not breaking anything for us, so let's just keep an eye on this. Thanks for looking into it!
@cinspire93 can you share some details on your workaround?
I'm hitting the same problem. The reason seems to be: https://github.com/getredash/redash/blob/1a75d490417ebb5cb1bf175f78904bef7962e6ab/redash/handlers/query_results.py#L199
As the query_hash of a query with parameters will never be equal to the query_hash of its query_results.
As defined here: https://github.com/getredash/redash/blob/1a75d490417ebb5cb1bf175f78904bef7962e6ab/redash/handlers/query_results.py#L41
The query_hash of a query_result contains the rendered query parameters, while the query_hash of the query is calculated on without the rendered query parameters.
Perhaps I should rephrase it... my solution not necessarily a workaround because it did not manage to get cached results when there's a parameter present in the query. If the query has a parameter, I will have to refresh it, poll job and get output by query_result_id.
We've started a project to redo permissions in Redash, which will also address this use case. To follow along you can watch #3284.
What is the actual resolution for this when just using the HTTP URL?
Most helpful comment
Hi Richard, I have gotten it to work with a workaround indeed. That said, I guess a new suggestion would be adding the ability to query for cached results even if a query has parameters. We have some pipelines internally that could benefit a lot from the speed that comes with Redash's cached results.