我运行了以下命令,其中包括pig中的load和dump命令:我的文件在本地,我在独立的机器上。
grunt> custs = LOAD 'custs' USING PigStorage(',') As (id:long,name:chararray,surname:chararray,age:int,prof:chararray);
grunt> dump custs;
我收到了这个错误:
HadoopVersion PigVersion UserId StartedAt FinishedAt Features
2.7.1 0.15.0 sujit 2016-04-21 13:05:51 2016-04-21 13:05:51 UNKNOWN
Failed!
Failed Jobs:
JobId Alias Feature Message Outputs
N/A custs MAP_ONLY Message: java.lang.NullPointerException
Input(s):
Failed to read data from "file:///home/sujit/pig_data/custs"
Job DAG:
null
2016-04-21 13:05:51,277 [main] INFO org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MapReduceLauncher - Failed!
2016-04-21 13:05:51,278 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1066: Unable to open iterator for alias custs
Details at logfile: /home/sujit/pig_data/pig_1461220631975.log
但文件存在,具有必要的权限
sujit@sujit-pc:~/pig_data$ ls -l
total 4824
-rwxrwxrwx 1 sujit sujit 391355 Jun 9 2012 custs
答案 0 :(得分:0)
我收到此错误是因为我还没有将我的本地文件复制到 hdfs 。
要将文件从本地复制到hdfs,您可以使用命令
hdfs dfs -copyFromLocal yourFileNameHere.csv ~/yourFolder/yourFileNameHere.csv
*请注意,您必须先在hdfs中创建一个文件夹。这是通过像 -
这样的命令完成的hdfs dfs -mkdir /home/ubuntu/yourFolder
将我的本地文件复制到HDFS后,我不再收到错误。