Hive报错"Expression not in GROUP BY key"的解决方案
Hive报错"Expression not in GROUP BY key"的解决方案
hive写查询语句时如果需要分组,且有些查询的列不需要变化,那么直接写会报错,需要写成collect_set("列名")[0] as "列名"
例如SELECT id, latitude, longitude FROM t_po GROUP BY id ;会报错,应该写成
SELECT id, collect_set(latitude)[0] as latitude, collect_set(longitude)[0] as longitude FROM t_po GROUP BY id ;