
Answer-first summary for fast verification
Answer: CREATE TABLE products USING CSV OPTIONS (path '/data/products.csv', header 'true', inferSchema 'true')
The correct answer is A because it correctly specifies the CSV options including the path, header, and inferSchema. The 'header' option is set to 'true' to indicate that the first row of the CSV file contains column names, and 'inferSchema' is set to 'true' to automatically infer the schema from the data.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
You are given a task to create a table named 'products' from an external CSV file located at '/data/products.csv'. The table should include columns 'product_id', 'product_name', and 'price'. Write the Spark SQL command to achieve this.
A
CREATE TABLE products USING CSV OPTIONS (path '/data/products.csv', header 'true', inferSchema 'true')
B
CREATE TABLE products USING CSV OPTIONS (path '/data/products.csv', header 'false', inferSchema 'true')
C
CREATE TABLE products USING CSV OPTIONS (path '/data/products.csv', header 'true', inferSchema 'false')
D
CREATE TABLE products USING CSV OPTIONS (path '/data/products.csv', header 'false', inferSchema 'false')
No comments yet.