Return 布尔值(1 或 0)如果 table 包含重复行

Return Boolean (1 or 0) if table contains duplicate rows

如果 Hive 0.9 中的 table 中存在重复项,我希望 return 一个布尔值 现在,我正在这样做:

select cast(case when count(*) > 0 then 1 else 0 end as smallint) Validate_Value 
from  (
    select guid, count(guid) cnt 
    from default.vms_feed v 
    group by guid
) where v.cnt > 1 ;

但这给了我一个错误:

"cannot recognize input near 'where' 'v' '.' in subquery source [DB Errorcode=11] "

我不确定我哪里出错了或者我在这里遗漏了什么!

Hive 子查询的正确语法是:

SELECT ... FROM (subquery) name ...

所以在你的情况下

SELECT CAST(...) Validate_Value 
FROM (
   ... 
) v WHERE v.cnt > 1 ;