QuestionQ66

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

A Data Analyst is working with sensor_df. This DataFrame has two columns: record_datetime (timestamp) and record (array).

Which code fragment returns a DataFrame that separates the record column into individual columns and produces one row for each array item?

Explanation

explode returns one row for every element of an array. Exploding record into a struct column and selecting that struct's sensor_id, status, and health fields produces separate columns while preserving the timestamp for each emitted row.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!