
Answer-first summary for fast verification
Answer: df.createOrReplaceTempView('people_view')
The correct answer is A because it correctly uses the 'createOrReplaceTempView' method to create a temporary view named 'people_view' that can be used in subsequent SQL queries. This method ensures that the view is always up-to-date with the DataFrame.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
You have a DataFrame df loaded from a JSON file with columns 'id', 'name', and 'age'. You need to create a temporary view named 'people_view' that can be used in subsequent SQL queries. How would you achieve this using PySpark?
A
df.createOrReplaceTempView('people_view')
B
df.createTempView('people_view')
C
df.createOrReplaceGlobalTempView('people_view')
D
df.createGlobalTempView('people_view')