Bird
0
0

Which YAML snippet correctly calls this test for column age with range 18 to 65?

hard📝 Application Q15 of 15
dbt - Advanced Testing
You want to create a generic test that checks if a numeric column's values are within a custom range using parameters min_value and max_value. Which YAML snippet correctly calls this test for column age with range 18 to 65?
Atests: - within_range('age', 18, 65)
Btests: - within_range: column: 'age' min: 18 max: 65
Ctests: - within_range: column_name: 'age' min_value: 18 max_value: 65
Dtests: - within_range: column_name: age min_value: '18' max_value: '65'
Step-by-Step Solution
Solution:
  1. Step 1: Use correct parameter names

    The test expects parameters named 'column_name', 'min_value', and 'max_value'.
  2. Step 2: Use correct YAML syntax and types

    tests: - within_range: column_name: 'age' min_value: 18 max_value: 65 uses correct parameter names and numeric values without quotes for numbers.
  3. Step 3: Check other options

    Function call syntax is invalid in YAML; incorrect parameter names like 'column', 'min', 'max'; unquoted column name and quoted numbers may cause type issues.
  4. Final Answer:

    tests: - within_range: column_name: 'age' min_value: 18 max_value: 65 -> Option C
  5. Quick Check:

    Correct params + types = tests: - within_range: column_name: 'age' min_value: 18 max_value: 65 [OK]
Quick Trick: Match parameter names and use correct YAML types [OK]
Common Mistakes:
MISTAKES
  • Using wrong parameter keys like 'column' or 'min'
  • Passing numbers as strings
  • Using function call syntax in YAML

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes