pig基本语法——order by limit

2021-05-14 17:00:06 浏览数 (1)

主要参考:

https://book.itxueyuan.com/3b7D/XDBe

基础数据:

==============================================

[root@cdh1 data]# cat demodata

xiaoxiao,12,12.1f

aaa,13,1.1f

kjkj,12,12.1f

ddf,19,12.8f

youyou,89,12.3f

==============================================

grunt> A = load '/root/xytest/pig/data/demodata' using PigStorage(',') as (name:chararray,age:int,gpa:float);

grunt> B = order A by age DESC;

grunt> dump B;

输出结果:

(youyou,89,12.3)

(ddf,19,12.8)

(aaa,13,1.1)

(kjkj,12,12.1)

(xiaoxiao,12,12.1)

能够看到结果已经根据第二列倒叙排列了。

==============================================

主要参考:

https://book.itxueyuan.com/3b7D/BDOK

limit 主要用于限定输出数量

==============================================

[root@cdh1 data]# cat demodata

xiaoxiao,12,12.1f

aaa,13,1.1f

kjkj,12,12.1f

ddf,19,12.8f

youyou,89,12.3f

==============================================

grunt> A = load '/root/xytest/pig/data/demodata' using PigStorage(',') as (name:chararray,age:int,gpa:float);

grunt> B = limit A 3;

grunt> dump B;

运行结果:

(aaa,13,1.1)

(kjkj,12,12.1)

(xiaoxiao,12,12.1)

本文来源0day__,由javajgs_com转载发布,观点不代表Java架构师必看的立场,转载请标明来源出处

0 人点赞