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

Scheduled query executions fail when a query uses dynamic date range parameters #4514

Open
susodapop opened this issue Dec 30, 2019 · 10 comments · May be fixed by #6960
Open

Scheduled query executions fail when a query uses dynamic date range parameters #4514

susodapop opened this issue Dec 30, 2019 · 10 comments · May be fixed by #6960

Comments

@susodapop
Copy link
Contributor

Issue Summary

Since dynamic date ranges are evaluated in the front-end, scheduled executions fail without warning or notice.

Steps to Reproduce

  1. Write a query with a date range parameter
  2. Configure the date range parameter to use a dynamic value
  3. Execute the query and note its last execution time
  4. Schedule the query to execute within a reasonable time (60 seconds e.g.)
  5. After the time allotted, observe that the last executed time has not updated

I expect the interface to warn about this behavior. Ideally, we can perform the calculation in the back-end so that scheduled executions can work.

Technical details:

  • Redash Version: v9 alpha
  • Browser/OS: FF / Chrome / Safari
  • How did you install Redash: SaaS
@susodapop susodapop changed the title Scheduled query executiosn fail when a query uses dynamic date range parameters Scheduled query executions fail when a query uses dynamic date range parameters Dec 30, 2019
@wtfzambo
Copy link

wtfzambo commented Apr 9, 2020

Yup, encountered this problem just today. Using a self hosted version of redash.
Any idea of a potential workaround that I can easily implement to circumvent this?

@susodapop
Copy link
Contributor Author

My workaround uses the API. The example here does it, including dynamic dates.

@wtfzambo
Copy link

@susodapop
Hi, thanks for the reply. I've checked the repo you linked but I'm a bit lost.

Could you elaborate a bit more in depth how to implement the toolbelt? I'm working on a self hosted instance but the selfhosting itself was made by my company's developer, so I have zero clue what that implies.

@susodapop
Copy link
Contributor Author

@wtfzambo I'm fixing a couple issues with that script. Will follow-up with you once completed.

@susodapop
Copy link
Contributor Author

@wtfzambo I made an example using refresh_dashboard.py. It updates a whole dashboard of queries.

But you can borrow the logic to make a single query updater or whatever you need. This doesn't require you to have admin access to the Redash instance. All you need is your API key (as shown in the video).

@wtfzambo
Copy link

@susodapop yo, thanks a lot for taking the time to make this video, it was really explanatory.
I am actually admin, but I thought I needed to edit some things in the docker and I don't have access to that (nor would I know tf to do anyway).

So, given that I host my redash inside a VPC in AWS, I guess to make this run on a daily basis I need to make a lambda function inside the same VPC and schedule a cloudwatch event to trigger said lambda. Would that work?

@susodapop
Copy link
Contributor Author

@wtfzambo You could do that. I usually just add a cron job.

@wtfzambo
Copy link

@susodapop a cron job where? in the redash instance itself?

@susodapop
Copy link
Contributor Author

@wtfzambo You can run the cron job on any box that has network access to your Redash instance. It can be your laptop, a raspberry pi, a docker container on your NAS or server, a VPS somewhere (kinda like your cloudwatch instance).

I usually run them on a raspberry pi. Entirely up to you.

You probably wouldn't run it in the Redash Docker container though, since updates down the road might blow away your settings.

@wtfzambo
Copy link

wtfzambo commented Apr 17, 2020

@susodapop aaaah ok! Sorry for the stupid question, I was confused at first because since I'm operating for a business, I would never have considered running a cron on my personal laptop or a raspberry pi :D

@ehooi ehooi linked a pull request May 10, 2024 that will close this issue
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants