• About Us
  • Privacy Policy
  • Disclaimer
  • Contact Us
TechTrendFeed
  • Home
  • Tech News
  • Cybersecurity
  • Software
  • Gaming
  • Machine Learning
  • Smart Home & IoT
No Result
View All Result
  • Home
  • Tech News
  • Cybersecurity
  • Software
  • Gaming
  • Machine Learning
  • Smart Home & IoT
No Result
View All Result
TechTrendFeed
No Result
View All Result

Getting began with dbt | In the direction of Knowledge Science

Admin by Admin
September 10, 2026
Home Machine Learning
Share on FacebookShare on Twitter


As a contract knowledge engineer, I typically expertise — ahem — let’s simply say, durations of inactivity. Once I browse the web marketplace for appropriate roles throughout these instances, some of the in-demand expertise I preserve seeing is expertise with a instrument known as dbt. 

So, to present myself the very best probability of acquiring work, I made a decision to be taught as a lot about dbt as I assumed I wanted to, to at the least be assured sufficient to speak about it on the whole phrases to a fellow techie at an interview stage ought to the necessity come up. This text distils that course of and what I’ve learnt. In fact you may’t be taught a topic simply by studying about it, in order traditional, I am going to present loads of sensible code and real-world examples.

To be clear, I’ve no affiliation or business affiliation with dbt, DuckDB, or their creators.

dbt Core is a free open-source software program launched underneath the Apache 2.0 licence, and you may run it regionally and not using a dbt account. DuckDB can also be free to make use of underneath the permissive MIT licence.

dbt supplies a broad vary of capabilities, however as that is an introduction to the subject, I’m concentrating on explaining the fundamentals. This contains utilizing dbt fashions and sources, and utilizing it to check knowledge and create documentation. Extra about all of those later.

For those who’ve labored on any moderately sized analytics or knowledge engineering undertaking, you’ve most likely ended up with a folder stuffed with SQL scripts.

When your undertaking first begins up, every part feels manageable. You run the scripts manually or schedule them in no matter orchestration instrument your organization makes use of. Every thing is nice.

Then the undertaking grows.

A column will get renamed in a single desk, and all of a sudden some downstream report or dashboard stops working or, worse nonetheless, your nightly 10 million report knowledge ingestion job fails, and your entire system grinds to a halt. The checklist of points {that a} wrongly utilized little bit of SQL or a desk change can do to a database system is horrifying. And you recognize what, it occurs on a regular basis.

A part of the issue is that, historically, SQL has been handled as a set of remoted scripts relatively than as a software program undertaking.

If this sounds all too acquainted, the parents behind dbt suppose they’ve an answer.

Desk of contents

  1. What’s dbt?
  2. Why do knowledge groups use dbt?
  3. Stipulations
  4. Putting in dbt
  5. Establishing a dbt undertaking
  6. Creating our DuckDB database
  7. Creating and working a dbt mannequin with a supply
  8. Utilizing dbt for testing your knowledge
    1. Not null check
    2. Accepted values check
  9. Utilizing dbt to doc your system
  10. Subsequent levels

What’s dbt?

dbt (knowledge construct instrument) was created within the mid 2010s by a gaggle now referred to as dbt Labs. It grew from an inner analytics workflow right into a broadly used open-source, free (on the developer plan) CLI instrument known as dbt Core, alongside a totally managed, paid model known as dbt Platform. I’ll be utilizing the free model.

dbt is used to remodel knowledge already saved in a database, warehouse or lakehouse. It does this by creating tables or views primarily based on user-supplied SQL, but it surely additionally handles the next:

  • Testing knowledge high quality

  • Documenting datasets and lineage

  • Reusing SQL by macros

  • Managing growth, testing and manufacturing environments

  • Working transformations by scheduled jobs or CI/CD pipelines

dbt is broadly utilized by groups working enterprise-grade knowledge storage platforms akin to Snowflake, BigQuery, Redshift and Databricks. However for my examples, I’m going to be utilizing an area DuckDB database.

Why do knowledge groups use dbt?

Primarily as a result of it’s good at what it does. 

Think about you’re constructing a gross sales reporting platform. Uncooked order knowledge lands in your knowledge warehouse each hour, say. You write one SQL script to wash the info, one other to calculate buyer totals, one other to construct every day gross sales figures, and one other to generate govt dashboards.

At first, the undertaking has 4 or 5 SQL recordsdata, and it’s straightforward to maintain monitor of them. Six months later, there are fifty, and the order by which they run is now not apparent.

  • Which script runs by which order? 

  • What breaks if somebody renames a column? 

  • How do you verify that the info continues to be legitimate? 

  • May a brand new developer perceive the undertaking with out opening each SQL file?

Usually, analytics groups solved these issues with naming conventions, handwritten notes handed round and plenty of shared methods information.

As organisations turned extra data-driven, analytics tasks began wanting increasingly like software program tasks. Groups wanted model management, automated testing, documentation and dependency administration as a result of they have been writing hundreds of traces of SQL.

Relatively than treating SQL scripts as unbiased recordsdata, dbt treats them as elements of a single undertaking, the place each transformation has an outlined function, and each dependency is known.

Stipulations

I’m utilizing Home windows as my working system and have Python 3.13 put in. Every thing ought to work in the identical manner in the event you’re on Linux or macOS however you positively must have Python put in. You’ll additionally want entry to an appropriate database for dbt to behave on. Every database could have variations in the way you set it up to make use of dbt. I will be utilizing DuckDB as my database and can present you the arrange for that. Seek the advice of the dbt docs (linked on the finish) in the event you’re utilizing a distinct knowledge retailer.

Putting in dbt

Now that we have now a greater understanding of dbt, in the remainder of this text I’ll present you the right way to set up it and, by means of instance code, reveal the commonest dbt instructions you’ll use in your day-to-day job.

The very first thing we must always do is about up a separate Python growth atmosphere to maintain our tasks siloed.

PS C:Usersthoma> cd tasksPS C:Usersthomaprojects> mkdir dbt-demo    Listing: C:UsersthomaprojectsMode                 LastWriteTime         Size Title----                 -------------         ------ ----d-----        03/08/2026     16:21                dbt-demoPS C:Usersthomaprojects> cd dbt-demoPS C:Usersthomaprojectsdbt-demo> python3 -m venv .venvPrecise atmosphere location could have moved attributable to redirects, hyperlinks or junctions.  Requested location: "C:Usersthomaprojectsdbt-demo.venvScriptspython3.exe"  Precise location:    "D:Usersthomaprojectsdbt-demo.venvScriptspython3.exe"PS C:Usersthomaprojectsdbt-demo> ..venvScriptsActivate.ps1(.venv) PS C:Usersthomaprojectsdbt-demo>(.venv) PS C:Usersthomaprojectsdbt-demo>(.venv) PS C:Usersthomaprojectsdbt-demo>

You may set up dbt utilizing a easy pip command just like the one proven under. To attach dbt to a knowledge supply, we use one thing known as an adapter. dbt has many several types of adapters, for instance, BigQuery, AWS Redshift, Snowflake, and so forth. For this demo, I’m going to be utilizing an area DuckDB database. 

Most adapters must be put in individually from the dbt-core product, however for DuckDB, dbt supplies a one-file set up.

(.venv) PS C:Usersthomaprojectsdbt-demo> python3 -m pip set up dbt-duckdbGathering dbt-duckdb  Downloading dbt_duckdb-1.10.1-py3-none-any.whl.metadata (38 kB)Gathering dbt-common<2,>=1 (from dbt-duckdb)  Utilizing cached dbt_common-1.38.0-py3-none-any.whl.metadata (5.0 kB)Gathering dbt-adapters<2,>=1 (from dbt-duckdb)  Utilizing cached dbt_adapters-1.24.5-py3-none-any.whl.metadata (4.6 kB)Gathering duckdb>=1.0.0 (from dbt-duckdb)  Downloading duckdb-1.5.5-cp313-cp313-win_amd64.whl.metadata (4.2 kB)Gathering dbt-core>=1.8.0 (from dbt-duckdb)  Utilizing cached dbt_core-1.12.0-py3-none-any.whl.metadata (4.5 kB)Gathering agate<2.0,>=1.0 (from dbt-adapters<2,>=1->dbt-duckdb)  Utilizing cached agate-1.14.2-py3-none-any.whl.metadata (3.1 kB)Gathering dbt-protos<2.0,>=1.0.291 (from dbt-adapters<2,>=1->dbt-duckdb)  Utilizing cached dbt_protos-1.0.541-py3-none-any.whl.metadata (859 bytes)Gathering mashumaro<3.18,>=3.9 (from mashumaro[msgpack]<3.18,>=3.9->dbt-adapters<2,>=1->dbt-duckdb).........Utilizing cached typing_inspection-0.4.2-py3-none-any.whl (14 kB)Utilizing cached tzdata-2026.3-py2.py3-none-any.whl (348 kB)Utilizing cached zipp-4.1.0-py3-none-any.whl (10 kB)Putting in collected packages: text-unidecode, pytz, pytimeparse, parsedatetime, leather-based, daff, zipp, urllib3, tzdata, typing-extensions, tabulate, sqlparse, sqlglot, six, rpds-py, rapidfuzz, pyyaml, python-slugify, python-dotenv, protobuf, pathspec, packaging, orderly-set, networkx, msgpack, more-itertools, MarkupSafe, isodate, idna, duckdb, dbt-extractor, dbt-core-experimental-parser, colorama, charset_normalizer, certifi, Babel, attrs, annotated-types, typing-inspection, requests, referencing, python-dateutil, pydantic-core, mashumaro, jinja2, importlib-metadata, deepdiff, dbt-protos, click on, agate, snowplow-tracker, pydantic, jsonschema-specifications, jsonschema, metricflow, dbt-common, dbt-adapters, dbt-core, dbt-duckdbEfficiently put in Babel-2.18.0 MarkupSafe-3.0.3 agate-1.9.1 annotated-types-0.8.0 attrs-26.1.0 certifi-2026.7.22 charset_normalizer-3.4.9 click-8.4.2 colorama-0.4.6 daff-1.4.2 dbt-adapters-1.24.5 dbt-common-1.38.0 dbt-core-1.12.0 dbt-core-experimental-parser-2.0.0a5 dbt-duckdb-1.10.1 dbt-extractor-0.6.0 dbt-protos-1.0.541 deepdiff-8.6.2 duckdb-1.5.5 idna-3.18 importlib-metadata-9.0.0 isodate-0.7.2 jinja2-3.1.6 jsonschema-4.26.0 jsonschema-specifications-2025.9.1 leather-0.4.1 mashumaro-3.17 metricflow-0.211.0 more-itertools-10.8.0 msgpack-1.2.1 networkx-3.6.1 orderly-set-5.5.0 packaging-26.2 parsedatetime-2.6 pathspec-1.0.4 protobuf-6.33.6 pydantic-2.13.4 pydantic-core-2.46.4 python-dateutil-2.9.0.post0 python-dotenv-1.2.2 python-slugify-8.0.4 pytimeparse-1.1.8 pytz-2026.3.post1 pyyaml-6.0.3 rapidfuzz-3.14.5 referencing-0.37.0 requests-2.34.2 rpds-py-2026.6.3 six-1.17.0 snowplow-tracker-1.1.0 sqlglot-30.14.0 sqlparse-0.5.5 tabulate-0.10.0 text-unidecode-1.3 typing-extensions-4.16.0 typing-inspection-0.4.2 tzdata-2026.3 urllib3-2.7.0 zipp-4.1.0[notice] A brand new launch of pip is out there: 26.1.2 -> 26.2[notice] To replace, run: python3.exe -m pip set up --upgrade pip(.venv) PS C:Usersthomaprojectsdbt-demo>

