如何使用 SQL 在 spark 中从另一个 TABLE 创建一个带有 SELECT 的 TABLE

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

我有一个 table 保存在名为 usedcars 的 HDFS 中。我想根据此 table 上 select 语句的输出创建另一个 table,如下所示

%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
)

我在 zeppelin 笔记本中使用 spark SQL。我得到的错误是

请帮忙!谢谢。

删除 select(...) 中的括号。如果包含括号,select 语句将被解释为 selecting 您 selected 的所有列的单个结构列。