-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Change query_hash calculation method with separate params #6960
base: master
Are you sure you want to change the base?
Conversation
161e0ae
to
d479136
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6960 +/- ##
==========================================
- Coverage 63.85% 63.84% -0.01%
==========================================
Files 161 161
Lines 13082 13095 +13
Branches 1811 1815 +4
==========================================
+ Hits 8353 8361 +8
- Misses 4429 4431 +2
- Partials 300 303 +3
|
Reckon this could be made automatic with a migration of some sort? |
Either migration or maybe some period of checking both hashes (old and new). |
I can't think of how a database migration would do this correctly. The technique I have been using is to use a script to POST an empty payload to force the server to recalculate hashes: for query in queries:
# Empty payload will still cause the query has to be re-calculated with default parameters applied
updated_query = redash.post(f"/api/queries/{query['id']}", data={}) |
…d parameters instead of final query.
Hmmm, this sounds like a pain, but perhaps a necessary one. Migration wise, hmmm. Seems like it needs to have some part of it Python driven (as @eradman mentions) as the database can't drive it purely using database functions. Does our Python migration framework not provide some existing capability for this? |
d479136
to
2d13628
Compare
I found a migration file. I wrote the migration code. It has no downgrade code. |
What type of PR is this?
Change query_hash calculation method.
Example
select c1, c2 from table where c3="{{ key }}"
Before:
After:
Description
I want to fundamentally fix #4514 #6063 #6683
I believe the problem lies in the dynamic date(-range) parameters being evaluated on the frontend side.
Before evaluating dynamic params on the backend side, we need to separate query text and parameters.
This is a breaking change. All query hashes will be changed.
You will need to re-save and execute all scheduled queries once to be scheduled properly afterward.
How is this tested?
Related Tickets & Documents
#4514 #6063 #6683
Mobile & Desktop Screenshots/Recordings (if there are UI changes)