Courseiva
Using Spark SQL →hardMultiple Select

Databricks-Spark-Assoc Using Spark SQL Practice Question

Which THREE of the following are valid ways to create a DataFrame from an existing table in Spark SQL?

⚠ Common exam trap

Candidates often select invalid or overly verbose DataFrame creation syntaxes, such as attempting to use non-existent SparkSession methods or confusing RDD loading commands with native table readers.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

spark.table('table_name')

Spark provides multiple entry points to access table data. You can use the 'spark.table()' method for direct catalog access, 'spark.sql()' to execute a SELECT statement, or the 'spark.read.table()' method. All three provide the same underlying Dataset/DataFrame API, allowing for flexible programmatic interaction with metadata managed by the Hive Metastore or Unity Catalog, ensuring consistency across different development styles and API usage patterns in Databricks.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    spark.table('table_name')

    Why this is correct

    The 'spark.table()' method is a direct and efficient way to create a DataFrame by looking up the table name in the catalog. It is highly readable and is the standard way to retrieve a persistent table as a DataFrame for further transformation using the Spark API.

  • ✓

    spark.sql('SELECT * FROM table_name')

    Why this is correct

    Using 'spark.sql()' allows you to leverage the full power of the Spark SQL parser to execute queries. This approach is useful when you need to perform filtering, joins, or projections at the time of loading the data into the DataFrame, reducing the need for subsequent transformations.

  • ✓

    spark.read.table('table_name')

    Why this is correct

    The 'spark.read.table()' method is part of the 'DataFrameReader' interface. It is syntactically consistent with other reader operations like 'spark.read.csv()' or 'spark.read.parquet()', making it the preferred choice for developers who want a unified coding pattern when loading data from various sources into the Spark environment.

  • ✗

    spark.open('table_name')

    Why it's wrong here

    There is no 'spark.open()' method in the SparkSession API. The reader API uses 'read', and the catalog API uses 'table'. Inventing methods that do not exist is a common trap; it is important to stick to the documented 'read' or 'table' methods provided by the Spark library.

  • ✗

    spark.from_table('table_name')

    Why it's wrong here

    The 'from_table' method does not exist in the SparkSession or DataFrameReader classes. Developers must use the standard 'table' or 'read.table' methods. Using incorrect method names will result in an AttributeError, as these functions are not part of the public Spark developer API for DataFrame creation.

About these practice questions

This Databricks-Spark-Assoc question is part of Courseiva's 295-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Databricks exam blueprint

This Databricks-Spark-Assoc practice question is part of Courseiva's free Databricks certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the Databricks-Spark-Assoc exam.