
Answer-first summary for fast verification
Answer: To perform aggregation and convert rows into columns, transforming data from a long format to a wide format
The PIVOT clause in Spark SQL is designed for aggregating data and rotating rows into columns. This transformation changes the data from a long format, where data is listed in rows, to a wide format, where data is displayed in columns. It's especially useful for generating summary tables and facilitating data analysis.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
What is the primary function of the PIVOT clause in Spark SQL?
A
To merge multiple rows into a single row by creating a wider table with more columns
B
To perform aggregation and convert rows into columns, transforming data from a long format to a wide format
C
To filter rows based on a specified condition
D
To split a single column into multiple columns based on column values