Free Databricks Certified Associate Developer for Apache Spark 3.0 Exam Braindumps
Certified Associate Developer for Apache Spark Questions 56–60 (page: 13)

Updated On: 9-Feb-2026

In which order should the code blocks shown below be run in order to create a table of all values in column attributes next to the respective values in column supplier in DataFrame itemsDf?
1. itemsDf.createOrReplaceView("itemsDf")
2. spark.sql("FROM itemsDf SELECT 'supplier', explode('Attributes')")
3. spark.sql("FROM itemsDf SELECT supplier, explode(attributes)")
4. itemsDf.createOrReplaceTempView("itemsDf")

  1. 4, 3
  2. 1, 3
  3. 2
  4. 4, 2
  5. 1, 2

Answer(s): A

Explanation:

Static notebook | Dynamic notebook: See test 1, Question: 56 ( Databricks import instructions)



The code block shown below should return a copy of DataFrame transactionsDf without columns value and productId and with an additional column associateId that has the value 5. Choose the

answer that correctly fills the blanks in the code block to accomplish this. transactionsDf.
1 ( 2 , 3 ). 4 ( 5 , 'value')

  1. 1. withColumn
    2. 'associateId' 3. 5
    4. remove
    5. 'productId'
  2. 1. withNewColumn
    2. associateId
    3. lit(5)
    4. drop
    5. productId
  3. 1. withColumn
    2. 'associateId'
    3. lit(5)
    4. drop
    5. 'productId'
  4. 1. withColumnRenamed
    2. 'associateId' 3. 5
    4. drop
    5. 'productId'
  5. 1. withColumn
    2. col(associateId)
    3. lit(5)
    4. drop
    5. col(productId)

Answer(s): C

Explanation:

Correct code block:
transactionsDf.withColumn('associateId', lit(5)).drop('productId', 'value')
For solving this Question: it is important that you know the lit() function (link to documentation below). This function enables you to add a column of a constant value to a DataFrame.
More info: pyspark.sql.functions.lit — PySpark 3.1.1 documentation
Static notebook | Dynamic notebook: See test 1, Question: 57 (Databricks import instructions)



The code block shown below should write DataFrame transactionsDf as a parquet file to path storeDir, using brotli compression and replacing any previously existing file. Choose the answer that correctly fills the blanks in the code block to accomplish this.
transactionsDf. 1 .format("parquet"). 2 ( 3 ).option( 4 , "brotli"). 5 (storeDir)

  1. 1. save
    2. mode
    3. "ignore"
    4. "compression"
    5. path
  2. 1. store
    2. with
    3. "replacement"
    4. "compression"
    5. path
  3. 1. write
    2. mode
    3. "overwrite"
    4. "compression"
    5. save
  4. 1. save
    2. mode
    3. "replace"
    4. "compression"
    5. path
  5. 1. write
    2. mode
    3. "overwrite"
    4. compression
    5. parquet

Answer(s): C



The code block shown below should write DataFrame transactionsDf as a parquet file to path storeDir, using brotli compression and replacing any previously existing file. Choose the answer that correctly fills the blanks in the code block to accomplish this.
transactionsDf. 1 .format("parquet"). 2 ( 3 ).option( 4 , "brotli"). 5 (storeDir)

  1. 1. save
    2. mode
    3. "ignore"
    4. "compression"
    5. path
  2. 1. store
    2. with
    3. "replacement"
    4. "compression"
    5. path
  3. 1. write
    2. mode
    3. "overwrite"
    4. "compression"
    5. save (Correct)
  4. 1. save
    2. mode
    3. "replace"
    4. "compression"
    5. path
  5. 1. write
    2. mode
    3. "overwrite"
    4. compression
    5. parquet

Answer(s): D

Explanation:

Correct code block: transactionsDf.write.format("parquet").mode("overwrite").option("compression", "snappy").save(storeDir)
Solving this Question: requires you
to know how to access the DataFrameWriter (link below) from the DataFrame API - through DataFrame.write.
Another nuance here is about knowing the different modes available for writing parquet files that determine Spark's behavior when dealing with existing files. These, together with the compression options are explained in the DataFrameWriter.parquet documentation linked below.
Finally, bracket 5 poses a certain challenge. You need to know which command you can use to pass down the file path to the DataFrameWriter. Both save and parquet are valid options here.
More info:
- DataFrame.write: pyspark.sql.DataFrame.write — PySpark 3.1.1 documentation
- DataFrameWriter.parquet: pyspark.sql.DataFrameWriter.parquet — PySpark 3.1.1 documentation Static notebook | Dynamic notebook: See test 1, Question: 58 (Databricks import instructions)



Which of the following code blocks silently writes DataFrame itemsDf in avro format to location fileLocation if a file does not yet exist at that location?

  1. itemsDf.write.avro(fileLocation)
  2. itemsDf.write.format("avro").mode("ignore").save(fileLocation)
  3. itemsDf.write.format("avro").mode("errorifexists").save(fileLocation)
  4. itemsDf.save.format("avro").mode("ignore").write(fileLocation)
  5. spark.DataFrameWriter(itemsDf).format("avro").write(fileLocation)

Answer(s): A

Explanation:

The trick in this Question: is knowing
the "modes" of the DataFrameWriter. Mode ignore will ignore if a file already exists and not replace that file, but also not throw an error. Mode errorifexists will throw an error, and is the default mode of the DataFrameWriter. The Question: explicitly calls for the DataFrame to be "silently" written if it does not exist, so you need to specify mode("ignore") here to avoid having Spark communicate any error to you if the file already exists.
The `overwrite' mode would not be right here, since, although it would be silent, it would overwrite the already-existing file. This is not what the Question: asks for.
It is worth noting that the option starting with spark.DataFrameWriter(itemsDf) cannot work, since spark references the SparkSession object, but that object does not provide the DataFrameWriter.

As you can see in the documentation (below), DataFrameWriter is part of PySpark's SQL API, but not of its SparkSession API.
More info:
DataFrameWriter: pyspark.sql.DataFrameWriter.save — PySpark 3.1.1 documentation SparkSession API: Spark SQL — PySpark 3.1.1 documentation
Static notebook | Dynamic notebook: See test 1, Question: 59 (Databricks import instructions)



Viewing page 13 of 37
Viewing questions 61 - 65 out of 342 questions


Post your Comments and Discuss Databricks Databricks Certified Associate Developer for Apache Spark 3.0 exam prep with other Community members:

AI Tutor AI Tutor 👋 I’m here to help!