DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #39
In what order should the below lines of code be run in order to write DataFrame storesDF to file path filePath as parquet and partition by values in column division? Lines of code: 1. .write() \ 2…
The correct answer is C. 4, 6, 2, 3. The correct sequence is lines 4, 6, 2, 3: storesDF → .write → .partitionBy("division") → .parquet(filePath). write is a property (not a method), so line 1 (.write() with parentheses) is invalid. Line 5 (.repartition("division")) physically repartitions data in memory/cluster…
Question
Options
- A4, 1, 2, 3
- B4, 1, 5, 7
- C4, 6, 2, 3
- D4, 1, 5, 3
- E4, 6, 2, 7
How the community answered
(46 responses)- A7% (3)
- B2% (1)
- C89% (41)
- E2% (1)
Explanation
The correct sequence is lines 4, 6, 2, 3: storesDF → .write → .partitionBy("division") → .parquet(filePath). write is a property (not a method), so line 1 (.write() with parentheses) is invalid. Line 5 (.repartition("division")) physically repartitions data in memory/cluster but does not create on-disk partition directories - .partitionBy() on the DataFrameWriter is required for that. Line 7 (.path(filePath, "parquet")) does not exist as a valid DataFrameWriter method. Only option C assembles the correct chain using the property form of write.
Topics
Community Discussion
No community discussion yet for this question.