
Answer-first summary for fast verification
Answer: CREATE TABLE customer_email AS SELECT customer_id, email FROM customer_data
The correct answer is A, as it correctly uses the Spark SQL syntax to create a new table 'customer_email' by selecting only the 'customer_id' and 'email' columns from the 'customer_data' table. This approach is efficient and adheres to Spark SQL best practices. Option B uses incorrect syntax for table creation in Spark SQL. Option C uses a syntax that is not supported in Spark SQL for creating tables directly from a SELECT statement. Option D misses the 'AS' keyword which is necessary for the correct syntax in Spark SQL.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
In a scenario where you are working with a Delta Lake table named 'customer_data' that contains columns 'customer_id', 'first_name', 'last_name', and 'email', you are tasked with creating a new table 'customer_email' that includes only the 'customer_id' and 'email' columns. The solution must optimize for performance and adhere to best practices for Spark SQL queries. Considering the need for efficiency and correctness, which of the following Spark SQL queries would you use to accomplish this task? (Choose one correct option)
A
CREATE TABLE customer_email AS SELECT customer_id, email FROM customer_data
B
CREATE TABLE customer_email FROM customer_data (customer_id, email)
C
SELECT customer_id, email INTO customer_email FROM customer_data
D
CREATE TABLE customer_email SELECT customer_id, email FROM customer_data