Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to select all columns from the source table.
dbt
select * from [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ref() instead of source() for external tables.
Using incorrect function names like load() or table().
✗ Incorrect
In dbt, the source() function is used to refer to tables from external sources.
2fill in blank
mediumComplete the code to join two source tables on the 'id' column.
dbt
select a.*, b.value from [1] as a join [2] as b on a.id = b.id
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing ref() and source() incorrectly.
Joining on wrong columns.
✗ Incorrect
Use source() to refer to external tables. Here, we join two source tables on 'id'.
3fill in blank
hardFix the error in the code to correctly union two source tables.
dbt
select * from [1] union all select * from [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same table for both selects.
Using ref() instead of source() for external tables.
✗ Incorrect
To union two different source tables, use source() with correct source and table names for each.
4fill in blank
hardFill both blanks to create a model that merges data from two sources using a full outer join.
dbt
select coalesce(a.id, b.id) as id, a.value as value_a, b.value as value_b from [1] as a full outer join [2] as b on a.id = b.id
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ref() instead of source() for external tables.
Using inner join instead of full outer join.
✗ Incorrect
Use source() to refer to external tables when merging data from different sources.
5fill in blank
hardFill all three blanks to create a dictionary comprehension that filters and transforms data from multiple sources.
dbt
result = { [1]: [2] for [3] in data if [2] > 10 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent variable names.
Using wrong keys or values in the dictionary.
✗ Incorrect
We iterate over each record in data, use record['id'] as key and record['value'] as value, filtering values greater than 10.