猪的参数替代

时间:2015-02-22 12:06:32

标签: apache-pig bigdata

students = load '/home/vm4learning/Desktop/students-db.txt' using PigStorage('|') as (rnum, sname, name, age, gender, class, subject, marks);

在使用/home/vm4learning/Desktop/students-db.txt的参数替换时,我遇到语法错误。 那么正确的命令是什么,在这里使用正确的语法。

由于

2 个答案:

答案 0 :(得分:1)

您需要指定Pig LOAD脚本的HDFS路径

首先,您需要在HDFS中复制输入文件,然后可以在猪脚本中指定hdfs路径

您可以使用hadoop put命令将输入​​文件复制到HDFS中:

hadoop fs -put /home/vm4learning/Desktop/students-db.txt /user/input

然后你可以在猪脚本中使用该路径

students = load '/user/input/students-db.txt' using PigStorage('|') as (.....);

UPDATE:

将您的猪脚本保存在包含扩展名.pig文件的文件中。

<强> process.pig:

students = load '$inputPath' using PigStorage('|') as (.....);

现在从终端您可以发出以下命令来执行您的pig文件,方法是将输入路径作为参数传递:

pig -p inputPath=/user/input/students-db.txt process.pig

有关详细信息,您可以check here

答案 1 :(得分:1)

使用pig -x filename dryrun -param key = value -param key2 = value2

相关问题