Establishing a dbt undertaking

The following factor we wish to do is initialise a dbt undertaking. We do that utilizing the dbt init command.

(.venv-core) PS C:Usersthomaprojectsdbt-demo> dbt init15:48:36  Working with dbt=1.12.0Enter a reputation on your undertaking (letters, digits, underscore): my-dbt-demomy-dbt-demo shouldn't be a legitimate undertaking identify.Enter a reputation on your undertaking (letters, digits, underscore): my_dbt_demo15:49:02  Establishing your profile.Which database would you want to make use of?[1] duckdb(Do not see the one you need? https://docs.getdbt.com/docs/available-adapters)Enter a quantity: 115:49:05  Profile my_dbt_demo written to C:Usersthoma.dbtprofiles.yml utilizing goal's pattern configuration. As soon as up to date, you'll begin growing with dbt.15:49:05  Working dbt debug to validate the undertaking...15:49:05  dbt model: 1.12.015:49:05  python model: 3.13.1415:49:05  python path: C:Usersthomaprojectsdbt-demo.venv-coreScriptspython3.exe15:49:05  os data: Home windows-11-10.0.22621-SP015:49:05  Utilizing profiles dir at C:Usersthoma.dbt15:49:05  Utilizing profiles.yml file at C:Usersthoma.dbtprofiles.yml15:49:05  Utilizing dbt_project.yml file at C:Usersthomaprojectsdbt-demomy_dbt_demodbt_project.yml15:49:05  adapter sort: duckdb15:49:05  adapter model: 1.10.115:49:05  Configuration:15:49:05    profiles.yml file [OK found and valid]15:49:05    dbt_project.yml file [OK found and valid]15:49:05  Required dependencies:15:49:05   - git [OK found]15:49:05  Connection:15:49:05    database: dev15:49:05    schema: major15:49:05    path: dev.duckdb15:49:05    config_options: None15:49:05    extensions: None15:49:05    settings: {}15:49:05    external_root: .15:49:05    use_credential_provider: None15:49:05    connect: None15:49:05    filesystems: None15:49:05    distant: None15:49:05    plugins: None15:49:05    disable_transactions: False15:49:05  Registered adapter: duckdb=1.10.115:49:05    Connection check: [OK connection ok]15:49:05  All checks handed!15:49:05  Your new dbt undertaking "my_dbt_demo" was created!Initialized new undertaking in C:Usersthomaprojectsdbt-demomy_dbt_demomy_dbt_demoFor extra data on the right way to configure the profiles.yml file,please seek the advice of the dbt documentation right here:  https://docs.getdbt.com/docs/configure-your-profileAnother factor:Need assistance? Do not hesitate to succeed in out to us through GitHub points or on Slack:  https://neighborhood.getdbt.com/Comfortable modeling!

Working the above command will create a variety of folders and recordsdata. It’ll look one thing like this,

MY_DBT_DEMO/    analyses/    knowledge/    macros/    fashions/        instance/            my_first_dbt_model.sql            my_second_dbt_model.sql            schema.yml    seeds/    snapshots/    exams/    .gitignore    dbt_project.yml    duckdb.exe    README.md

The fashions/instance folder exhibits two instance mannequin recordsdata and a schema file. We’ll speak extra about mannequin recordsdata in a bit, however for now you may safely delete the whole instance folder and its contents. 

One of the vital recordsdata that the dbt init course of creates is named profiles.yml. This holds your database connection properties, however you gained’t see it in your dbt undertaking construction. As a substitute, in Home windows, its full path is,

In my setup, the file contained this.

my_dbt_demo:  outputs:    dev:      sort: duckdb      path: dev.duckdb      threads: 1    prod:      sort: duckdb      path: prod.duckdb      threads: 4  goal: dev

Now we will see what dbt expects our database to be known as and the place it ought to reside. In fact, you may edit this file and alter these particulars if you need. The trail is relative to your HOME listing. I need my duckDB knowledge file to be in,

C:Usersthomaprojectsdbt-demodatamy_dbt_demo

So I up to date my profiles.yml file to appear to be this

my_dbt_demo:  outputs:    dev:      sort: duckdb      path: "{{ env_var('USERPROFILE') }}/tasks/dbt-demo/knowledge/duckdb.dev"      schema: uncooked      threads: 1    prod:      sort: duckdb      path: "{{ env_var('USERPROFILE') }}/tasks/dbt-demo/knowledge/duckdb.prod"      schema: uncooked      threads: 4  goal: dev

Creating our DuckDB database

Now we will create our DuckDB database. To try this, we have to set up the DuckDB CLI. Click on the hyperlink under and observe the directions related to your atmosphere.

https://duckdb.org/set up/?atmosphere=cli&platform=win&download_method=direct

Run the duckdb CLI and cross it the identify of an acceptable file to completely retailer your database. You too can run it and not using a parameter in the event you’re not bothered about conserving the info while you exit. Sort within the following command.

(.venv-core) PS C:Usersthomaprojectsdbt-demomy_dbt_demo> .duckdb $HOMEprojectsdbt-demomy_dbt_demodataduckdb.devDuckDB v1.5.5 (Variegata)Enter ".assist" for utilization hints.duckdb D CREATE SCHEMA IF NOT EXISTS uncooked;duckdb Dduckdb D CREATE OR REPLACE TABLE uncooked.orders (             order_id       INTEGER,             customer_name  VARCHAR,             product_name   VARCHAR,             order_date     DATE,             amount       INTEGER,             unit_price     DECIMAL(10, 2),             order_status   VARCHAR         );duckdb D INSERT INTO uncooked.orders VALUES             (1,  'Alice',   'Laptop computer Stand', '2026-01-03', 1,  39.99, 'accomplished'),             (2,  'Bob',     'USB-C Hub',    '2026-01-04', 2,  29.99, 'accomplished'),             (3,  'Charlie', 'Webcam',       '2026-01-05', 1,  74.50, 'returned'),             (4,  'Alice',   'Keyboard',     '2026-01-08', 1,  89.00, 'accomplished'),             (5,  'Diana',   'Mouse',        '2026-01-10', 2,  24.99, 'accomplished'),             (6,  'Bob',     'Monitor',      '2026-01-12', 1, 249.00, 'processing'),             (7,  'Alice',   'USB-C Hub',    '2026-02-02', 1,  29.99, 'accomplished'),             (8,  'Charlie', 'Keyboard',     '2026-02-06', 1,  89.00, 'accomplished'),             (9,  'Diana',   'Webcam',       '2026-02-09', 2,  74.50, 'accomplished'),             (10, 'Bob',     'Mouse',        '2026-02-14', 1,  24.99, 'cancelled'),             (11, 'Alice',   'Monitor',      '2026-03-01', 1, 249.00, 'accomplished'),             (12, 'Diana',   'Laptop computer Stand', '2026-03-05', 2,  39.99, 'accomplished');duckdb Dduckdb D SHOW ALL TABLES;┌──────────┬─────────┬─────────┬─────────────────────────────────────┬─────────────────────────────────────┬───────────┐│ database │ schema  │  identify   │            column_names             │            column_types             │ momentary ││ varchar  │ varchar │ varchar │              varchar[]              │              varchar[]              │  boolean  │├──────────┼─────────┼─────────┼─────────────────────────────────────┼─────────────────────────────────────┼───────────┤│ duckdb   │ uncooked     │ orders  │ [order_id, customer_name,           │ [INTEGER, VARCHAR, VARCHAR, DATE,   │ false     ││          │         │         │  product_name, order_date,          │  INTEGER, 'DECIMAL(10,2)', VARCHAR] │           ││          │         │         │  amount, unit_price,              │                                     │           ││          │         │         │  order_status]                      │                                     │           │└──────────┴─────────┴─────────┴─────────────────────────────────────┴─────────────────────────────────────┴───────────┘duckdb Dduckdb D SELECT *         FROM uncooked.orders         ORDER BY order_id;┌──────────┬───────────────┬──────────────┬────────────┬──────────┬───────────────┬──────────────┐│ order_id │ customer_name │ product_name │ order_date │ amount │  unit_price   │ order_status ││  int32   │    varchar    │   varchar    │    date    │  int32   │ decimal(10,2) │   varchar    │├──────────┼───────────────┼──────────────┼────────────┼──────────┼───────────────┼──────────────┤│        1 │ Alice         │ Laptop computer Stand │ 2026-01-03 │        1 │         39.99 │ accomplished    ││        2 │ Bob           │ USB-C Hub    │ 2026-01-04 │        2 │         29.99 │ accomplished    ││        3 │ Charlie       │ Webcam       │ 2026-01-05 │        1 │         74.50 │ returned     ││        4 │ Alice         │ Keyboard     │ 2026-01-08 │        1 │         89.00 │ accomplished    ││        5 │ Diana         │ Mouse        │ 2026-01-10 │        2 │         24.99 │ accomplished    ││        6 │ Bob           │ Monitor      │ 2026-01-12 │        1 │        249.00 │ processing   ││        7 │ Alice         │ USB-C Hub    │ 2026-02-02 │        1 │         29.99 │ accomplished    ││        8 │ Charlie       │ Keyboard     │ 2026-02-06 │        1 │         89.00 │ accomplished    ││        9 │ Diana         │ Webcam       │ 2026-02-09 │        2 │         74.50 │ accomplished    ││       10 │ Bob           │ Mouse        │ 2026-02-14 │        1 │         24.99 │ cancelled    ││       11 │ Alice         │ Monitor      │ 2026-03-01 │        1 │        249.00 │ accomplished    ││       12 │ Diana         │ Laptop computer Stand │ 2026-03-05 │        2 │         39.99 │ accomplished    │└──────────┴───────────────┴──────────────┴────────────┴──────────┴───────────────┴──────────────┘  12 rows                                                                              7 columnsduckdb D

Creating and working a dbt mannequin with a supply

Now that we have now knowledge in our database, we will begin to use dbt. Two of crucial ideas to understand in dbt are these of fashions and sources.

A mannequin is just a file containing a snippet of SQL that dbt makes use of to create a brand new desk or view in your goal database.

A supply is an current desk or view in your knowledge retailer that dbt did not create, akin to uncooked knowledge loaded by an software or ingestion instrument. Sources are how fashions check with current tables in your database/schema. You outline a supply utilizing a YAML configuration file. As we’re working with an orders desk, we’ll name ours orders.yml. 

For our instance, we’re going to create a mannequin that builds a desk to carry accomplished orders. This may check with our current orders database desk, so it is smart to create a supply YAML file for it. That appears like this:

# orders.ymlmodel: 2sources:  - identify: uncooked    schema: uncooked    tables:      - identify: orders

And our mannequin SQL file seems to be like this.

-- customer_orders_summary.sql{{ config(materialized='desk') }}with completed_orders as (    choose        order_id,        customer_name,        order_date,        amount,        amount * unit_price as order_value    from {{ supply('uncooked', 'orders') }}    the place decrease(order_status) = 'accomplished')choose    customer_name,    rely(*) as completed_order_count,    sum(amount) as total_units_purchased,    spherical(sum(order_value), 2) as total_revenue,    spherical(avg(order_value), 2) as average_order_value,    min(order_date) as first_order_date,    max(order_date) as most_recent_order_datefrom completed_ordersgroup by customer_name

Create each the mannequin SQL file and supply YAML file underneath the fashions folder in your dbt undertaking.

Hopefully you may instantly see the good thing about utilizing a supply in our mannequin file. As a result of the FROM clause within the SQL makes use of a reference relatively than an precise desk identify, if the supply desk identify have been to alter sooner or later sooner or later, you’ll solely must replace that change in a single place —  the supply file. Any and all SQLs utilizing the supply file would run unchanged.

Okay, now that these recordsdata are in place, we will run our dbt transformation. You do this utilizing the dbt run command.

(.venv-core) PS C:Usersthomaprojectsdbt-demomy_dbt_demo> dbt run20:33:39  Working with dbt=1.12.020:33:40  Registered adapter: duckdb=1.10.120:33:40  Unable to do partial parsing as a result of profile has modified20:33:41  [WARNING]: Configuration paths exist in your dbt_project.yml file which don't apply to any sources.There are 1 unused configuration paths:- fashions.my_dbt_demo.instance20:33:41  Discovered 1 mannequin, 1 supply, 486 macros20:33:4120:33:41  Concurrency: 1 threads (goal='dev')20:33:4120:33:41  1 of 1 START sql desk mannequin uncooked.customer_order_summary ........................ [RUN]20:33:41  1 of 1 OK created sql desk mannequin uncooked.customer_order_summary ................... [OK in 0.11s]20:33:4120:33:41  Completed working 1 desk mannequin in 0 hours 0 minutes and 0.23 seconds (0.23s).20:33:4120:33:41  Accomplished efficiently20:33:4120:33:41  Achieved. PASS=1 WARN=0 ERROR=0 SKIP=0 NO-OP=0 REUSED=0 TOTAL=1(.venv-core) PS C:Usersthomaprojectsdbt-demomy_dbt_demo> .duckdb $HOMEprojectsdbt-demomy_dbt_demodataduckdb.devDuckDB v1.5.5 (Variegata)Enter ".assist" for utilization hints.duckdb D present all tables;┌──────────┬─────────┬────────────────────────┬─────────────────────────────┬──────────────────────────────┬───────────┐│ database │ schema  │          identify          │        column_names         │         column_types         │ momentary ││ varchar  │ varchar │        varchar         │          varchar[]          │          varchar[]           │  boolean  │├──────────┼─────────┼────────────────────────┼─────────────────────────────┼──────────────────────────────┼───────────┤│ duckdb   │ uncooked     │ customer_order_summary │ [customer_name,             │ [VARCHAR, BIGINT, HUGEINT,   │ false     ││          │         │                        │  completed_order_count,     │  'DECIMAL(38,2)', DOUBLE,    │           ││          │         │                        │  total_units_purchased,     │  DATE, DATE]                 │           ││          │         │                        │  total_revenue,             │                              │           ││          │         │                        │  average_order_value,       │                              │           ││          │         │                        │  first_order_date,          │                              │           ││          │         │                        │  most_recent_order_date]    │                              │           │├──────────┼─────────┼────────────────────────┼─────────────────────────────┼──────────────────────────────┼───────────┤│ duckdb   │ uncooked     │ orders                 │ [order_id, customer_name,   │ [INTEGER, VARCHAR, VARCHAR,  │ false     ││          │         │                        │  product_name, order_date,  │  DATE, INTEGER,              │           ││          │         │                        │  quantity, unit_price,      │  'DECIMAL(10,2)', VARCHAR]   │           ││          │         │                        │  order_status]              │                              │           │└──────────┴─────────┴────────────────────────┴─────────────────────────────┴──────────────────────────────┴───────────┘duckdb D choose * from uncooked.customer_order_summary;┌───────────────┬───────────────────────┬───┬─────────────────────┬──────────────────┬────────────────────────┐│ customer_name │ completed_order_count │ … │ average_order_value │ first_order_date │ most_recent_order_date ││    varchar    │         int64         │ … │       double        │       date       │          date          │├───────────────┼───────────────────────┼───┼─────────────────────┼──────────────────┼────────────────────────┤│ Charlie       │                     1 │ … │                89.0 │ 2026-02-06       │ 2026-02-06             ││ Alice         │                     4 │ … │               102.0 │ 2026-01-03       │ 2026-03-01             ││ Bob           │                     1 │ … │               59.98 │ 2026-01-04       │ 2026-01-04             ││ Diana         │                     3 │ … │               92.99 │ 2026-01-10       │ 2026-03-05             │└───────────────┴───────────────────────┴───┴─────────────────────┴──────────────────┴────────────────────────┘

The output is as anticipated. A brand new abstract desk is created with the required data. That’s all I’m going to say on fashions and sources. What I’ve proven may appear a little bit of a faff for only one desk, and it’s, however belief me, in case you are coping with dozens or lots of of tables and transformations, you gained’t remorse the time spent on creating fashions and sources.

Utilizing dbt for testing your knowledge

One other advantage of utilizing dbt is its capability to automate your SQL testing cycle. Assessments are outlined (in YAML) alongside your fashions and sources and may be executed independently or at any time when the undertaking is constructed. You may write your individual SQL exams, however dbt additionally supplies 4 built-in check situations:

  • distinctive

  • not_null

  • relationships

  • accepted_values

We’ll demo two of those exams to present you a flavour of what you are able to do with them.

Not null check

Our check can be run towards the customer_name column of the customer_order_summary desk. As we’re testing a desk that dbt is creating, we add the check YAML to a fashions part in our orders.yml file. It now seems to be like this:

