Bird
0
0

Which of the following is the correct syntax to define a sum metric named 'total_sales' in dbt YAML?

easy📝 Syntax Q3 of 15
dbt - Advanced Patterns
Which of the following is the correct syntax to define a sum metric named 'total_sales' in dbt YAML?
Ametrics: - name: total_sales model: sales type: sum expression: sales_amount
Bmetrics: - total_sales: model: sales type: sum expression: sales_amount
Cmetrics: - name: total_sales model: sales aggregation: sum column: sales_amount
Dmetrics: - name: total_sales model: ref('sales') type: sum expression: sales_amount
Step-by-Step Solution
Solution:
  1. Step 1: Check correct YAML keys and structure

    The metric should have 'name', 'model' (using ref), 'type', and 'expression' keys.
  2. Step 2: Validate syntax correctness

    metrics: - name: total_sales model: ref('sales') type: sum expression: sales_amount correctly uses 'model: ref('sales')', 'type: sum', and 'expression: sales_amount'.
  3. Final Answer:

    Correct YAML syntax with ref and sum type -> Option D
  4. Quick Check:

    Sum metric syntax = name, model ref, type, expression [OK]
Quick Trick: Use 'model: ref(...)' and 'type: sum' for sum metrics [OK]
Common Mistakes:
MISTAKES
  • Missing 'name' key or wrong indentation
  • Using 'aggregation' instead of 'type'
  • Not using ref() for model reference

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes