Databricks Certified Associate Developer for Apache Spark — Question 106

The code block shown below should use SQL to return a new DataFrame containing column storeId and column managerName from a table created from DataFrame storesDF. Choose the response that correctly fills in the numbered blanks within the code block to complete this task.

Code block:

__1__.__2__("stores")
__3__.__4__("SELECT storeId, managerName FROM stores")

Answer options

Correct answer: E

Explanation

The correct answer is E because it correctly uses storesDF to create a temporary view with createOrReplaceTempView and then runs the SQL query with sql. Option A is incorrect because 'query' is not a valid method, and options B and D incorrectly use 'createTable' and do not align the order of the parameters. Option C incorrectly places 'spark' where 'storesDF' should be.