
Answer-first summary for fast verification
Answer: The third command fails, and the 'name' column is displayed as output.
This question tests your understanding of view creation and temporary views in Databricks. Here's what happens step by step: 1. `CREATE VIEW viewing AS SELECT age FROM viewer;` - This command executes successfully, creating a view named 'viewing'. 2. `CREATE TEMP VIEW viewing AS SELECT name FROM viewer;` - This also executes successfully, creating a temporary view named 'viewing' which shadows the first view. 3. `CREATE VIEW viewing AS SELECT age FROM viewer;` - This command fails because a view named 'viewing' already exists. 4. `SELECT * FROM viewing;` - This command outputs the 'name' column from the temporary view, not the 'age' column from the original view. To access the 'age' column, you'd need to specify the database name with the view, e.g., `SELECT * FROM db_name.viewing;`. Remember, `SHOW VIEWS;` can list all active views, including their associated database names.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
What will be the outcome of executing the following set of statements in a Databricks notebook, assuming 'viewer' is a pre-defined delta table with columns 'name' and 'age'?
CREATE VIEW viewing AS SELECT age FROM viewer; CREATE TEMP VIEW viewing AS SELECT name FROM viewer; CREATE VIEW viewing AS SELECT age FROM viewer; SELECT * FROM viewing;
A
All commands execute successfully, displaying the 'age' column as output.
B
The third command fails, and the 'name' column is displayed as output.
C
All commands execute successfully, displaying the 'name' column as output.
D
The second and third commands fail, and the 'age' column is displayed as output.
E
All commands execute successfully, but no output is displayed.
No comments yet.