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

Provide re-usable building blocks for queries #328

Closed
mcomella opened this issue Feb 1, 2018 · 10 comments
Closed

Provide re-usable building blocks for queries #328

mcomella opened this issue Feb 1, 2018 · 10 comments

Comments

@mcomella
Copy link

mcomella commented Feb 1, 2018

As someone who doesn't use sql.tmo often, every time I write a query, I need to find a previously written query to do the same tasks over and over again. Examples:

  • Return all results < 6 months old
  • Format date in a certain way
  • Pull out data from list of DAUs/WAUs/MAUs

It'd be really great if there were reusable building blocks so every query didn't have to reproduce this functionality - think of it like functions for mozilla's redash!

@arikfr
Copy link

arikfr commented Feb 8, 2018

That's sort of what the query snippets are for... aren't they being used at Mozilla?

So query snippets will save you the trouble of finding and typing this all over again, but it won't update after you insert the snippet into the query.

@rafrombrc
Copy link
Member

@arikfr Apparently not. ;)

@mcomella Do query snippets meet your need, or do you have a use case that they don't satisfy?

@mcomella
Copy link
Author

@rafrombrc They look like they would, yes. However, I can't seem to find a way to access them through the sql.telemetry.mozilla.org interface.

@rafrombrc
Copy link
Member

@mcomella Sorry for the delay in replying... I got lost in some confusion re: the availability of query snippets, because I found a page (here: https://help.redash.io/article/39-query-snippets-shortcuts) that says only admins can create them. Our experimentation shows that this is incorrect, however, non-admins can create them.

If you click on your name in the upper right hand corner, click on your name in the dropdown menu, you should see a 'query snippets' tag that will take you to the interface. The help.redash.io page linked above should help you get started (incorrect availability information notwithstanding).

@mcomella
Copy link
Author

mcomella commented Mar 8, 2018

@rafrombrc Can query snippets be shared between users without copy/pasting then? As someone who infrequently uses re-dash, I think it'd be great to steal some snippets (like DAUs) from high frequency users on my team.

@rafrombrc
Copy link
Member

@mcomella Not sure. I just created a snippet called 'hll_convert' which contains the boilerplate for rendering a hyperloglog field as a numeric count value. Try typing 'hll_' when you're entering a query and see if it shows up as an auto-complete option for you.

@arikfr Also, I should draw your attention to the https://help.redash.io/article/39-query-snippets-shortcuts page which has inaccurate information about only admins being able to create query snippets. Is there a place to submit a bug for getting that page corrected?

@mcomella
Copy link
Author

mcomella commented Mar 8, 2018

Found it! :) How do we tell people to use it?

screen shot 2018-03-08 at 11 21 22

Caveat: I don't know if there's a way to search these query snippets without clicking through all the pages and doing find-in-page.

@rafrombrc
Copy link
Member

@mcomella Snippets work via the autocomplete mechanism that is in effect when you're creating and/or editing a query. Every snippet has a "trigger", if you type that trigger in while you're in the query editor you should see the snippet show up as an autocomplete suggestion. Select it from the autocomplete dropdown, and the snippet will be inserted where the cursor is. So if you type 'hll_' while you're in the query editor you should see the snippet show up and become usable.

Hope this helps!

@mcomella
Copy link
Author

So it does! Great! :)

Should we close this issue as WORKSFORME or perhaps there is an action item to publicize this?

@arikfr
Copy link

arikfr commented May 30, 2018

@arikfr Also, I should draw your attention to the https://help.redash.io/article/39-query-snippets-shortcuts page which has inaccurate information about only admins being able to create query snippets. Is there a place to submit a bug for getting that page corrected?

@rafrombrc I missed your original message, but happy to share that all the help pages sources are now on GitHub (here's the query snippets page).

I already updated this page and removed the note about admins.

Thanks!

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

No branches or pull requests

3 participants