Farhan Ahmed Wasim
Farhan Ahmed Wasim

Reputation: 949

How to create a TABLE with SELECT from another TABLE in spark using SQL

I have a table saved in HDFS called usedcars. I want to create another table based on the output of a select statement on this table as follows

%spark.sql
CREATE TABLE cleanusedcars
AS (
select (maker, model, mileage, manufacture_year, engine_displacement, engine_power, transmission, door_count, seat_count, fuel_type, date_created, date_last_seen, price_eur)
from usedcars
where maker is not null and model is not null and price_eur <= 2000000 and price_eur >= 3000 and manufacture_year <= 2017 and manufacture_year >= 2000
)

I am using spark SQL in a zeppelin notebook. The error I am getting is Error message

Please help! Thanks.

Upvotes: 0

Views: 2271

Answers (1)

mck
mck

Reputation: 42352

Remove the parenthesis from select(...). If you include parenthesis, the select statement will be interpreted as selecting a single struct column of all the columns you have selected.

Upvotes: 1

Related Questions