Data Analytics

dbt - Advanced Features

Jinja macros, custom tests, packages, hooks, snapshots, incremental models, CI/CD orchestration

20 interview questionsยท
Senior
1

What is the difference between a macro and a model in dbt?

Answer

A macro is a reusable Jinja code block that generates SQL dynamically, while a model is a SQL file that produces a table or view in the data warehouse. Macros help factorize repetitive code and create custom functions, whereas models define the structure of transformed data.

2

How to declare a custom macro in dbt?

Answer

A dbt macro is declared in a .sql file within the macros/ folder using Jinja macro and endmacro tags. The macro name is defined in the macro tag, and it can accept parameters. The macro is then callable in models using the Jinja double curly braces syntax.

3

What is the main benefit of incremental models in dbt?

Answer

Incremental models allow processing only new or modified data since the last run, instead of rebuilding the entire table. This significantly reduces execution time and compute costs for large tables, while keeping data up to date.

4

What configuration is required to define an incremental model in dbt?

5

What is the purpose of the merge strategy in a dbt incremental model?

+17 interview questions

Master Data Analytics for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free