1. Databricks Documentation
"Tutorial: Load and transform data using Apache Spark DataFrames": This official tutorial demonstrates the use of spark.sql() to run SQL queries. Under the section "Run SQL queries"
it explicitly shows the syntax: df = spark.sql("SELECT FROM diamonds"). This directly supports option E.
Source: Databricks Documentation > Get started > Tutorials > Data engineering tutorials > Tutorial: Load and transform data using Apache Spark DataFrames.
2. Apache Spark Documentation
pyspark.sql.SparkSession.sql: The official PySpark API documentation defines the sql method on the SparkSession class. It states
"Returns a DataFrame representing the result of the given query."
Source: Apache Spark 3.4.1 Documentation > API Docs > PySpark > pyspark.sql > pyspark.sql.SparkSession.
3. Apache Spark Documentation
pyspark.sql.SparkSession.table: The same PySpark API documentation defines the table method. It states
"Returns the specified table or view as a DataFrame
" and its parameter is tableName
not a SQL query. This confirms why option C is incorrect.
Source: Apache Spark 3.4.1 Documentation > API Docs > PySpark > pyspark.sql > pyspark.sql.SparkSession.
4. Databricks Documentation
"Databricks Utilities (dbutils)": This page lists all available dbutils modules
such as dbutils.fs
dbutils.widgets
and dbutils.secrets. It confirms that a dbutils.sql utility does not exist
making option D incorrect.
Source: Databricks Documentation > Reference > Utilities > Databricks Utilities (dbutils).