Count
count.co
  • Getting Started
    • What is Count?
    • Count FAQ
    • Intro to your workspace
    • Example canvases
    • Getting started guides
      • Set up your workspace and projects
        • 1. Review workspace settings
        • 2. Create and organise your projects
      • Canvas orientation
      • Your first ad hoc analysis
        • 1. Examples and templates
        • 2. Build your first queries
        • 3. Create visuals
        • 4. Caching, local cells and scheduling
        • 5. Collaborating with a stakeholder
      • Your first report
        • 1. Examples and templates
        • 2. Filters and control cells
        • 3. Sharing your report
        • 4. Alerts
  • Connect your data
    • Database connection overview
      • Athena
      • Azure Synapse
      • BigQuery
      • Databricks
      • Microsoft SQL Server
      • MySQL
      • PostgreSQL
      • Redshift
      • Snowflake
    • Refresh database schema
    • Upload CSV files
    • dbt integration
      • ☁️dbt Cloud integration
      • 👩‍💻dbt Core integration
  • Import & Export
    • Import from other tools
      • Import Miro files
      • Import SQL files
      • Import Google Sheets
      • Import Jupyter notebooks
    • Export code and results
      • Export compiled SQL and Jinja-SQL
      • Export CSV files
      • Export images and PDF files
  • THE CANVAS
    • Navigating the canvas
      • Canvas tool bar
      • Data sidebar
      • Customizing the canvas
    • Canvas objects
      • Cells
      • Text and markdown
      • Shapes and tools
      • Sticky notes
      • Frames
      • Images
      • Embeds
      • Stamps
      • Grouping objects
      • Object order and alignment
      • Locking objects
      • Scaling objects
      • Shared styles
    • Overviews
    • Templates
    • Count AI
    • Alerts and subscriptions
      • Slack integration
    • Keyboard shortcuts
  • Querying data
    • Cells overview
      • Dynamic query compilation engine
    • SQL cells
      • Referencing other cells
      • Jinja templating
      • SQL formatting
    • Python cells
    • Visual and low-code cells
      • Calculations in visuals and low-code cells
      • Joins in visuals and low-code cells
    • Control cells
      • Single and multiple selects
      • Date controls
      • Text, number, and boolean controls
      • Custom control cells
    • Local DuckDB cells
      • DuckDB on the server
    • Query caching and scheduling
    • Manage queries and results
    • Troubleshooting
  • Visualizing data
    • Visualization overview
    • Templated visuals
    • Custom visuals
      • Marks
      • Facet
      • Subplots
      • Style
      • Filters
    • Formatting a visual
      • Axes
        • Secondary Axis
      • Colors and labels
      • Legends
      • Tooltips
    • Column summaries
    • Dynamic text
    • Every Visual Under the Sun
  • Presenting and Reporting
    • Reports and Slides
  • Count Metrics
    • Intro to Count Metrics
    • Build and edit a catalog
    • Views
      • Creating views
      • Customizing views
    • Datasets
      • Creating datasets
    • Save changes to the catalog
      • Catalog validation
      • Version control
    • Exposing catalogs to the workspace
    • Caching in Count Metrics
    • Using the catalog
      • Explore from cell
  • Sharing and Permissions
    • Real-time collaboration
    • Comments
    • Sharing permissions
    • Shared links
    • Embedding canvases
  • History and Versions
    • Version control
    • Duplicating and merging
    • Data snapshots
  • Settings and administration
    • Workspace settings
      • Workspace members
      • Groups
      • Tags
      • Billing
      • Single sign-on (SSO)
        • Okta
        • Entra ID
        • JumpCloud
        • Google
        • Generic OIDC
      • Brand
    • Connection settings
    • Project settings
    • User settings
    • Roles and permissions
  • Quick guides
    • Interactive control guides
      • Date ranges
      • Date groupings
      • Search
      • Select All
  • Resources
    • Join the Slack community
  • Blog
  • Security overview
  • Terms of use
  • Pricing FAQ
Powered by GitBook
On this page
  • Introduction
  • Video tutorials
  • Why import dbt metadata?
  • Viewing dbt metadata
  • Importing models
  • Model cells
  • How the ref() macro works
  • How Jinja compilation works
  • Troubleshooting
  1. Connect your data

dbt integration

Import your dbt models into Count

PreviousUpload CSV filesNextdbt Cloud integration

Last updated 17 days ago

Introduction

is an open-source tool for transforming data, helping data engineers build and define a of SQL queries called .

Sound familiar? By adding dbt models as cells, the Count canvas becomes a natural place to collaboratively explore, visualise, and develop your dbt models.

Count supports dbt Cloud and dbt Core integrations. Learn how to connect to each in the following pages:

Video tutorials

Learn more about how the dbt integration in Count works in the following videos:

