Bird
0
0

You want to write a custom test in dbt to check that the 'price' column is always greater than zero. Which approach correctly applies this test?

hard📝 Application Q8 of 15
dbt - Advanced Testing
You want to write a custom test in dbt to check that the 'price' column is always greater than zero. Which approach correctly applies this test?
AUse the built-in unique test on price column
BAdd 'greater_than_zero' under tests in schema.yml without SQL file
CCreate a SQL file in tests/ folder with a query filtering price <= 0 and reference it in schema.yml
DWrite a Python script to check price values outside dbt
Step-by-Step Solution
Solution:
  1. Step 1: Understand how to create custom tests in dbt

    Custom tests require SQL files with logic and referencing them in schema.yml.
  2. Step 2: Evaluate options

    Create a SQL file in tests/ folder with a query filtering price <= 0 and reference it in schema.yml correctly describes creating a SQL test and linking it. Others are incorrect or outside dbt.
  3. Final Answer:

    Create a SQL file in tests/ folder with a query filtering price <= 0 and reference it in schema.yml -> Option C
  4. Quick Check:

    Custom tests need SQL files and schema.yml reference [OK]
Quick Trick: Custom tests require SQL files and schema.yml links [OK]
Common Mistakes:
MISTAKES
  • Assuming custom tests work without SQL files
  • Using built-in tests for unsupported checks
  • Running external scripts instead of dbt tests

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes