Certified Associate Developer for Apache Spark Practice Test

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

Question 56

The code block shown below contains an error. The code block is intended to return a new DataFrame that is the result of a position-wise union between DataFrame storesDF and DataFrame acquiredStoresDF. Identify the error. Code block: storesDF.unionByName(acquiredStoresDF)

  1. There is no DataFrame.unionByName() operation – the concat() operation should be used instead with both DataFrames as arguments.
  2. There are no key columns specified – similar column names should be the second argument.
  3. The DataFrame.unionByName() operation does not union DataFrames based on column position – it uses column name instead.
  4. The unionByName() operation is a standalone operation rather than a method of DataFrame – it should have both DataFrames as arguments.
  5. There are no column positions specified – the desired column positions should be the second argument.

Question 57

Which of the following code blocks writes DataFrame storesDF to file path filePath as JSON?

  1. storesDF.write.option("json").path(filePath)
  2. storesDF.write.json(filePath)
  3. storesDF.write.path(filePath)
  4. storesDF.write(filePath)
  5. storesDF.write().json(filePath)

Question 58

In what order should the below lines of code be run in order to write DataFrame storesDF to file path filePath as parquet and partition by values in column division? Lines of code: 1. .write() \ 2. .partitionBy("division") \ 3. .parquet(filePath) 4. .storesDF \ 5. .repartition("division") 6. .write \ 7. .path(filePath, "parquet")

  1. 4, 1, 2, 3
  2. 4, 1, 5, 7
  3. 4, 6, 2, 3
  4. 4, 1, 5, 3
  5. 4, 6, 2, 7

Question 59

The code block shown below contains an error. The code block intended to read a parquet at the file path filePath into a DataFrame. Identify the error. Code block: spark.read.load(filePath, source – "parquet")

  1. There is no source parameter to the load() operation – the schema parameter should be used instead.
  2. There is no load() operation – it should be parquet() instead.
  3. The spark.read operation should be followed by parentheses to return a DataFrameReader object.
  4. The filePath argument to the load() operation should be quoted.
  5. There is no source parameter to the load() operation – it can be removed.

Question 60

In what order should the below lines of code be run in order to read a JSON file at the file path filePath into a DataFrame with the specified schema schema? Lines of code: 1. .json(filePath, schema = schema) 2. .storesDF 3. .spark \ 4. .read() \ 5. .read \ 6. .json(filePath, format = schema)

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