# orders.ymlmodel: 2sources:  - identify: uncooked    schema: uncooked    tables:      - identify: ordersfashions:  - identify: customer_order_summary    columns:      - identify: customer_name        data_tests:          - not_null

As I didn’t have any null buyer names in my authentic orders desk, I created one so we will see what a failing check seems to be like.

duckdb D replace uncooked.orders set customer_name = NULL the place order_id = 1;duckdb D choose * from uncooked.orders;┌──────────┬───────────────┬──────────────┬────────────┬──────────┬───────────────┬──────────────┐│ order_id │ customer_name │ product_name │ order_date │ amount │  unit_price   │ order_status ││  int32   │    varchar    │   varchar    │    date    │  int32   │ decimal(10,2) │   varchar    │├──────────┼───────────────┼──────────────┼────────────┼──────────┼───────────────┼──────────────┤│        1 │ NULL          │ Laptop computer Stand │ 2026-01-03 │        1 │         39.99 │ accomplished    ││        2 │ Bob           │ USB-C Hub    │ 2026-01-04 │        2 │         29.99 │ accomplished    ││        3 │ Charlie       │ Webcam       │ 2026-01-05 │        1 │         74.50 │ returned     ││        4 │ Alice         │ Keyboard     │ 2026-01-08 │        1 │         89.00 │ accomplished    ││        5 │ Diana         │ Mouse        │ 2026-01-10 │        2 │         24.99 │ accomplished    ││        6 │ Bob           │ Monitor      │ 2026-01-12 │        1 │        249.00 │ processing   ││        7 │ Alice         │ USB-C Hub    │ 2026-02-02 │        1 │         29.99 │ accomplished    ││        8 │ Charlie       │ Keyboard     │ 2026-02-06 │        1 │         89.00 │ accomplished    ││        9 │ Diana         │ Webcam       │ 2026-02-09 │        2 │         74.50 │ accomplished    ││       10 │ Bob           │ Mouse        │ 2026-02-14 │        1 │         24.99 │ cancelled    ││       11 │ Alice         │ Monitor      │ 2026-03-01 │        1 │        249.00 │ accomplished    ││       12 │ Diana         │ Laptop computer Stand │ 2026-03-05 │        2 │         39.99 │ accomplished    │└──────────┴───────────────┴──────────────┴────────────┴──────────┴───────────────┴──────────────┘  12 rows                                                                              7 columns

Now, to run our check, we will merely sort the dbt construct command like this, which runs and validates the chosen elements of a dbt undertaking in dependency order.

(.venv-core) PS C:Usersthomaprojectsdbt-demomy_dbt_demo> dbt construct08:43:19  Working with dbt=1.12.008:43:20  Registered adapter: duckdb=1.10.108:43:20  [WARNING]: Configuration paths exist in your dbt_project.yml file which don't apply to any sources.There are 1 unused configuration paths:- fashions.my_dbt_demo.instance08:43:20  Discovered 1 mannequin, 1 check, 1 supply, 486 macros08:43:2008:43:20  Concurrency: 1 threads (goal='dev')08:43:2008:43:20  1 of two START sql desk mannequin uncooked.customer_order_summary ........................ [RUN]08:43:20  1 of two OK created sql desk mannequin uncooked.customer_order_summary ................... [OK in 0.14s]08:43:20  2 of two START check not_null_customer_order_summary_customer_name ................ [RUN]08:43:20  2 of two FAIL 1 not_null_customer_order_summary_customer_name .................... [FAIL 1 in 0.02s]08:43:2008:43:20  Completed working 1 desk mannequin, 1 check in 0 hours 0 minutes and 0.24 seconds (0.24s).08:43:2008:43:20  Accomplished with 1 error, 0 partial successes, and 0 warnings:08:43:2008:43:20  [ERROR]: in check not_null_customer_order_summary_customer_name (modelsorders.yml)08:43:20    Received 1 outcome, configured to fail if != 008:43:2008:43:20    compiled code at targetcompiledmy_dbt_demomodelsorders.ymlnot_null_customer_order_summary_customer_name.sql08:43:2008:43:20  Achieved. PASS=1 WARN=0 ERROR=1 SKIP=0 NO-OP=0 REUSED=0 TOTAL=2

The problem is caught and reported on. dbt does not delete or roll again a mannequin when its subsequent knowledge check fails. Nevertheless, fashions downstream of the failed check are usually skipped through the construct. If you wish to run the check with out re-creating any tables, and so forth., simply use the dbt check command.

Accepted values check

This does precisely what it seems like. It lets you check {that a} column comprises solely particular values. If we take a look at our orders desk, we will see that the order_status column ought to solely comprise both accomplished, processing, returned or cancelled values. So let’s replace the desk and alter one of many values to be one thing else.

duckdb D choose * from uncooked.orders the place order_id = 10;┌──────────┬───────────────┬──────────────┬────────────┬──────────┬───────────────┬──────────────┐│ order_id │ customer_name │ product_name │ order_date │ amount │  unit_price   │ order_status ││  int32   │    varchar    │   varchar    │    date    │  int32   │ decimal(10,2) │   varchar    │├──────────┼───────────────┼──────────────┼────────────┼──────────┼───────────────┼──────────────┤│       10 │ Bob           │ Mouse        │ 2026-02-14 │        1 │         24.99 │ cancelled    │└──────────┴───────────────┴──────────────┴────────────┴──────────┴───────────────┴──────────────┘duckdb D replace uncooked.orders set order_status = 'invalid' the place order_id = 10;duckdb D choose * from uncooked.orders the place order_id = 10;┌──────────┬───────────────┬──────────────┬────────────┬──────────┬───────────────┬──────────────┐│ order_id │ customer_name │ product_name │ order_date │ amount │  unit_price   │ order_status ││  int32   │    varchar    │   varchar    │    date    │  int32   │ decimal(10,2) │   varchar    │├──────────┼───────────────┼──────────────┼────────────┼──────────┼───────────────┼──────────────┤│       10 │ Bob           │ Mouse        │ 2026-02-14 │        1 │         24.99 │ invalid      │└──────────┴───────────────┴──────────────┴────────────┴──────────┴───────────────┴──────────────┘

