Bird
0
0

Which of the following is the correct syntax to use the pivot macro in dbt-utils?

easy📝 Syntax Q12 of 15
dbt - Packages and Reusability
Which of the following is the correct syntax to use the pivot macro in dbt-utils?
A{% set pivoted = dbt_utils.unpivot(table=ref('sales'), column='month', value='revenue') %}
B{% set pivoted = dbt_utils.surrogate_key(columns=['id', 'date']) %}
C{% set pivoted = dbt_utils.pivot(table=ref('sales'), column='month', value='revenue') %}
D{% set pivoted = dbt_utils.pivot(table='sales', row='month', value='revenue') %}
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct macro and parameters

    The pivot macro requires a table, a column to pivot on, and a value column.
  2. Step 2: Check syntax correctness

    {% set pivoted = dbt_utils.pivot(table=ref('sales'), column='month', value='revenue') %} uses table=ref('sales'), column='month', and value='revenue', which is correct.
  3. Final Answer:

    {% set pivoted = dbt_utils.pivot(table=ref('sales'), column='month', value='revenue') %} -> Option C
  4. Quick Check:

    pivot syntax = table, column, value [OK]
Quick Trick: pivot needs table, column, and value parameters [OK]
Common Mistakes:
MISTAKES
  • Using unpivot macro instead of pivot
  • Passing wrong parameter names like 'row' instead of 'column'
  • Not using ref() for table argument

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes