Feature idea: SQL snippet reveal button

Hey there!

I am really happy with using Metabase - great software and community!

Recently I updated to the latest version and now I am able to use the SQL snippets to shorten my code - they work perfectly!

I have a few things that concern me about them:

  1. I am writing big queries and right now I have a lot of SQL snippets inside my code. However, sometimes with having so many snippets you might get lost in your code. It would be great to add a button that would not remove the snippets but show you the code without them. Imagine a scenario where you want to find a bug and you have a lot of snippets. Using such a button would allow you to quickly trace the error.

  2. Is it possible to implement such a feature that once a snippet is added to check whether the shortcode is used in existing queries and therefore suggest to replace the code with the snippet if needed? It would be useful! (Sorry if it is possible and I missed it)

  3. It would greatly extend the feature if it supports variables in itself too. If you implement a snippet that has a variable in it to directly pop up on top of the query and be usable.

These are a few suggestions that would bring greater functionality to your product.

All the best!

Hi @petar777
As for 1, almost the same as this issue, which is requesting an option to show the SQL that will be used:
https://github.com/metabase/metabase/issues/6096 - upvote by clicking :+1: on the first post

As for 2, very related to this request:
But snippets are not stored with references in the table, but as objects in report_card.dataset_query[native][template-tags], so there currently isn’t a way to easily get this information unless searching through all the questions’ metadata.

As for 3, that would be a lot more difficult than it sounds. It’s basically the same as a full Sub-Query:
https://github.com/metabase/metabase/issues/14545 - upvote by clicking :+1: on the first post

You might be interested in nested snippets too:
https://github.com/metabase/metabase/issues/13731 - upvote by clicking :+1: on the first post

1 Like