请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

执行sql报错

Exception in thread "main" org.apache.spark.sql.AnalysisException: grouping expressions sequence is empty, and 'ods_user_behavior_click.`uid`' is not an aggregate function. Wrap '((IF((sum(ods_user_behavior_click.`rating`) IS NULL), CAST(NULL AS DOUBLE), UDF(sum(rating)))) AS `rating`)' in windowing function(s) or wrap 'ods_user_behavior_click.`uid`' in first() (or first_value) if you don't care which value you get.;;
Aggregate [uid#4L, item_id#5L, if (isnull(sum(rating#6))) null else UDF(sum(rating#6)) AS rating#0]

正在回答

1回答

同学你好,在语句末尾要加上group by。

完整语句应该是,

spark.sql(

"select uid,item_id,

scaler(sum(score)) as rating from dws.dws_behavior_score 

where year='"+year+"' "+

"and month='"+month+"' "+

"and day='"+day+"' "+

"group by uid,item_id")

感谢指出,祝学习愉快!

0 回复 有任何疑惑可以回复我~
  • 提问者 恒量Qt #1
    非常感谢!老师的代码里没加group by,可以帮忙加上哈。
    回复 有任何疑惑可以回复我~ 2020-05-13 17:50:57
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信