报错信息,
org.apache.spark.sql.AnalysisException:
expression 'a.`site`' is neither present in the group by, nor is it an aggregate function.
Add to group by or wrap in first() (or first_value)
报错原因:spark sql 使用group by的时候必须将select的所有字段都写进去。
例如:
select a,b,c from table group by a;
就会报错
解决办法,在不需要group by的字段上加first()
select a,first(b),first(c) from table group by a;
这样就可以了。
本文介绍了在使用Spark SQL进行group by操作时遇到的错误,重点讲解了如何修复'expression 'a.site' is neither present in the group by, nor is it an aggregate function.'的问题,即在select语句中未包含所有group by字段时,需将非group by字段用first()函数处理。
2682

被折叠的 条评论
为什么被折叠?



