Reader small image

You're reading from  Metabase Up and Running

Product typeBook
Published inSep 2020
Reading LevelBeginner
PublisherPackt
ISBN-139781800202313
Edition1st Edition
Languages
Right arrow
Author (1)
Tim Abraham
Tim Abraham
author image
Tim Abraham

Tim Abraham is originally from Oakland, California, and currently living in the San Francisco Bay Area. He has been working in Data Science for 10 years, spending his time working at consumer technology companies like StumbleUpon, Twitter, and Airbnb and advising a few others. He also spent time as a Data Scientist in Residence at Expa, the Startup Studio that Metabase came out of, which is where he got to know the product and the founding team. Find him on Twitter @timabe.
Read more about Tim Abraham

Right arrow

Creating saved SQL snippets

It may feel like a lot of the SQL we've written has been copied, pasted, and reused over and over again from other queries. This is common in SQL, common in programming in general, and considered an anti-pattern. In fact, there's a principle in computing called the DRY principle, which stands for Don't Repeat Yourself (https://en.wikipedia.org/wiki/Don%27t_repeat_yourself). The principle is about how you should not rewrite the same line or lines of code again and again, as it is time-consuming and introduces more risk of bugs from typos.

Metabase has taken this principle to heart and has a feature called Saved SQL Snippets. A SQL snippet is a block of SQL that you can call upon in a single variable whenever you want to reuse it.

Throughout this chapter and book, we've been working with some iteration of the same query that takes the Orders table and flattens it out, such that every row becomes an item ordered, rather than an entire...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Metabase Up and Running
Published in: Sep 2020Publisher: PacktISBN-13: 9781800202313

Author (1)

author image
Tim Abraham

Tim Abraham is originally from Oakland, California, and currently living in the San Francisco Bay Area. He has been working in Data Science for 10 years, spending his time working at consumer technology companies like StumbleUpon, Twitter, and Airbnb and advising a few others. He also spent time as a Data Scientist in Residence at Expa, the Startup Studio that Metabase came out of, which is where he got to know the product and the founding team. Find him on Twitter @timabe.
Read more about Tim Abraham