Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a snapshot in dbt.
dbt
snapshot my_snapshot {
[1]: 'my_source_table'
strategy: timestamp
updated_at: updated_at_column
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'target' instead of 'source' causes dbt to fail to find the input table.
Confusing 'table' or 'database' as the keyword.
✗ Incorrect
In dbt snapshots, the 'source' keyword specifies the source table to track changes from.
2fill in blank
mediumComplete the code to specify the snapshot strategy in dbt.
dbt
snapshot my_snapshot {
source: 'my_source_table'
strategy: [1]
updated_at: updated_at_column
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'merge' which is not a valid snapshot strategy in dbt.
Confusing 'incremental' with snapshot strategies.
✗ Incorrect
The 'timestamp' strategy tracks changes based on a timestamp column indicating last update time.
3fill in blank
hardFix the error in the snapshot config to correctly track changes by unique key.
dbt
snapshot my_snapshot {
source: 'my_source_table'
strategy: check
unique_key: [1]
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a timestamp column as unique_key causes incorrect snapshot behavior.
Using a non-unique column leads to duplicate records.
✗ Incorrect
The 'unique_key' should be the column that uniquely identifies each record, often an ID column.
4fill in blank
hardFill both blanks to create a snapshot that uses the 'check' strategy and tracks changes by 'email' column.
dbt
snapshot user_email_snapshot {
source: 'users'
strategy: [1]
unique_key: [2]
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'timestamp' strategy with 'email' unique key is inconsistent.
Using 'id' instead of 'email' when the task specifies email.
✗ Incorrect
The 'check' strategy compares specified columns for changes, and 'email' is used here as the unique key.
5fill in blank
hardFill all three blanks to define a snapshot with 'timestamp' strategy, track by 'last_modified', and use 'user_id' as unique key.
dbt
snapshot user_activity_snapshot {
source: [1]
strategy: [2]
unique_key: [3]
updated_at: last_modified
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong table name for source.
Confusing unique_key with updated_at column.
✗ Incorrect
The source table is 'users', strategy is 'timestamp', and unique_key is 'user_id' to track user activity changes.