
Answer-first summary for fast verification
Answer: `spark.sql("select * from sales")`
The correct method to access any table in PySpark is by using the `spark.sql("select * from table_name")` method, which returns a DataFrame. Therefore, the correct answer is `spark.sql("select * from sales")`.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
A team of data analysts is working with a table named sales using SQL and seeks assistance from the data engineering team, who primarily use Python in Databricks notebooks. What is the correct method for the data engineers to query the sales table using PySpark?
A
spark.table("select * from sales")
B
"select * from sales"
C
spark.sql("select * from sales")
D
spark.sql("sales")
E
There is no way to access the sales table in a Python notebook