SQL cells

SQL cells are the analysis workhorse of Count

Creating a SQL cell

To create a SQL cell, click the cell button in the control bar, or hit the / key. You can drop your cell anywhere on the canvas and start writing SQL. Your query can use any of the tables, columns or cells you see in the data bar on the left hand side of the canvas.

When you create a cell, it will reference the currently-selected data source in the sources pane of the data bar.

Writing and formatting SQL

Cells use the syntax for your database. For example, if you are querying Snowflake you should use Snowflake syntax and functions. If you switch to BigQuery, write in native BigQuery SQL.

SQL cells have a few great features:

  • Contextual auto-complete - Count will suggest table names, column names and functions depending on the scope of the SQL you are writing.

  • SQL linting - Accessed via the design bar or right click menu, Count will automatically format your SQL to be easy to read.

  • Automatic DAG creation - Count will automatically connect any SQL cells that reference one another with an arrow.

  • Automatic cell layout - Available with the keyboard shortcut Cmd/Ctrl+Opt/Alt+L, Count will automatically selected cells in a logical manner.

  • Exploding cells - Turn any query involving CTEs into a DAG of connected cells.

  • Jinja templating - Use the jinja templating language to generate queries.

Exporting SQL from Count

Each cell, regardless of type, is a SQL statement under the hood. You can export that SQL via the right-click menu by choosing Copy compiled SQL.

It's important to understand that any given cell contains the SQL for all cells upstream in the DAG. This means you can export SQL from the last cell in a complex chain of analysis and export it to any database or data tool. This is often used for materializing views in a database.

Remember, each cell in Count is one or more compiled CTEs. Because we use the native SQL of your database, you can plug-and-play SQL from Count into your data source.

Last updated