PIG:根据单词过滤字符串 [英] PIG : Filter a string on the basis of a word
本文介绍了PIG:根据单词过滤字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一份猪工作,我需要通过查找一个词来过滤数据, 这里是摘录
A = LOAD'/ home / user / filename'使用PigStorage(',');
B = FOREACH A GENERATE $ 27,$ 38;
C = FILTER B BY($ 1 =='* Word *');
STORE C INTO'/ home / user / out1'使用PigStorage();
错误在第三行,而找到C,
i也尝试过使用 p>
C =过滤器B BY $ 1 MATCHES'* WORD *'
同样
C =过滤B BY $ 1 MATCHES'\\ w + WORD \\w +'
你能帮我纠正一下吗?
谢谢
解决方案
MATCHES
使用正则表达式。你应该做 ... MATCHES'。* WORD。*'
。
这是一个 here 找到'apache'这个词。
I have a pig job where in i need to filter the data by finding a word in it,
Here is the snippet
A = LOAD '/home/user/filename' USING PigStorage(',');
B = FOREACH A GENERATE $27,$38;
C = FILTER B BY ( $1 == '*Word*');
STORE C INTO '/home/user/out1' USING PigStorage();
the error is in the 3rd line while finding C, i have also tried using
C = FILTER B BY $1 MATCHES '*WORD*'
Also
C = FILTER B BY $1 MATCHES '\\w+WORD\\w+'
Can you please correct and help me out.
Thanks
解决方案
MATCHES
uses regular expressions. You should do ... MATCHES '.*WORD.*'
instead.
These is an example here finding the word 'apache'.
这篇关于PIG:根据单词过滤字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文