Certified Associate Developer for Apache Spark Practice Test

Certified Associate Developer for Apache Spark Practice Test practice questions, page 4 of 14, with answer review and explanations.

Question 16

Which of the following operations can be used to create a new DataFrame that has 12 partitions from an original DataFrame df that has 8 partitions?

  1. df.repartition(12)
  2. df.cache()
  3. df.partitionBy(1.5)
  4. df.coalesce(12)
  5. df.partitionBy(12)

Question 17

Which of the following object types cannot be contained within a column of a Spark DataFrame?

  1. DataFrame
  2. String
  3. Array
  4. null
  5. Vector

Question 18

Which of the following operations can be used to create a DataFrame with a subset of columns from DataFrame storesDF that are specified by name?

  1. storesDF.subset()
  2. storesDF.select()
  3. storesDF.selectColumn()
  4. storesDF.filter()
  5. storesDF.drop()

Question 19

The code block shown below contains an error. The code block is intended to return a DataFrame containing all columns from DataFrame storesDF except for column sqft and column customerSatisfaction. Identify the error. Code block: storesDF.drop(sqft, customerSatisfaction)

  1. The drop() operation only works if one column name is called at a time – there should be two calls in succession like storesDF.drop("sqft").drop("customerSatisfaction").
  2. The drop() operation only works if column names are wrapped inside the col() function like storesDF.drop(col(sqft), col(customerSatisfaction)).
  3. There is no drop() operation for storesDF.
  4. The sqft and customerSatisfaction column names should be quoted like "sqft" and "customerSatisfaction".
  5. The sqft and customerSatisfaction column names should be subset from the DataFrame storesDF like storesDF."sqft" and storesDF."customerSatisfaction".

Question 20

Which of the following code blocks returns a DataFrame containing only the rows from DataFrame storesDF where the value in column sqft is less than or equal to 25,000?

  1. storesDF.filter("sqft" <= 25000)
  2. storesDF.filter(sqft > 25000)
  3. storesDF.where(storesDF[sqft] > 25000)
  4. storesDF.where(sqft > 25000)
  5. storesDF.filter(col("sqft") <= 25000)