Databricks-Spark-Assoc Using Spark SQL Practice Question
A data engineer runs the following statement in a Databricks notebook: CREATE OR REPLACE TEMP VIEW high_value_customers AS SELECT customer_id, SUM(amount) AS total FROM sales GROUP BY customer_id HAVING SUM(amount) > 10000. Later, the same engineer opens a new notebook attached to the same cluster and tries to run SELECT * FROM high_value_customers. What will happen?
⚠ Common exam trap
The trap here is assuming that two notebooks attached to the same cluster share one SparkSession and therefore share temporary views, when in fact each notebook session has its own session-scoped catalog.
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
✓
The query fails with TABLE_OR_VIEW_NOT_FOUND because the temporary view is scoped to the SparkSession that created it and is not visible to a different notebook session.
Temporary views are registered in a session-scoped catalog, so a view created in one notebook is invisible to other notebooks even when they run on the same cluster. A second notebook gets its own SparkSession and cannot resolve the view name, producing TABLE_OR_VIEW_NOT_FOUND. To share results across sessions, the engineer must persist them as a table in the metastore or use a global temporary view in the global_temp database.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The query fails with an analysis error only if the underlying sales table was dropped; otherwise the temporary view remains globally accessible.
Why it's wrong here
The existence of the base table sales has no bearing on whether the temporary view name resolves in a different session. Even if sales still exists, the view definition is registered only in the creating session's catalog. Dropping the base table would instead cause a different error when the view definition is resolved, not a visibility problem.
- ✗
The query succeeds only if the second notebook calls REFRESH TABLE high_value_customers before selecting from it, because temp views are lazily registered.
Why it's wrong here
REFRESH TABLE is used to refresh the cached metadata and file listing of a persistent table, typically in the Hive metastore or Delta catalog. It has no effect on temporary view visibility and cannot make a session-scoped view resolvable from another SparkSession. The failure is about catalog scope, not stale metadata, so refreshing would not help here.
- ✓
The query fails with TABLE_OR_VIEW_NOT_FOUND because the temporary view is scoped to the SparkSession that created it and is not visible to a different notebook session.
Why this is correct
Temporary views live in the session-scoped catalog of the SparkSession that created them. A second notebook attached to the same cluster receives a separate SparkSession, so the name high_value_customers cannot be resolved and Spark raises TABLE_OR_VIEW_NOT_FOUND. Persisting the result as a managed or external table would be required for cross-notebook visibility.
- ✗
The query succeeds because temporary views are stored in the cluster-wide Spark catalog and shared across all notebooks on that cluster.
Why it's wrong here
A TEMP VIEW is registered in the session catalog, which is scoped to the SparkSession that created it, not to the cluster. A second notebook on the same cluster gets its own SparkSession and therefore cannot resolve the view name. Only a GLOBAL TEMP VIEW, which is stored in the global_temp database, would be visible across sessions on the same cluster.
Visual reference
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 →
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.