Exam Associate-Developer-Apache-Spark-3.5 Topic 1 Question 22 Discussion

Actual exam question for Databricks's Associate-Developer-Apache-Spark-3.5 exam
Question #: 22
Topic #: 1
A Data Analyst is working on the DataFrame sensor_df, which contains two columns:
Which code fragment returns a DataFrame that splits the record column into separate columns and has one array item per row?
A)

B)

C)

D)

Suggested Answer: C Vote an answer

To flatten an array of structs into individual rows and access fields within each struct, you must:
Use explode() to expand the array so each struct becomes its own row.
Access the struct fields via dot notation (e.g., record_exploded.sensor_id).
Option C does exactly that:
First, explode the record array column into a new column record_exploded.
Then, access fields of the struct using the dot syntax in select.
This is standard practice in PySpark for nested data transformation.
Final answer: C

by pankaj.k.shukla at Sep 28, 2026, 11:41 AM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
pankaj.k.shukla
2026-09-28 11:41:37
None of the given answers is correct as written. Options B and C are identical. If the order of the statements is reversed in either B or C—so that explode() is executed before select()—that option would be correct.
upvoted 2 times
...
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

0
0
0
10