As we’re testing a supply desk, we must always put our check YAML config within the sources part of our YAML file. You may depart or take away the unique null check if you need. I’ve stored it in.

# orders.ymlmodel: 2sources:  - identify: uncooked    schema: uncooked    tables:      - identify: orders        columns:          - identify: order_status            data_tests:              - accepted_values:                  arguments:                    values:                      - accomplished                      - processing                      - returned                      - cancelledfashions:  - identify: customer_order_summary    columns:      - identify: customer_name        data_tests:          - not_null

We’re working the check on an current desk, so we needn’t run the construct command. We are able to simply use dbt check.

(.venv-core) PS C:Usersthomaprojectsdbt-demomy_dbt_demo> dbt check09:08:04  Working with dbt=1.12.009:08:04  Registered adapter: duckdb=1.10.109:08:04  [WARNING]: Configuration paths exist in your dbt_project.yml file which don't apply to any sources.There are 1 unused configuration paths:- fashions.my_dbt_demo.instance09:08:04  Discovered 1 mannequin, 2 knowledge exams, 1 supply, 486 macros09:08:0409:08:04  Concurrency: 1 threads (goal='dev')09:08:0409:08:04  1 of two START check not_null_customer_order_summary_customer_name ................ [RUN]09:08:04  1 of two FAIL 1 not_null_customer_order_summary_customer_name .................... [FAIL 1 in 0.03s]09:08:04  2 of two START check source_accepted_values_raw_orders_order_status__completed__processing__returned__cancelled  [RUN]09:08:04  2 of two FAIL 1 source_accepted_values_raw_orders_order_status__completed__processing__returned__cancelled  [FAIL 1 in 0.02s]09:08:0409:08:04  Completed working 2 knowledge exams in 0 hours 0 minutes and 0.11 seconds (0.11s).09:08:0409:08:04  Accomplished with 2 errors, 0 partial successes, and 0 warnings:09:08:0409:08:04  [ERROR]: in check not_null_customer_order_summary_customer_name (modelsorders.yml)09:08:04    Received 1 outcome, configured to fail if != 009:08:0409:08:04    compiled code at targetcompiledmy_dbt_demomodelsorders.ymlnot_null_customer_order_summary_customer_name.sql09:08:0409:08:04  [ERROR]: in check source_accepted_values_raw_orders_order_status__completed__processing__returned__cancelled (modelsorders.yml)09:08:04    Received 1 outcome, configured to fail if != 009:08:0409:08:04    compiled code at targetcompiledmy_dbt_demomodelsorders.ymlsource_accepted_values_raw_ord_0932c13ab9fb3a73a9e3e3c87c81af50.sql09:08:0409:08:04  Achieved. PASS=0 WARN=0 ERROR=2 SKIP=0 NO-OP=0 REUSED=0 TOTAL=2(.venv-core) PS C:Usersthomaprojectsdbt-demomy_dbt_demo>

The opposite two sorts of built-in check are equally straightforward to arrange and run, so I am going to depart it at that.

Utilizing dbt to doc your system

The ultimate introductory dbt matter we’re going to take a look at is arguably certainly one of its finest options. Most documentation begins life with good intentions earlier than quietly changing into old-fashioned. dbt approaches documentation in another way.

As a result of your fashions, exams and metadata all reside alongside your SQL, dbt can generate undertaking documentation routinely. Extra importantly, it additionally creates a visible lineage graph displaying precisely how your fashions depend upon each other.

That is invaluable when somebody new joins your undertaking as a result of they don’t must reverse-engineer lots of of SQL recordsdata. They’ll see the whole transformation pipeline virtually instantly.

It’s a type of options that doesn’t appear notably thrilling till you’ve inherited another person’s analytics undertaking.

Proper off the bat, dbt can do some automated documentation for you, but it surely’s a type of issues that the extra you place into it, the higher documentation you’ll get out. With out doing something additional to our undertaking, right here is the naked documentation you get. We use the dbt docs generate command to create the documentation like this.

(.venv-core) PS C:Usersthomaprojectsdbt-demomy_dbt_demo> dbt docs generate09:21:19  Working with dbt=1.12.009:21:19  Registered adapter: duckdb=1.10.109:21:19  [WARNING]: Configuration paths exist in your dbt_project.yml file which don't apply to any sources.There are 1 unused configuration paths:- fashions.my_dbt_demo.instance09:21:19  Discovered 1 mannequin, 2 knowledge exams, 1 supply, 486 macros09:21:1909:21:19  Concurrency: 1 threads (goal='dev')09:21:1909:21:19  Constructing catalog09:21:19  Catalog written to C:Usersthomaprojectsdbt-demomy_dbt_demotargetcatalog.json

Now that we’ve generated the documentation, we will visualise it in an online browser utilizing the dbt docs serve command.

