
Answer-first summary for fast verification
Answer: DataFrame.count()
The correct operation to return the number of rows in a DataFrame is `DataFrame.count()`. Option D is correct because `count()` is the standard Spark DataFrame action that triggers computation and returns the total row count. - **A**: `numberOfRows()` is not a valid DataFrame method in Apache Spark. - **B**: `n()` is not a recognized method for counting rows in Spark. - **C**: `sum()` aggregates numerical columns and does not count rows. - **E**: `countDistinct()` is used for counting distinct values in columns, not total rows. Thus, only option D is correct.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.