Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+7 votes
4 views
in Big Data Hadoop & Spark by (47.6k points)

If I want to execute pig script from grunt shell what all do I need to have? I have copied the

.pig file and source file into the hdfs. what else do I need to copy? Can you please share

the execution command or statement along with step by step process how to execute the

pig script in grunt shell?

1 Answer

+9 votes
by (106k points)

To execute pig script from grunt shell you can use exec or run command. While the time of using the run command, all the commands present in the script file will be available in the grunt history, which is not the case with the exec command.

You can load the data file in PigStorage by using the following piece of code:-

product = LOAD 'hdfs://localhost:9000/product_dir/products.csv' USING PigStorage(',') as (product_id:int, product_name:chararray, price:int);

dump product;

After loading the data files the next thing you can do is execute the script file, which is stored in HDFS by using the following commands:-

exec hdfs://localhost:9000/script_dir/pig_script.pig

or

run hdfs://localhost:9000/script_dir/pig_script.pig

Related questions

+1 vote
1 answer
asked Aug 2, 2019 in R Programming by Sammy (47.6k points)
0 votes
1 answer
asked Jan 24, 2021 in Linux by dev_sk2311 (45k points)
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...