(.venv-core) PS C:Usersthomaprojectsdbt-demomy_dbt_demo> dbt docs serve09:24:48  Working with dbt=1.12.0Serving docs at 8080To entry out of your browser, navigate to: http://localhost:8080Press Ctrl+C to exit.127.0.0.1 - - [04/Aug/2026 10:24:48] "GET / HTTP/1.1" 200 -127.0.0.1 - - [04/Aug/2026 10:24:48] "GET /manifest.json?cb=1785835488811 HTTP/1.1" 200 -127.0.0.1 - - [04/Aug/2026 10:24:48] "GET /catalog.json?cb=1785835488811 HTTP/1.1" 200 -127.0.0.1 - - [04/Aug/2026 10:24:49] code 404, message File not discovered127.0.0.1 - - [04/Aug/2026 10:24:49] "GET /%7Bpercent7Bpercent20getIcon(merchandise.sort,%20'on')%20percent7Dpercent7D HTTP/1.1" 404 -127.0.0.1 - - [04/Aug/2026 10:24:49] code 404, message File not discovered127.0.0.1 - - [04/Aug/2026 10:24:49] "GET /%7Bpercent7Bpercent20getIcon(merchandise.sort,%20'off')%20percent7Dpercent7D HTTP/1.1" 404 -

You must see a browser window open that appears one thing like this,

As I discussed, it’s fairly bare-bones however nonetheless helpful. To see the true energy, you need to add your individual descriptive documentation textual content within the type of YAML to your orders.yml file. Right here is an instance.

model: 2sources:  - identify: uncooked    description: "Uncooked demonstration knowledge created straight in DuckDB earlier than dbt transformations run."    schema: uncooked    tables:      - identify: orders        description: "Pattern buyer orders used because the enter to the shopper order abstract mannequin."        columns:          - identify: order_id            description: "Distinctive identifier assigned to every order."          - identify: customer_name            description: "Title of the shopper who positioned the order."          - identify: product_name            description: "Product bought by the shopper."          - identify: order_date            description: "Date on which the order was positioned."          - identify: amount            description: "Variety of product models ordered."          - identify: unit_price            description: "Worth of 1 product unit on the time of the order."          - identify: order_status            description: "Present order state; restricted to the 4 supported standing values."            data_tests:              - accepted_values:                  arguments:                    values:                      - accomplished                      - processing                      - returned                      - cancelledfashions:  - identify: customer_order_summary    description: >      A dbt-created desk containing one row per buyer. It contains solely accomplished      orders and summarises order counts, models bought, income and order dates.    columns:      - identify: customer_name        description: "Buyer represented by the abstract row."        data_tests:          - not_null      - identify: completed_order_count        description: "Variety of accomplished orders positioned by the shopper."      - identify: total_units_purchased        description: "Whole variety of models throughout the shopper's accomplished orders."      - identify: total_revenue        description: "Whole worth of the shopper's accomplished orders."      - identify: average_order_value        description: "Common worth of the shopper's accomplished orders."      - identify: first_order_date        description: "Earliest accomplished order date for the shopper."      - identify: most_recent_order_date        description: "Most up-to-date accomplished order date for the shopper."

Now, once we run the 2 dbt documentation instructions, we get a a lot richer output like this.

Subsequent levels

dbt is a big ecosystem, and as I defined, I solely needed to the touch on a number of the fundamentals of its operation. As issues stand, I’m proud of the information I’ve on utilizing dbt. If you wish to take issues additional, you would possibly wish to dive deeper into the next matters, which construct on what I’ve talked about right here.

  • Incremental fashions: Course of solely new or modified data as an alternative of rebuilding a complete desk on each run.

  • Jinja: A templating language that permits you to add variables, situations, loops and reusable features to SQL.

  • Macros: Reusable items of Jinja and SQL logic that may settle for parameters and generate SQL.

  • Snapshots: Report how supply data change over time, permitting you to retain their historic values.

  • Reusable packages: Use fashions, macros and exams created by different dbt tasks as an alternative of constructing every part your self.

Here’s a hyperlink to the official dbt Labs house web page the place you may discover all the knowledge you must find out about dbt.

https://www.getdbt.com

Comfortable studying.

Tags: DataScienceStartedwithdbt
Admin

Admin

Next Post
How AI Is Reworking Digital Engineering

How AI Is Reworking Digital Engineering

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Trending.

Discover a Software program Improvement Firm in Europe

Discover a Software program Improvement Firm in Europe

August 22, 2025
These 5 Easy Methods Helped Me Construct a Smarter House

These 5 Easy Methods Helped Me Construct a Smarter House

July 19, 2025
Arbitrage: Environment friendly Reasoning by way of Benefit-Conscious Hypothesis

Arbitrage: Environment friendly Reasoning by way of Benefit-Conscious Hypothesis

August 8, 2026
How A lot Does Error-Monitoring Software program Growth Value?

How A lot Does Error-Monitoring Software program Growth Value?

April 8, 2025
Salesforce acquires Informatica for $8 billion

Salesforce acquires Informatica for $8 billion

May 27, 2025

TechTrendFeed

Welcome to TechTrendFeed, your go-to source for the latest news and insights from the world of technology. Our mission is to bring you the most relevant and up-to-date information on everything tech-related, from machine learning and artificial intelligence to cybersecurity, gaming, and the exciting world of smart home technology and IoT.

Categories

  • Cybersecurity
  • Gaming
  • Machine Learning
  • Smart Home & IoT
  • Software
  • Tech News

Recent News

Scale back LLM latency with prefix-aware routing on Amazon SageMaker Inference

Scale back LLM latency with prefix-aware routing on Amazon SageMaker Inference

September 11, 2026
Nintendo Lastly Provides Some Life To The Swap 2

Nintendo Lastly Provides Some Life To The Swap 2

September 11, 2026
  • About Us
  • Privacy Policy
  • Disclaimer
  • Contact Us

© 2025 https://techtrendfeed.com/ - All Rights Reserved

No Result
View All Result
  • Home
  • Tech News
  • Cybersecurity
  • Software
  • Gaming
  • Machine Learning
  • Smart Home & IoT

© 2025 https://techtrendfeed.com/ - All Rights Reserved