火花错误:java.lang.RuntimeException:[5.52]故障:预计会出现``工会'',但`('

时间:2018-12-02 13:24:19

标签: sql scala apache-spark

下面的查询正在针对db工作,但给出错误为:

  

“ java.lang.RuntimeException:[5.52]错误:预期为“工会”,但   `('“ sum(如果action ='purchase,则1否则0结束的情况)作为purchase_count,

代码:

val activityByProduct = SQLContext.sql("""
    SELECT
        product,
        timestamp_hour
        sum(case when action = 'purchase' then 1 else 0 end) as purchase_count,
        |sum(case when action = 'add_to_cart' then 1 else 0 end) as add_to_cart,
        |sum(case when action = 'page_view' then 1 else 0 end) as page_view
    |from activity
    |group by product,timestamp_hour """)

如果我缺少某些东西,请有人帮助我。 谢谢

1 个答案:

答案 0 :(得分:1)

«timestamp_hour»后缺少昏迷。

SELECT
       product,
       timestamp_hour,<— HERE
        sum(case when action = 'purchase' then 1 else 0 end) as purchase_count,

还应删除所有« »您查询的字符