
Answer-first summary for fast verification
Answer: Both A & B
Delta tables in Databricks can be queried using standard SQL. Databricks notebooks support magic commands like %sql to directly execute SQL queries. Additionally, you can use the Spark SQL API within Python (using %python) to execute SQL queries against Delta tables. The spark.sql() method allows you to pass a SQL query string. Therefore, both options A and B are valid ways to query a Delta table. Incorrect options: - **%python execute.sql("select * from table")**: There is no standard execute.sql() method directly available under the spark object in PySpark for executing SQL queries. You should use spark.sql(). - **%python delta.sql("select * from table")**: While there is a delta package in Databricks for working with Delta Lake features, there isn’t a direct delta.sql() method for executing general SQL queries against Delta tables. You would still use spark.sql().
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
Which of the following commands can be used to query a delta table in Databricks?
A
%sql Select * from table_name
B
%python spark.sql("select * from table_name")
C
%python execute.sql("select * from table")
D
Both A & B
E
%python delta.sql("select * from table")
No comments yet.