【问题标题】:MAX(Count) function apache pig latinMAX(Count) 函数 apache pig latin
【发布时间】:2017-03-01 01:12:48
【问题描述】:

下面这个程序我试图在 Apache Pig 和非结构化数据中完成它

i) 我有包含街道名称、城市和州的数据集:

ii) 按州分组

iii) 我正在获取数据集中的 COUNT(*) 个状态现在我的 o/p 将类似于 statename,count===>该状态在数据集中可用的时间

程序:

realestate = LOAD DATA using pigstorage(',') as (street:string,city string,state string);

A = GROUP realestate by state;
B= FOREACH A GENERATE group , count (*)

O/P 会像

CA,14
washington,20

现在我需要最大(计数)我的输出应该是“华盛顿,20)

如何进行。请帮我解决问题

【问题讨论】:

    标签: hadoop apache-pig hadoop-streaming hadoop-partitioning


    【解决方案1】:

    在生成的结果上应用ORDERLIMIT

    realestate = LOAD DATA using pigstorage(',') as (street:string,city string,state string);
    A = GROUP realestate by state;
    B = FOREACH A GENERATE group , COUNT(realestate) as c;
    
    # Arrange the tuples based on the count in descending order
    D = order B by c desc;
    
    # Apply limit on the ordered result to get the Max value
    E = LIMIT D 1;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-26
      • 1970-01-01
      • 1970-01-01
      • 2015-01-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多