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
- A. 1. spark 2. createOrReplaceTempView 3. storesDF 4. query
- B. 1. spark 2. createTable 3. storesDF 4. sql
- C. 1. storesDF 2. createOrReplaceTempView 3. spark 4. query
- D. 1. spark 2. createOrReplaceTempView 3. storesDF 4. sql
- E. 1. storesDF 2. createOrReplaceTempView 3. spark 4. sql
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.