-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
feat(sqllab): save query parameters in database #21682
feat(sqllab): save query parameters in database #21682
Conversation
@mayurnewase I sometimes wonder what purpose query parameters have in SQL Lab, other than while developing virtual table queries that are meant to accept query parameters. Do you have a clear use case for persisting query params? It would be great to understand how this feature is usually leveraged in the wild. |
hi @villebro I have seen similar issue raised in the associated ticket. Do you think its worth saving it in the db? |
Hi, yes, I think the params should be persisted if they weren't previously if there's a clear use case for it. Personally I've just never really seen a very clear use case for query params in SQL Lab, but that may just be me and how I use SQL Lab. But IMO this PR looks good, so I'm happy to review/test when it's ready. |
Codecov Report
@@ Coverage Diff @@
## master #21682 +/- ##
==========================================
+ Coverage 66.82% 66.84% +0.01%
==========================================
Files 1799 1799
Lines 68830 68886 +56
Branches 7332 7320 -12
==========================================
+ Hits 45997 46047 +50
+ Misses 20953 20952 -1
- Partials 1880 1887 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice work @mayurnewase ! LGTM and tested to work as expected
endpoint: '/savedqueryviewapi/api/create', | ||
postPayload: convertQueryToServer(query), | ||
stringify: false, | ||
endpoint: '/api/v1/saved_query/', | ||
jsonPayload: convertQueryToServer(payload), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the migration to v1 API! 🚀
Thank you so much for adding this feature!! I was one of those who asked for that, because I had some complex jinja templated SQL query and I had trouble using the Native Dashboard filter to allow users to click and select the desired values for substitution. With your new feature, users can simply take the templated SQL, update the saved paramters and press RUN to get the output (as raw data without visualisation). THank you :))) Now I cannot wait until a new release is ready with your feature :)) |
Thanks @kenho811 for sharing your use case! And thanks again @mayurnewase for taking this on and doing a thorough cleanup of the related code + adding tests, really stellar work! |
This reverts commit 61319fd.
SUMMARY
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ENABLE_TEMPLATE_PROCESSING
flagSELECT '{{ p1 }}'
and set parameters{"p1": "value from params"}
value from params
ADDITIONAL INFORMATION