PIG: filter a string based on a word

I have a job with pigs, where I need to filter data by finding the word in it,

Here is a 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 on the third line when searching for C, I also tried using

  C = FILTER B BY $1 MATCHES '*WORD*' 

Besides

  C = FILTER B BY $1 MATCHES '\\w+WORD\\w+' 

Could you please correct and help me.

thanks

+6
source share
1 answer

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

Here is an example here to find the word "apache".

+15
source

Source: https://habr.com/ru/post/897471/


All Articles