Hive中典型的表内数据除重写法

    insert overwrite table store  
      select t.p_key,t.sort_word from   
        ( select p_key,  
               sort_word ,  
               row_number()over(distribute by p_key sort by sort_word) as rn  
         from store) t  
         where t.rn=1;  

Hive上一个典型表内除重的写法, p_key为除重依据, sort_word 为排序依据,一般为时间   rn为排名。 这里就留下第一名

注意hql 方言中, 表的嵌套要家别名, 字段前加上表别名。 union all 不支持顶层视图。

原文地址:https://www.cnblogs.com/itboys/p/6007609.html