Reputation: 1883
I have to find a name given the first letter is 'P' and the last letter is 'l'. In sql, we would give it as 'P%%l'. In pig latin commands, how can this be given.
Upvotes: 1
Views: 910
Reputation: 1382
The Pig equivalent of SQL's '%' is '.*'
So you can use
X = FILTER A BY (name matches 'P.*I');
Reference: http://pig.apache.org/docs/r0.10.0/basic.html#comparison
Upvotes: 0
Reputation: 592
The format of regular expressions in Pig is that supported by Java So, use matches in FILTER: result = FILTER input BY name matches '^P.*I$'
Upvotes: 1
Reputation: 25909
You'd use the FILTER command with a regex e.g.
X = FILTER A BY (name matches '\AP\w*l\b');
Upvotes: 2