Which line of code loads all rows from the Product table into a DataFrame using Spark SQL?

Prepare for the DP-600 Fabric Analytics Engineer Exam. Test your knowledge with multiple choice questions and detailed explanations. Gear up for your success now!

Multiple Choice

Which line of code loads all rows from the Product table into a DataFrame using Spark SQL?

Explanation:
Running a SQL query through SparkSession.sql is how you use Spark SQL to load data into a DataFrame. The line spark.sql("SELECT * FROM Product") asks Spark to query the Product table and return every row as a DataFrame. It leverages the Spark SQL engine to read from the catalog and materialize the full result set when you trigger an action. The other options either use the DataFrameReader API directly (not Spark SQL), load from a file rather than a registered table, or apply a limit (TOP 100) that would exclude some rows.

Running a SQL query through SparkSession.sql is how you use Spark SQL to load data into a DataFrame. The line spark.sql("SELECT * FROM Product") asks Spark to query the Product table and return every row as a DataFrame. It leverages the Spark SQL engine to read from the catalog and materialize the full result set when you trigger an action.

The other options either use the DataFrameReader API directly (not Spark SQL), load from a file rather than a registered table, or apply a limit (TOP 100) that would exclude some rows.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy