Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a macro named 'get_active_users'.
dbt
{% macro [1]() %}
SELECT * FROM users WHERE active = true
{% endmacro %} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a macro name that does not match the task instruction.
Forgetting to include parentheses after the macro name.
✗ Incorrect
The macro name must be 'get_active_users' to match the task requirement.
2fill in blank
mediumComplete the code to call the macro 'get_active_users' inside a model.
dbt
SELECT * FROM {{ [1]() }} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the macro name without parentheses.
Using a wrong macro name.
✗ Incorrect
To call the macro, use its exact name 'get_active_users' inside double curly braces.
3fill in blank
hardFix the error in the macro call to correctly pass a parameter named 'status'.
dbt
SELECT * FROM {{ get_users(status=[1]) }} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing string parameters without quotes causing syntax errors.
Using mismatched or double quotes incorrectly.
✗ Incorrect
String parameters must be passed with quotes inside the macro call.
4fill in blank
hardFill both blanks to create a macro that accepts a parameter 'table_name' and returns a SELECT statement.
dbt
{% macro [1]([2]) %}
SELECT * FROM {{ table_name }}
{% endmacro %} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a parameter name different from the one used inside the macro body.
Forgetting parentheses around parameters.
✗ Incorrect
The macro name is 'select_all' and the parameter is 'table_name' as required.
5fill in blank
hardFill all three blanks to create a macro that filters a table by a given column and value.
dbt
{% macro [1]([2], [3]) %}
SELECT * FROM {{ table }} WHERE {{ column }} = {{ value }}
{% endmacro %} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching parameter names and variables inside the macro body.
Forgetting commas between parameters.
✗ Incorrect
The macro name is 'filter_table' and parameters are 'table' and 'column' to match the body variables.