DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK-3-0 practice question 24 of 25
Which of the following code blocks writes DataFrame itemsDf to disk at storage location filePath, making sure to substitute any existing data at that location?
Full set: 180 questionsitemsDf.write.mode("overwrite").parquet(filePath) Correct! itemsDf.write returns a pyspark.sql.DataFrameWriter instance whose overwriting behavior can be modified via the mode setting or by passing mode="overwrite" to the parquet() command. Although the parquet format is not prescribed for solving this question, parquet() is a valid operator to initiate Spark to write the data to disk. itemsDf.write.mode("overwrite").path(filePath) No. A pyspark.sql.DataFrameWriter instance does not have a path() method. itemsDf.write.option("parquet").mode("overwrite").path(filePath) Incorrect, see above. In addition, a file format cannot be passed via the option() method. itemsDf.write(filePath, mode="overwrite") Wrong. Unfortunately, this is too simple. You need to obtain access to a DataFrameWriter for the DataFrame through calling itemsDf.write upon which you can apply further methods to control how Spark data should be written to disk. You cannot, however, pass arguments to itemsDf.write directly. itemsDf.write().parquet(filePath, mode="overwrite") False. See above. More info: pyspark.sql.DataFrameWriter.parquet — PySpark 3.1.2 documentation Static notebook | Dynamic notebook: See test 3,
Keep practicing
Take the free DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK-3-0 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK-3-0 practice questions
- Question 1The code block displayed below contains an error. The code block is intended to perform a…
- Question 2Which of the following code blocks shows the structure of a DataFrame in a tree-like way,…
- Question 3Which of the following code blocks reads the parquet file stored at filePath into DataFra…
- Question 4Which of the following code blocks returns a 2-column DataFrame that shows the distinct v…
- Question 5The code block shown below should return an exact copy of DataFrame transactionsDf that d…
- Question 6The code block displayed below contains an error. The code block should configure Spark t…
