How to display a declared variable in PIG

I'm just wondering if there is a way to show a declared variable in PIG - for testing purposes (no UDF)?

So how to display $ DATE :

%declare DATE `date +%s`;

      

+3


source to share


3 answers


You can name your script as a dry run using the following:

pig -x local -r my_pig_script.pig

      

Will be displayed my_pig_script.pig.substituted

in your working directory. If you look at this file, all declared variables will be replaced with their values. This gives you a "preview" of what your work will be doing before sending it to the cluster.



Hope this helps!

Edit:

Dry run will also help you debug your script and identify any compilation errors before actually running.

+1


source


If you want to display a variable without saving it to a file, try the following:



%declare DATE `date +%Y%m%d_%H%M%S`;
sh echo $DATE;

      

+6


source


The STORE statement writes output to the file system; or, the DUMP statement displays the output to the screen

A = LOAD 'student' USING PigStorage() AS (name:chararray, age:int, gpa:float);
B = FOREACH A GENERATE name;
DUMP B;
(John)
(Mary)
(Bill)
(Joe)

      

For more information: https://pig.apache.org/docs/r0.7.0/piglatin_ref1.html

0


source







All Articles