Free Databricks Certified Associate Developer for Apache Spark 3.0 Exam Braindumps
Certified Associate Developer for Apache Spark Questions 21–85 (page: 18)

Updated On: 9-Feb-2026

Which of the following code blocks selects all rows from DataFrame transactionsDf in which column productId is zero or smaller or equal to 3?

  1. transactionsDf.filter(productId==3 or productId<1)
  2. transactionsDf.filter((col("productId")==3) or (col("productId")<1))
  3. transactionsDf.filter(col("productId")==3 | col("productId")<1)
  4. transactionsDf.where("productId"=3).or("productId"<1))
  5. transactionsDf.filter((col("productId")==3) | (col("productId")<1))

Answer(s): E

Explanation:

This Question: targets your
knowledge about how to chain filtering conditions. Each filtering condition should be in parentheses. The correct operator for "or" is the pipe character (|) and not the word or. Another operator of concern is the equality operator. For the purpose of comparison, equality is expressed as two equal signs (==).
Static notebook | Dynamic notebook: See test 2, Question: 21 (Databricks import instructions)



Which of the following code blocks sorts DataFrame transactionsDf both by column storeId in ascending and by column productId in descending order, in this priority?

  1. transactionsDf.sort("storeId", asc("productId"))
  2. transactionsDf.sort(col(storeId)).desc(col(productId))
  3. transactionsDf.order_by(col(storeId), desc(col(productId)))
  4. transactionsDf.sort("storeId", desc("productId"))
  5. transactionsDf.sort("storeId").sort(desc("productId"))

Answer(s): D

Explanation:

In this Question: it is
important to realize that you are asked to sort transactionDf by two columns. This means that the sorting of the second column depends on the sorting of the first column.

So, any option that sorts the entire DataFrame (through chaining sort statements) will not work. The two columns need to be channeled through the same call to sort(). Also, order_by is not a valid DataFrame API method.
More info: pyspark.sql.DataFrame.sort — PySpark 3.1.2 documentation
Static notebook | Dynamic notebook: See test 2, Question: 22 (Databricks import instructions)



The code block displayed below contains an error. The code block should produce a DataFrame with color as the only column and three rows with color values of red, blue, and green, respectively.

Find the error.
Code block:
1. spark.createDataFrame([("red",), ("blue",), ("green",)], "color") Instead of calling spark.createDataFrame, just DataFrame should be called.

  1. The commas in the tuples with the colors should be eliminated.
  2. The colors red, blue, and green should be expressed as a simple Python list, and not a list of tuples.
  3. Instead of color, a data type should be specified.
  4. The "color" expression needs to be wrapped in brackets, so it reads ["color"].

Answer(s): D

Explanation:

Correct code block:
spark.createDataFrame([("red",), ("blue",), ("green",)], ["color"])
The createDataFrame syntax is not exactly straightforward, but luckily the documentation (linked below) provides several examples on how to use it. It also shows an example very similar to the
code block presented here which should help you answer this Question: correctly. More info: pyspark.sql.SparkSession.createDataFrame — PySpark 3.1.2 documentation
Static notebook | Dynamic notebook: See test 2, Question: 23 (Databricks import instructions)



The code block displayed below contains an error. The code block should return all rows of DataFrame transactionsDf, but including only columns storeId and predError. Find the error.
Code block:
spark.collect(transactionsDf.select("storeId", "predError"))

  1. Instead of select, DataFrame transactionsDf needs to be filtered using the filter operator.
  2. Columns storeId and predError need to be represented as a Python list, so they need to be wrapped in brackets ([]).
  3. The take method should be used instead of the collect method.
  4. Instead of collect, collectAsRows needs to be called.
  5. The collect method is not a method of the SparkSession object.

Answer(s): E

Explanation:

Correct code block:
transactionsDf.select("storeId", "predError").collect() collect() is a method of the DataFrame object.
More info: pyspark.sql.DataFrame.collect — PySpark 3.1.2 documentation Static notebook | Dynamic notebook: See test 2, Question: 24 (
Databricks import instructions)



The code block shown below should store DataFrame transactionsDf on two different executors, utilizing the executors' memory as much as possible, but not writing anything to disk. Choose the answer that correctly fills the blanks in the code block to accomplish this.

1. from pyspark import StorageLevel
2. transactionsDf. 1 (StorageLevel. 2 ). 3

  1. 1. cache
    2. MEMORY_ONLY_2
    3. count()
  2. 1. persist
    2. DISK_ONLY_2
    3. count()
  3. 1. persist
    2. MEMORY_ONLY_2
    3. select()
  4. 1. cache
    2. DISK_ONLY_2
    3. count()
  5. 1. persist
    2. MEMORY_ONLY_2
    3. count()

Answer(s): E

Explanation:

Correct code block:
from pyspark import StorageLevel transactionsDf.persist(StorageLevel.MEMORY_ONLY_2).count()
Only persist takes different storage levels, so any option using cache() cannot be correct. persist() is evaluated lazily, so an action needs to follow this command. select() is not an action, but count() is – so all options using select() are incorrect.
Finally, the Question: states that
"the executors' memory should be utilized as much as possible, but not writing anything to disk". This points to a MEMORY_ONLY storage level. In this storage level, partitions that do not fit into memory will be recomputed when they are needed, instead of being written to disk, as with the storage option MEMORY_AND_DISK. Since the data need to be duplicated across two executors, _2 needs to be appended to the storage level.
Static notebook | Dynamic notebook: See test 2, Question: 25 (Databricks import instructions)



Viewing page 18 of 37
Viewing questions 86 - 90 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!