2. Build your first queries

Now the fun begins...

1. Insert a cell

There are a few ways to insert a cell. The fastest (and my preferred method) is to drag in a column preview from the data sidebar.

For our Spotify example, let's drag in the spotify_daily_tracks from the spotify schema. The query should look like:

SELECT * FROM spotify.spotify_daily_tracks LIMIT 10

💡 Just a reminder that our demo data runs in BigQuery, so if following along, use BigQuery syntax 😉

2. Edit the cell

We can customize this cell in a number of ways including:

Editing the query

  • Count can execute any SQL SELECT statement.

  • Queries are sent directly to your database, and results are retrieved and shown in the canvas, so use the same syntax you would in your database or SQL IDE

  • To run a query you can either:

    • click off the cell (the query will automatically run)

    • Shift + Enter on the keyboard

    • Hit the 'Run cell' button in the menu above the cell

Editing the cell

  • You can customize the cell name - which will be helpful when we reference it in other cells

  • You can add a cell title to help others understand what the cell represents

  • You can format the SQL in your cell using the Format SQL button in the Design bar

In our Spotify example, let's edit the name of our cell to be daily_streams, and we'll remove the LIMIT so we can see all the data. Lastly, we can format our SQL to make it look pretty 😉.

3. Build a linked cell

One of the unique features of the Count canvas is the ability to reference other cells - effectively turning your analysis into a DAG of connected queries. Instead of building messy, complex queries across several tabs in a SQL IDE, visualizing your analysis as a DAG helps you to:

  • debug a query easily by isolating each subquery/CTE

  • copy and paste parts of the DAG for fast iteration and testing

  • the logical steps are easier to follow than trying to read messy, nested SQL

To continue our analysis, we can insert a referenced cell by clicking the </> button beneath our cell, daily_streams:

I'm going to build out my analysis a little bit more, just for fun!

Cell FAQs

What SQL is really running when I reference another cell?

Under the hood, all referenced cells are turned into CTEs, added to the query in your cell, and sent to your database.

To see the SQL that's being run, you can right-click on a cell and click Copy Compiled SQL.

How can I see how long my queries take to run?

On the bottom left of each cell, you will see metadata including:

  • the number of rows, and columns

  • when the query was last run

  • and how long it took to get the results

I have some long-running queries, can I stop them from updating unless I want them to run?

Yes! You can turn caching on for your canvas and that will ensure that results are only updated when you request them.

Can I import queries I already have?

Indeed!

You can import any SELECT SQL query, including compiled dbt models.

Once they are imported you can turn any CTEs into cells in one click, instantly turning your query into a DAG of cells.

Last updated