Pig命令

来源:互联网 发布:数据分析管理师 编辑:程序博客网 时间:2024/06/05 22:46

一、Shell命令


1fs 例子

(1)创建文件夹

fs  -mkdir /tmp

(2)复制文件

fs  -copyFromLocal  file-x  file-y

(3)列出文件

fs  -ls  file-y

2、sh pig脚本或Grunt shell 中调用任意sh Shell命令

注意只有真正的程序才可以从sh命令中运行,像<cd>命令不是程序而是shell环境的一部分,这样是不可以运行的,除非用户准确的调用了shell,像<bash cd>

例如:

sh ls 

< 用sh这个shell  (sh一般指系统默认shell,比如 bash, ksh, Csh 等都有可能来解释和运行脚本。>

二、常用命令


1、exec的例子

(1)显示和运行脚本

grunt> cat myscript.piga = LOAD 'student' AS (name, age, gpa);b = LIMIT a 3;DUMP b;grunt> exec myscript.pig(alice,20,2.47)(luke,18,4.00)(holly,24,3.27)

(2)带参数的运行命令

grunt> cat myscript.piga = LOAD 'student' AS (name, age, gpa);b = ORDER a BY name;STORE b into '$out';grunt> exec –param out=myoutput myscript.pig

(3)带多个参数的命令

grunt> exec –param p1=myparam1 –param p2=myparam2 myscript.pig</span>

2、run的例子

(1)通过Grunt Shell使脚本和命令的结果进行交互。

grunt> cat myscript.pigb = ORDER a BY name;c = LIMIT b 10;grunt> a = LOAD 'student' AS (name, age, gpa);grunt> run myscript.piggrunt> d = LIMIT c 3;grunt> DUMP d;(alice,20,2.47)(alice,27,1.95)(alice,36,2.27)

(2)带参数的运行命令

grunt> a = LOAD 'student' AS (name, age, gpa);grunt> cat myscript.pigb = ORDER a BY name;STORE b into '$out';grunt> run –param out=myoutput myscript.pig
网址:http://pig.apache.org/docs/r0.9.2/cmds.html





0 0
原创粉丝点击