nerdexam
Microsoft

DP-203 · Question #150

Drag and Drop Question You have an Apache Spark DataFrame named temperatures. A sample of the data is shown in the following table. You need to produce the following table by using a Spark SQL…

The correct answer is PIVOT; CAST. PIVOT is correct because it transforms row-level data into columns, which is exactly what's needed to convert temperature readings (stored as rows per category) into a wide-format table with each category as its own column. CAST is correct because the pivoted numeric values…

Submitted by yaw92· Mar 30, 2026Transform and query data using Apache Spark SQL - specifically reshaping tabular data with PIVOT and ensuring correct data types with CAST, typically aligned with Azure Databricks or DP-203 Data Engineering certification objectives.

Question

Drag and Drop Question You have an Apache Spark DataFrame named temperatures. A sample of the data is shown in the following table. You need to produce the following table by using a Spark SQL query. How should you complete the query? To answer, drag the appropriate values to the correct targets. Each value may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content. NOTE: Each correct selection is worth one point. Answer:

Exhibit

DP-203 question #150 exhibit

Answer Area

Drag items

CASTCOLLATECONVERTFLATTENPIVOTUNPIVOT

Correct arrangement

  • PIVOT
  • CAST

Explanation

PIVOT is correct because it transforms row-level data into columns, which is exactly what's needed to convert temperature readings (stored as rows per category) into a wide-format table with each category as its own column. CAST is correct because the pivoted numeric values need to be explicitly converted to the appropriate data type (e.g., CAST as INT or FLOAT) to ensure proper formatting in the output table. Together, PIVOT restructures the data shape and CAST ensures correct data typing.

Topics

#Spark SQL#PIVOT transformation#DataFrame reshaping#Type casting

Community Discussion

No community discussion yet for this question.

Full DP-203 Practice