
Ultimate access to all questions.
A data engineer needs to create a database called customer360 at the location /customer/customer360. The data engineer is unsure if one of their colleagues has already created the database.
Which of the following commands should the data engineer run to complete this task?
A
CREATE DATABASE customer360 LOCATION '/customer/customer360';
B
CREATE DATABASE IF NOT EXISTS customer360;
C
CREATE DATABASE IF NOT EXISTS customer360 LOCATION '/customer/customer360';
D
CREATE DATABASE IF NOT EXISTS customer360 DELTA LOCATION '/customer/customer360';
E
CREATE DATABASE customer360 DELTA LOCATION '/customer/customer360';
Explanation:
The correct answer is C because:
IF NOT EXISTS clause: This is essential since the data engineer is unsure if the database already exists. Without this clause, running the command would fail with an error if the database already exists.
LOCATION specification: The requirement explicitly states the database should be created at the location /customer/customer360. This needs to be included in the command.
Syntax correctness: The syntax CREATE DATABASE IF NOT EXISTS database_name LOCATION 'path' is the correct Spark SQL syntax for creating a database with a specific location if it doesn't already exist.
Why other options are incorrect:
IF NOT EXISTS clause - would fail if database already existsLOCATION specification - would create database at default location, not at /customer/customer360DELTA keyword is not valid in CREATE DATABASE statementIF NOT EXISTS clause and has incorrect DELTA keyword - would fail if database exists and has invalid syntaxThis question tests knowledge of Spark SQL DDL commands for database creation with conditional execution and custom location specification.