Why import dbt metadata?

With a dbt integration your database tables in Count are annotated with dbt model and test metadata, allowing you to import raw and compiled code with lineage intact. Count compiles your raw code live, allowing you to swap model references for cells and vice-versa.

This simple but powerful feature enables lots of helpful workflows. For example, you may:

  • Import a database table with all upstream models in one click.

  • Explode a model into its component CTEs for better debugging and comprehension.

  • Execute models against other databases - for example, staging and production environments.

  • Prototype and iterate models live with the data team, then export dbt-ready model files.

Viewing dbt metadata

Importing models

The Add to canvas button exposes options for adding models and sources to the canvas:

The different options here determine how the model is added and subsequently executed:

Jinja / Compiled

The Jinja option adds the model using the raw code from the original .sql file that defines it. The Compiled option adds the model as plain SQL as compiled by dbt. This option is available if your dbt artifacts contain compiled SQL.

Compiled SQL may be preferable if your model compilation requires information that is not available in Count, for example any private or local environment variables passed to dbt in another environment.

Explode cells

If enabled, models are exploded into CTEs before being added to the canvas. When a model has been exploded, the exploded cells are wrapped in a frame.

The cell containing the base SELECT statement from the model will be annotated with a dbt icon, while the other cells formed from the CTEs will not.

Upstream / downstream levels

By increasing the values here, it is possible to import additional upstream and downstream models at the same time as this one - the number of models that will be added is shown in the button below. Leaving both values at zero will import only the current model.

For example, selecting 1 upstream level and 2 downstream levels for model model is equivalent to the dbt select command:

--select 1+model+2

Model cells

When a cell is connected to a source with dbt enabled, then it will be possible to mark that cell as a dbt model using the controls in the right sidebar:

If a cell is marked as a model:

  • A dbt icon appears in the header of the cell.

How the ref() macro works

The ref() macro is one of several macros that are built-in to dbt and available in Count with some additional functionality.

When using this macro, any references to upstream models will be compiled to:

  • A Count cell reference if a cell with that name exists

  • A database identifier if a dbt model with that name exists, and is present in the database

  • A CTE if an ephemeral dbt model with that name exists

This is a very helpful feature when developing models, as Count cells can act as temporary scratchpads that can override your existing model definitions. To switch between referring to a Count cell or a database table, just rename or delete the cell.

To quickly view how a reference is compiled, hover over it to view either the compiled SQL or a link to the cell:

If a cell is deleted, all cells containing a ref() that reference that cell will be recompiled, and revert back to referencing the full database identifier.

How Jinja compilation works

Because some dbt macros require executing arbitrary SQL, compilation involving complex dbt functionality is currently disabled for canvas viewers.

When opening a canvas, if you're a canvas editor the relevant dbt artifacts will be downloaded by your browser.

Once the artifacts have been downloaded and processed in the background, your models and macros will become available in autocompletions:

In addition, Count makes available a subset of common dbt functionality, including access to cell results and formatting using native dbt macros:

dbt macros that access cell results will error if that cell is currently being executed or compiled. In this case, re-compile the cell once results are available using the Run cell button.

For compatibility with existing dbt models and macros, it is also possible to execute queries during the compilation phase of cell execution. We would suggest avoiding this approach where possible, as it is not yet (and may never be) fully integrated with Count's reactive cell execution framework.

Any queries executed during compilation are authorised and validated in the same way as any other cell query in Count, so are limited to SELECT statements.

Troubleshooting

Once a dbt integration is created, a dbt icon appears in the when hovering over any database table or view that is associated with a source or model (plus any ephemeral models). Clicking this icon opens a metadata pane that exposes additional information from your dbt project, including documentation and test results.

When exporting , references to that cell default to ref() rather than SQL, with cells further upstream not included.

If the dbt Core integration is , then changes to these cells are interpreted as changes to dbt model files.

Count reads your dbt and uses that information to compile your Jinja-SQL code directly in your browser. This ensures that compilation is quick, helping you to explore and iterate your models rapidly.

See our for frequently asked questions & how to guides on our dbt integrations.

artifacts
Learn centre
dbt
models
☁️dbt Cloud integration
👩‍💻dbt Core integration
Feature overview
Connecting dbt
Adding models to the canvas
Committing changes to GitHub
DAG
SQL + Jinja
connected to GitHub
Hover over a table or column to access dbt metadata.
An example of a dbt model exploded into 5 cells. The cell on the right with the dbt icon represents the original SELECT statement of the model.
The cell model controls
Hovering over Jinja blocks will show either compiled SQL or a link to the referenced cell.
Start typing a ref() call, and available models will appear in autocompletions
Your project macros are also available.
These macros are from the dbt package, and so in the global scope.
If any queries are executed during compilation, their duration will be displayed in the cell footer.
table pane