how to declare a variable in PIG? suppose i want to have a integer to have values as 10 how can i declare it in script? and how schema can be reused ?
Asked
Active
Viewed 2.1k times
1 Answers
11
I think you can use the 'Declare' command. It is used to describe one parameter and is used within the PIG script.
%declare DESC 'Database'
A = load 'data' as (name, desc);
B = FILTER A by desc eq '$DESC';
.....
You can get more about it here. Pig Parameter
-
There shouldn't have been a '$' before the DESC declaration. I fixed it, should work now. – kubi May 14 '14 at 21:58
-
It should start working in Pig version 0.14.0 according to https://issues.apache.org/jira/browse/PIG-2122 – Ankit Dhingra Aug 07 '15 at 18:33