Creating a dbt™ Model

In this guide, you'll learn how to create your first dbt™ model in the Paradime IDE. By the end of this tutorial, you'll have a fully functional dbt™ model materialized in your data warehouse.

Estimated completion time: 10 minutes

Prerequisites

What you'll learn:


1. Create a New Branch

Before creating a model in your dbt™ project, it's essential to work on a new branch to keep your main branch clean and stable. Use Git Lite to create a new branch:

  1. Open Git Lite: Click the source control icon within the left panel of the IDE.

  2. Create a New Branch: Using the dropdown, select + New Branch and give it a practical name (e.g., my_first_dbt_model).

2. Create a New File

Create a new .sql file for your dbt™ model:

  1. Open your project file: Click the folder Icon (📁) in the left panel to view your dbt™ project files.

  2. Create a new file: Right-click on the folder where you want to add your new file (e.g., models/sources) and click New File.

  3. Name your file: Use a descriptive name that reflects the purpose of the model (e.g., nba_player_info.sql).

3. Write a dbt™ Model

With your new model open in the Code IDE, write SQL that transforms your data, using dbt's jinja syntax to reference sources and models dynamically. For example:

WITH source AS (
    SELECT 
        person_id AS player_id,
        first_name,
        last_name,
        team_name,
        position,
        height,
        weight
    FROM 
        {{ source('PUBLIC', 'COMMON_PLAYER_INFO') }}
    )
    
    SELECT 
        *
    FROM
        source

4. Materialize Your dbt™ Model

With your model written and previewed, it's time to materialize it in the data warehouse:

  1. Execute dbt run: In the terminal at the bottom of your screen, run the command dbt run.

  2. Check for errors: Review any errors or warnings that appear during the build process and resolve them as needed.

You can also execute dbt commands from the commands panel. Click the "run model" dropdown and select your desired command for quick access to common dbt operations

5. Commit and Push

After successfully building your model, commit and push your work using the learnings from the previous tutorial.

  1. Write your commit message: Use DinoAI's "Write Commit" feature to automatically generate a detailed commit message tailored to your specific code changes.

  2. Commit and Push: Save your changes to your local repository, then push them to the remote repository to ensure your work is backed up and accessible.

  3. Open a Pull Request (PR): Create a PR to allow your team to review and discuss the updates before merging.



Summary

Congratulations! You've successfully created your first dbt™ model in Paradime, from creating a new branch to committing your changes. Your model is now materialized in your data warehouse and ready for use.

Next, we'll explore how to use the code IDE for data exploration.

Last updated

#350: Bolt - Template fixes pt 1

Change request updated