internalsGet Pro

Module 15 · Lesson 9 of 12Pro

Macros and packages in dbt

Level
Intermediate
Topic
Transformations with dbt
Reading time
17 min

When you finish this page you can

  1. Write a dbt macro with arguments, call it from a model and check the SQL it compiles to.
  2. Explain when Jinja runs during parsing and when it runs against the warehouse, and guard run_query accordingly.
  3. Trace how generate_schema_name and the target decide a model’s schema, and make one macro work on Snowflake and DuckDB with dispatch.
  4. Install, pin and upgrade a dbt package such as dbt_utils, and say what dbt v2 changed about package support.

Builds on 2 lessons

Start with lesson 214 min
  1. dbt models, sources and references14 min
  2. Testing data with dbt18 min

Two finance tables, two answers for Wednesday

At 07:05 IST on Thursday 17 February 2028, Daniel compares two of his tables. daily_revenue says one total for Wednesday. revenue_by_payment_method says about ₹3 crore less.

Our biggest sale ever · Black Friday

Flat 50% Off

Pro

Continue reading

Unlock every course, now and later

  • System Design, live
  • AI Engineering, live
  • Data Engineering, live
  • Machine Learning Engineering, live
  • Inference Engineering, coming soon
  • AI Research, coming soon
  • Performance Engineering, coming soon
  • Agent & Harness Engineering, coming soon
  • LLM Fine-tuning, coming soon
  • LLM Pre-training & Post-training, coming soon
  • Reinforcement Learning, coming soon
  • AI Infrastructure & Platform Engineering, coming soon
  • AI Evaluation & Safety, coming soon
  • Forward Deployed Engineering, coming soon
  • Cloud Computing, coming soon
  • DevOps, coming soon

50% off · Annual and Lifetime

BLACKFRIDAY50Applied at checkout

Choose a plan