【发布时间】:2015-02-18 23:05:07
【问题描述】:
我想在 Hive 的表中查找重复项,如下所示。
ID name phone
1 John 602-230-4040
2 Brian 602-230-3030
3 John 602-230-4040
4 Brian 602-230-3030
5 Jeff 602-230-4040
在关系数据库中,使用带有 group by 和 having 子句的 count 函数的最简单方法。当我使用以下查询时,
select count(name, phone) cnt, name, phone from mytest group by name, phone having cnt>1;
以下异常被抛出
FAILED: UDFArgumentException DISTINCT keyword must be specified
然后我在查询中使用了 distinct 关键字。
select count(distinct name, phone) cnt, name, phone from mytest group by name, phone having cnt>1;
显然查询没有返回任何行,因为如果我使用 distinct 关键字,结果中不会有任何重复记录。
我不确定为什么 Hive 在与 group by 子句一起使用时强制使用 distinct 关键字和 count 函数。
谁能告诉我如何在 Hive 表中查找重复项?
【问题讨论】:
标签: hive