Free Databricks Certified Associate Developer for Apache Spark 3.0 Exam Braindumps
Certified Associate Developer for Apache Spark Questions 26–90 (page: 19)

Updated On: 9-Feb-2026

The code block displayed below contains an error. The code block should return a copy of DataFrame transactionsDf where the name of column transactionId has been changed to transactionNumber. Find the error. Code block:
transactionsDf.withColumn("transactionNumber", "transactionId")

  1. The arguments to the withColumn method need to be reordered.
  2. The arguments to the withColumn method need to be reordered and the copy() operator should be appended to the code block to ensure a copy is returned.
  3. The copy() operator should be appended to the code block to ensure a copy is returned.
  4. Each column name needs to be wrapped in the col() method and method withColumn should be replaced by method withColumnRenamed.
  5. The method withColumn should be replaced by method withColumnRenamed and the arguments to the method need to be reordered.

Answer(s): E

Explanation:

Correct code block:
transactionsDf.withColumnRenamed("transactionId", "transactionNumber")
Note that in Spark, a copy is returned by default. So, there is no need to append copy() to the code block.
More info: pyspark.sql.DataFrame.withColumnRenamed — PySpark 3.1.2 documentation Static notebook | Dynamic notebook: See test 2, Question: 26 (
Databricks import instructions)



Which of the following code blocks performs an inner join between DataFrame itemsDf and DataFrame transactionsDf, using columns itemId and transactionId as join keys, respectively?

  1. itemsDf.join(transactionsDf, "inner", itemsDf.itemId == transactionsDf.transactionId)
  2. itemsDf.join(transactionsDf, itemId == transactionId)
  3. itemsDf.join(transactionsDf, itemsDf.itemId == transactionsDf.transactionId, "inner")
  4. itemsDf.join(transactionsDf, "itemsDf.itemId == transactionsDf.transactionId", "inner")
  5. itemsDf.join(transactionsDf, col(itemsDf.itemId) == col(transactionsDf.transactionId))

Answer(s): C

Explanation:

More info: pyspark.sql.DataFrame.join — PySpark 3.1.2 documentation
Static notebook | Dynamic notebook: See test 2, Question: 27 ( Databricks import instructions)



The code block shown below should return only the average prediction error (column predError) of a random subset, without replacement, of approximately 15% of rows in DataFrame transactionsDf. Choose the answer that correctly fills the blanks in the code block to accomplish this. transactionsDf. 1 ( 2 , 3 ). 4 (avg('predError'))

  1. 1. sample
    2. True 3. 0.15
    4. filter
  2. 1. sample
    2. False 3. 0.15
    4. select
  3. 1. sample 2. 0.85
    3. False
    4. select
  4. 1. fraction 2. 0.15
    3. True
    4. where
  5. 1. fraction
    2. False 3. 0.85
    4. select

Answer(s): B

Explanation:

Correct code block:
transactionsDf.sample(withReplacement=False, fraction=0.15).select(avg('predError'))
You should remember that getting a random subset of rows means sampling. This, in turn should point you to the DataFrame.sample() method. Once you know this, you can look up the correct order of arguments in the documentation (link below).
Lastly, you have to decide whether to use filter, where or select. where is just an alias for filter(). filter() is not the correct method to use here, since it would only allow you to filter rows based on some condition. However, the Question: asks to return only the average prediction error. You can control the columns that a query returns with the select() method – so this is the correct method to use here.

More info: pyspark.sql.DataFrame.sample — PySpark 3.1.2 documentation
Static notebook | Dynamic notebook: See test 2, Question: 28 (Databricks import instructions)



Which of the following code blocks returns a single-column DataFrame showing the number of words in column supplier of DataFrame itemsDf?

Sample of DataFrame itemsDf:

  1. itemsDf.split("supplier", " ").count()
  2. itemsDf.split("supplier", " ").size()
  3. itemsDf.select(word_count("supplier"))
  4. spark.select(size(split(col(supplier), " ")))
  5. itemsDf.select(size(split("supplier", " ")))

Answer(s): E

Explanation:

Output of correct code block:

This Question: shows a typical use case for the split command: Splitting a string into words. An additional difficulty is that you are asked to count the words. Although it is tempting to use the count method here, the size method (as in: size of an array) is actually the correct one to use. Familiarize yourself with the split and the size methods using the linked documentation below.

More info:
Split method: pyspark.sql.functions.split — PySpark 3.1.2 documentation Size method: pyspark.sql.functions.size — PySpark 3.1.2 documentation
Static notebook | Dynamic notebook: See test 2, Question: 29 (Databricks import instructions)



Which of the following code blocks stores DataFrame itemsDf in executor memory and, if insufficient memory is available, serializes it and saves it to disk?

  1. itemsDf.persist(StorageLevel.MEMORY_ONLY)
  2. itemsDf.cache(StorageLevel.MEMORY_AND_DISK)
  3. itemsDf.store()
  4. itemsDf.cache()
  5. itemsDf.write.option('destination', 'memory').save()

Answer(s): D

Explanation:

The key to solving this Question: is knowing
(or reading in the documentation) that, by default, cache() stores values to memory and writes any partitions for which there is insufficient memory to disk. persist() can achieve the exact same behavior, however not with the StorageLevel.MEMORY_ONLY option listed here. It is also worth noting that cache() does not have any arguments.
If you have troubles finding the storage level information in the documentation, please also see this student Q&A thread that sheds some light here.
Static notebook | Dynamic notebook: See test 2, Question: 30 (Databricks import instructions)



Viewing page 19 of 37
Viewing questions 91 - 95 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!