Bird
0
0

You want to log the current model name and the target database in a dbt model using Jinja. Which snippet correctly uses built-in context variables to achieve this?

hard📝 Application Q8 of 15
dbt - Jinja in dbt
You want to log the current model name and the target database in a dbt model using Jinja. Which snippet correctly uses built-in context variables to achieve this?
A{% do log('Model: ' ~ target.name ~ ', Database: ' ~ this.database) %}
B{% do log('Model: ' ~ this.name ~ ', Database: ' ~ target.database) %}
C{% do log('Model: ' ~ invocation_id ~ ', Database: ' ~ run_started_at) %}
D{% do log('Model: ' ~ this.schema ~ ', Database: ' ~ target.schema) %}
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct variables for model name and database

    this.name gives the current model name; target.database gives the target database.
  2. Step 2: Check string concatenation and log syntax

    Using ~ concatenates strings in Jinja; log is called correctly with the message.
  3. Final Answer:

    {% do log('Model: ' ~ this.name ~ ', Database: ' ~ target.database) %} -> Option B
  4. Quick Check:

    Use this.name and target.database for model and DB [OK]
Quick Trick: Use this.name for model and target.database for DB [OK]
Common Mistakes:
MISTAKES
  • Swapping this and target properties
  • Using invocation_id for model name
  • Concatenation syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes