我是Hadoop和Pig的初学者。我检查了在cloudera虚拟图像中证明的示例,并将其模拟为计算前5个常用词:
Lines = LOAD '/user/hue/pig/examples/data/midsummer.txt' as (line:CHARARRAY);
Words = FOREACH Lines GENERATE FLATTEN(TOKENIZE(line)) AS word;
Groups = GROUP Words BY word;
Counts = FOREACH Groups GENERATE group, COUNT(Words);
Results = ORDER Words BY Counts DESC;
Top5 = LIMIT Results 5;
STORE Top5 INTO /user/hue/pig/examples/data/summertop5Hi
但是,当我运行此脚本时,我收到此消息错误:
ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1000: Error during parsing. Lexical error at line 8, column 0. Encountered: <EOF> after : ""
这是什么意思?
答案 0 :(得分:3)
您需要在代码中修复三个问题才能使其正常工作
1。STORE stmt
未正确结束semicolon
2. STORE stmt
输出文件未正确包含在single quotes
中
3.需要在Counts and Results
stmt逻辑中稍作修改。
修改后的脚本:
Lines = LOAD '/user/hue/pig/examples/data/midsummer.txt' as (line:CHARARRAY);
Words = FOREACH Lines GENERATE FLATTEN(TOKENIZE(line)) AS word;
Groups = GROUP Words BY word;
Counts = FOREACH Groups GENERATE group, COUNT(Words) AS cnt;
Results = ORDER Counts BY cnt DESC;
Top5 = LIMIT Results 5;
STORE Top5 INTO '/user/hue/pig/examples/data/summertop5';
如果您在脚本中遇到任何问题,请与我们联系。