参考官网地址:
http://pig.apache.org/docs/r0.17.0/basic.html
基础数据
# cat /root/xytest/pig/data/demodata
xiaoxiao,12,12.1
aaa,13,1.1
kjkj,12,12.1
ddf,19,12.8
常规的程序
目前使用的都是pig -x local方式的
A = load '/root/xytest/pig/data/demodata' using PigStorage(',') as (name:chararray,age:int,gpa:float);
B = foreach A generate name;
dump B;
运行结果:
(xiaoxiao)
(aaa)
(kjkj)
(ddf)
存储数据:
store C into '/root/xytest/pig/data/cc' using PigStorage(',');
打印数据的schema:
grunt> describe A;
A: {name: chararray,age: int,gpa: float}
以表的方式打印出A的schema,并且附带第一行数据。
grunt> illustrate A;
---------------------------------------------------------
| A | name:chararray | age:int | gpa:float |
---------------------------------------------------------
| | xiaoxiao | 12 | 12.1f |
---------------------------------------------------------
本文来源0day__,由javajgs_com转载发布,观点不代表Java架构师必看的立场,转载请标明来源出处