How to Create Model in dbt?

Posted on by By admin, in DBT | 0

What is model in DBT

In dbt (data build tool), a model represents a logical transformation of raw data into a structured and analytically useful form. It consists of SQL queries that define how data from source tables or views should be selected, filtered, and aggregated to create a derived dataset. Models encapsulate the business logic necessary to generate meaningful insights and are designed to be modular, making them reusable and easy to maintain. By employing models, dbt enables a structured and version-controlled approach to data transformation, facilitating collaboration and ensuring the consistency and reliability of analytical outputs.

How To Create Models

Follow the below steps to create models in dbt UI (cloud)

  1. Log in to the DBT account. Click “Develop
  2. Find “models” folder in the project folders
  3. Click the … next to the models directory, then select Create file.
  4. Name the file filename.sql, then click Create.
  5. Write the transformation code / SQL and
    For eg –

    WITH raw_listings AS 
    ( SELECT * FROM AIRBNB.RAW.RAW_LISTINGS ) 
    SELECT id AS listing_id, 
    name AS listing_name, 
    listing_url, 
    room_type, 
    minimum_nights, 
    host_id, 
    price AS price_str, 
    created_at, 
    updated_at
    FROM raw_listings
  6. Click save

How To Run The Model

dbt run” command is used to run the model code / SQL. In the command prompt, enter “dbt run” at the bottom. You should get a successful run and see themodels created.

In case if you have any queries please get us at support@helicaltech.com

Thank You
Nikitha Rastapuram
Helical IT Solutions

logo

Best Open Source Business Intelligence Software Helical Insight is Here

logo

A Business Intelligence Framework

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments