Free Databricks Certified Associate Developer for Apache Spark 3.0 Exam Braindumps
Certified Associate Developer for Apache Spark Questions 51–55 (page: 12)

Updated On: 9-Feb-2026

The code block displayed below contains an error. The code block should return a DataFrame where all entries in column supplier contain the letter combination et in this order. Find the error.
Code block: itemsDf.filter(Column('supplier').isin('et'))

  1. The Column operator should be replaced by the col operator and instead of isin, contains should be used.
  2. The expression inside the filter parenthesis is malformed and should be replaced by isin('et', 'supplier').
  3. Instead of isin, it should be checked whether column supplier contains the letters et, so isin should be replaced with contains. In addition, the column should be accessed using col['supplier'].
  4. The expression only returns a single column and filter should be replaced by select.

Answer(s): B

Explanation:

Correct code block: itemsDf.filter(col('supplier').contains('et'))
A mixup can easily happen here between isin and contains. Since we want to check whether a column "contains" the values et, this is the operator we should use here. Note that both methods are methods of Spark's Column object. See below for documentation links.
A specific Column object can be accessed through the col() method and not the Column() method or through col[], which is an essential thing to know here. In PySpark, Column references a generic column object. To use it for queries, you need to link the generic column object to a specific DataFrame. This can be achieved, for example, through the col() method.

More info:
- isin documentation: pyspark.sql.Column.isin — PySpark 3.1.1 documentation
- contains documentation: pyspark.sql.Column.contains — PySpark 3.1.1 documentation

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



The code block shown below should write DataFrame transactionsDf to disk at path csvPath as a single CSV file, using tabs (\t characters) as separators between columns, expressing missing values as string n/a, and omitting a header row with column names. Choose the answer that correctly fills the blanks in the code block to accomplish this.
transactionsDf. 1 .write. 2 ( 3 , " "). 4 . 5 (csvPath)

  1. 1. coalesce(1)
    2. option
    3. "sep"
    4. option("header", True)
    5. path
  2. 1. coalesce(1)
    2. option
    3. "colsep"
    4. option("nullValue", "n/a")
    5. path
  3. 1. repartition(1)
    2. option
    3. "sep"
    4. option("nullValue", "n/a")
    5. csv
  4. 1. csv
    2. option
    3. "sep"
    4. option("emptyValue", "n/a")
    5. path
  5. 1. repartition(1)
    2. mode
    3. "sep"
    4. mode("nullValue", "n/a")
    5. csv

Answer(s): C

Explanation:

Correct code block:
transactionsDf.repartition(1).write.option("sep", "\t").option("nullValue", "n/a").csv(csvPath)
It is important here to understand that the Question: specifically asks for writing the DataFrame as a single CSV file. This should trigger you to think about partitions. By default, every partition is written as a separate file, so you need to include repatition(1) into your call. coalesce(1) works here, too!
Secondly, the Question: is very much an invitation to search through the parameters in the Spark documentation that work with DataFrameWriter.csv (link below). You will also need to know
that you need an option() statement to apply these parameters.
The final concern is about the general call structure. Once you have called accessed write of your DataFrame, options follow and then you write the DataFrame with csv. Instead of csv(csvPath), you could also use save(csvPath, format='csv') here.
More info: pyspark.sql.DataFrameWriter.csv — PySpark 3.1.1 documentation
Static notebook | Dynamic notebook: See test 1, Question: 52 (Databricks import instructions)



Which of the following code blocks returns a new DataFrame with only columns predError and values of every second row of DataFrame transactionsDf?

Entire DataFrame transactionsDf:

  1. transactionsDf.filter(col("transactionId").isin([3,4,6])).select([predError, value])
  2. transactionsDf.select(col("transactionId").isin([3,4,6]), "predError", "value")
  3. transactionsDf.filter("transactionId" % 2 == 0).select("predError", "value")
  4. transactionsDf.filter(col("transactionId") % 2 == 0).select("predError", "value")
  5. 1. transactionsDf.createOrReplaceTempView("transactionsDf")
    2. spark.sql("FROM transactionsDf SELECT predError, value WHERE transactionId % 2 = 2")
  6. transactionsDf.filter(col(transactionId).isin([3,4,6]))

Answer(s): D

Explanation:

Output of correct code block:


This is not an easy Question: to solve. You need to know that % stands for the module operator in Python. % 2 will return true for every second row. The statement using spark.sql gets it almost right (the modulo operator exists in SQL as well), but % 2 = 2 will never yield true, since modulo 2 is either 0 or 1.
Other answers are wrong since they are missing quotes around the column names and/or use filter or select incorrectly.
If you have any doubts about SparkSQL and answer options 3 and 4 in this question, check out the notebook I created as a response to a related student question.
Static notebook | Dynamic notebook: See test 1, Question: 53 (Databricks import instructions)



The code block displayed below contains an error. The code block should display the schema of DataFrame transactionsDf. Find the error.
Code block:
transactionsDf.rdd.printSchema

  1. There is no way to print a schema directly in Spark, since the schema can be printed easily through using print(transactionsDf.columns), so that should be used instead.
  2. The code block should be wrapped into a print() operation.
  3. printSchema is only accessible through the spark session, so the code block should be rewritten as spark.printSchema(transactionsDf).
  4. printSchema is a method and should be written as printSchema(). It is also not callable through transactionsDf.rdd, but should be called directly from transactionsDf.
  5. printSchema is a not a method of transactionsDf.rdd. Instead, the schema should be printed via transactionsDf.print_schema().

Answer(s): D

Explanation:

Correct code block:
transactionsDf.printSchema()
This is more of a knowledge Question: that you
should just memorize or look up in the provided documentation during the exam. You can get more info about DataFrame.printSchema() in the documentation (link below). However - it is a plain simple method without any arguments.
One answer points to an alternative of printing the schema: You could also use print(transactionsDf.schema). This will give you readable, but not nicely formatted, description of the schema.
More info: pyspark.sql.DataFrame.printSchema — PySpark 3.1.1 documentation
Static notebook | Dynamic notebook: See test 1, Question: 54 (Databricks import instructions)



Which of the following code blocks returns a one-column DataFrame of all values in column supplier of DataFrame itemsDf that do not contain the letter X? In the DataFrame, every value should only be listed once.
Sample of DataFrame itemsDf:

  1. itemsDf.filter(col(supplier).not_contains('X')).select(supplier).distinct()
  2. itemsDf.select(~col('supplier').contains('X')).distinct()
  3. itemsDf.filter(not(col('supplier').contains('X'))).select('supplier').unique()
  4. itemsDf.filter(~col('supplier').contains('X')).select('supplier').distinct()
  5. itemsDf.filter(!col('supplier').contains('X')).select(col('supplier')).unique()

Answer(s): D

Explanation:

Output of correct code block:

Key to managing this Question: is understand which operator to use to do the opposite of an operation – the ~ (not) operator. In addition, you should know that there is no unique() method.
Static notebook | Dynamic notebook: See test 1, Question: 55 (Databricks import instructions)



Viewing page 12 of 37
Viewing questions 56 - 60 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!