I have two values in a PIG Latin script, what should I do to use them mathematically, like if I had two variables
A=(5)
B=(4)
How can I do A+B or something like that ?
I have two values in a PIG Latin script, what should I do to use them mathematically, like if I had two variables
A=(5)
B=(4)
How can I do A+B or something like that ?
On
Yes you can able to do any arithmetic operation in it but the thing is that any variable declaration is kind of different in pig latin -
what you have to do is -
% declare A 5 % declare B 4
and in any of the foreach statement you can use
dummy = foreach column-1,...., column-n, A+B as summation;
this would work.
Let me know if I fulfilled you need.
You need to use Foreach stmt to do any mathematical operation, please see the below sample example.
input.txt
Pigscript:
Output: