Databricks Certified Associate Developer for Apache Spark — Question 178
What happens if a developer registers two DataFrames with the same view name, myView using the createOrReplaceTempView function?
Answer options
- A. Both DataFrames will be accessible under the same view name.
- B. The DataFrames merged into one under the view name myView.
- C. An Exception is thrown, indicating a duplicate view named myView.
- D. The previous view will be replaced by the new DataFrame’s view.
Correct answer: D
Explanation
The correct answer is D because using createOrReplaceTempView will replace any existing view with the new DataFrame's view if they share the same name. Option A is incorrect as both views cannot coexist; option B is not applicable since merging does not happen in this context. Option C is false because no exception is thrown; the existing view is simply replaced.