redash icon indicating copy to clipboard operation
redash copied to clipboard

Query results query parameters

Open ehearty opened this issue 3 years ago • 1 comments

What type of PR is this?

  • [ ] Refactor
  • [ X ] Feature
  • [ ] Bug Fix
  • [ ] New Query Runner (Data Source)
  • [ ] New Alert Destination
  • [ ] Other

Description

Modified the Query Results query runner to allow for the passing of query parameters. Should be 100% backward compatible.

The Query Results query runner can now pass query parameters using the following format:

param_query_<query_id>_{<URL ENCODED KEY=VALUE PARAMETER STRING>}

The format above should hopefully be intuitive for users as it uses a prefix to denote the query type, much like the "cached" prefix denotes caches queries.

The temporary tables created for each parameterized query will be unique baed on the hashed value of the query id + parameters, so it is possible to reuse the same query more than once and select for different results based on the values supplied.

Example:

Query 1: image

Query 2: image

Query 3 (example calling parameterized, cached, and non-parameterized queries): image

How is this tested?

  • [ X ] Unit tests (pytest, jest)
  • [ ] E2E Tests (Cypress)
  • [ ] Manually
  • [ ] N/A

Related Tickets & Documents

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

ehearty avatar Mar 21 '22 23:03 ehearty

This would be an excellent addition to the existing QRDS support and help to avoid having to do too much filtering in memory :pray:

lol768 avatar Sep 11 '22 17:09 lol768

This feature is awesome! I hope this pull request would be merged as soon as possible.

koty avatar Dec 07 '22 13:12 koty

Agreed this is an awesome feature addition. Hope this PR gets some attention soon!

sohil-k avatar Dec 16 '22 19:12 sohil-k

@ehearty , thanks for the PR! We've updated a lot of things now that we're Community-driven so - if you're still interested in getting this merged - would you mind rebasing off master to re-run the CI, as well as updating merge conflicts?

We're trying to clean up our PR todo list, so if you're not interested, that's fine - we'll close the PR in about a week if we don't hear back. If you're interested in reopening the PR afterwards, we would also very much welcome that.

guidopetri avatar Aug 20 '23 22:08 guidopetri

Codecov Report

Merging #5723 (0fc72b2) into master (1ef63fc) will increase coverage by 0.03%. Report is 1 commits behind head on master. The diff coverage is 64.51%.

@@            Coverage Diff             @@
##           master    #5723      +/-   ##
==========================================
+ Coverage   60.74%   60.77%   +0.03%     
==========================================
  Files         154      154              
  Lines       12628    12656      +28     
  Branches     1716     1721       +5     
==========================================
+ Hits         7671     7692      +21     
- Misses       4732     4739       +7     
  Partials      225      225              
Files Changed Coverage Δ
redash/query_runner/query_results.py 61.36% <64.51%> (+0.41%) :arrow_up:

... and 1 file with indirect coverage changes

codecov[bot] avatar Aug 24 '23 04:08 codecov[bot]

Cool, it's passed our CI tests.

@getredash/maintainers Anyone feel like reviewing this? It's Python only, and judging by the feedback icons on the request it seems like a few people are wanting it. :smile:

justinclift avatar Aug 24 '23 05:08 justinclift