0
0
dbtdata~10 mins

Built-in Jinja context variables in dbt - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to access the current model's name using a built-in Jinja variable.

dbt
SELECT * FROM {{ [1].this }}
Drag options to blanks, or click blank then click option'
Amodel
Bref
Cthis
Dconfig
Attempts:
3 left
💡 Hint
Common Mistakes
Using model instead of this.
Trying to use ref which is for referencing other models.
2fill in blank
medium

Complete the code to get the current model's schema using a built-in Jinja variable.

dbt
SELECT schema_name FROM information_schema.schemata WHERE schema_name = '{{ [1].schema }}'
Drag options to blanks, or click blank then click option'
Aadapter
Btarget
Cconfig
Dthis
Attempts:
3 left
💡 Hint
Common Mistakes
Using target.schema which refers to the target schema for the run, not the model's schema.
Using config.schema which is for configuration settings.
3fill in blank
hard

Fix the error in the code to correctly access the current model's alias using a built-in Jinja variable.

dbt
SELECT '{{ [1].alias }}' AS model_alias
Drag options to blanks, or click blank then click option'
Athis
Btarget
Cconfig
Dref
Attempts:
3 left
💡 Hint
Common Mistakes
Using target.alias which does not exist.
Using config.alias which is for configuration.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps each column name to its data type from the current model's columns.

dbt
{ [1]: [2] for col in this.columns }
Drag options to blanks, or click blank then click option'
Acol.name
Bcol.data_type
Ccol.type
Dcol.column_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using col.type which is not a valid attribute.
Using col.column_name which is not the correct attribute.
5fill in blank
hard

Fill all three blanks to create a filter that selects columns with data type 'string' and length greater than 10 from the current model's columns.

dbt
{col.name: col.data_type for col in this.columns if col.data_type == '[1]' and col.character_maximum_length [2] [3]
Drag options to blanks, or click blank then click option'
Ainteger
B>
C10
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'integer' instead of 'string' for data type.
Using '<' instead of '>' for length comparison.