Filter a string on the basis of a word

冷暖自知 提交于 2020-01-01 03:11:51

问题


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+'  

回答1:


MATCHES uses regular expressions. You should do ... MATCHES '.*WORD.*' instead.

These is an example here finding the word 'apache'.



来源:https://stackoverflow.com/questions/7445832/filter-a-string-on-the-basis-of-a-word

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!