DBT Tutorial: Macros in DBT

Опубликовано: 27 Февраль 2026
на канале: Anirvan Decodes
1,837
31

🚀 Welcome to Anirvan Decodes! 🚀


In this video we will learn usage of macros in dbt.


DBT macros are reusable blocks of Jinja code that enable you to encapsulate and reuse complex logic or SQL snippets within your dbt models or transformations.


Resources:

CSV file : https://github.com/dbt-labs/jaffle_sh...

Macros used:

get_payment_methods.sql

{% macro get_payment_methods() %}

{{ return(["bank_transfer", "credit_card", "gift_card"]) }}

{% endmacro %}


get_value_with_tax.sql

{% macro get_value_with_tax(amount_column, tax_percent = 12) %}


round({{amount_column}} + {{amount_column}} * {{tax_percent}} / 100)


{% endmacro %}



select
*,
{{ get_value_with_tax('amount') }} as amount_with_tax
from {{ ref('raw_payments') }}





dbt,macro,macros,jinja,in,and,using,set,variable,how,dbt macro,dbt macros,in dbt,set variable,macros in,how to,macro in,dbt jinja,dbt data,jinja and,macros in dbt,jinja and macros,how to write,to write dbt,write dbt macros,dbt macros using,macros using jinja2,dbt set variable,in dbt data,dbt data build


Rock Angel by Joakim Karud

/ joakimkarud
Creative Commons — Attribution-ShareAlike 3.0 Unported— CC BY-SA 3.0
http://creativecommons.org/licenses/b...
Music promoted by Audio Library

• Video

–––


▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Music: Uplifting And Inspiring Acoustic Corporate by Wavecont
https://protunes.net
Video Link:

• Wavecont - Uplifting And Inspiring Ac...
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