0
0
dbtdata~20 mins

dbt-utils package tests - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
dbt-utils Master Tester
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of dbt_utils.equality test on two tables
Given two tables table_a and table_b with identical columns and data, what will be the result of running the dbt_utils.equality test comparing these tables?
dbt
select * from {{ dbt_utils.equality('table_a', 'table_b') }}
ATest passes with no failures
BTest fails showing all rows as mismatched
CSyntax error due to missing parameters
DTest returns an empty result set but marked as failed
Attempts:
2 left
💡 Hint
Think about what happens when two tables have exactly the same data.
data_output
intermediate
2:00remaining
Result of dbt_utils.unique_combination_of_columns test
You run the dbt_utils.unique_combination_of_columns test on a table with columns user_id and order_id. The table has duplicate rows where user_id and order_id repeat. What will the test output show?
dbt
select * from {{ dbt_utils.unique_combination_of_columns('orders', ['user_id', 'order_id']) }}
AOnly unique rows with no duplicates
BRows that have duplicate combinations of user_id and order_id
CAll rows in the table
DAn error because the columns list is not a string
Attempts:
2 left
💡 Hint
The test finds duplicates in the specified columns.
🔧 Debug
advanced
2:00remaining
Identify the error in dbt_utils.not_null test usage
What error will occur when running this test?
select * from {{ dbt_utils.not_null('customers', 'customer_id, email') }}
dbt
select * from {{ dbt_utils.not_null('customers', 'customer_id, email') }}
ATest returns rows with nulls in customer_id only
BTest passes with no errors
CRuntime error because table does not exist
DCompilation error due to passing columns as a single string instead of a list
Attempts:
2 left
💡 Hint
Check the expected data type for the columns parameter.
🚀 Application
advanced
2:00remaining
Using dbt_utils.expression_is_true to test a condition
You want to test that all rows in the sales table have amount > 0. Which is the correct way to write this test using dbt_utils.expression_is_true?
Aselect * from {{ dbt_utils.expression_is_true('sales', amount > 0) }}
Bselect * from {{ dbt_utils.expression_is_true('sales', 'amount >= 0') }}
Cselect * from {{ dbt_utils.expression_is_true('sales', 'amount > 0') }}
Dselect * from {{ dbt_utils.expression_is_true('sales', ['amount > 0']) }}
Attempts:
2 left
💡 Hint
The expression parameter must be a string representing the condition.
🧠 Conceptual
expert
3:00remaining
Understanding the output of dbt_utils.surrogate_key test
You use dbt_utils.surrogate_key macro to generate a surrogate key from columns first_name and last_name. What is the expected output type and behavior of this macro?
AIt returns a hashed string combining the specified columns, suitable as a unique key
BIt returns a numeric auto-incrementing ID for each row
CIt returns a concatenated string of the columns separated by underscores
DIt returns a boolean indicating if the columns are unique
Attempts:
2 left
💡 Hint
Think about what a surrogate key is and how hashing helps.