Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing local shell script commands in pig

Is it possible to exexute a shell script command from my unix directory in pig file system?

like image 546
dev_newbie Avatar asked Jul 12 '26 03:07

dev_newbie


1 Answers

Here's how you can run a shell command from within your Pig script:

--declare a shell command
%declare command `shell_command`
file = LOAD 'file.txt' AS (colA:chararray, colB:int) ;

file_processed = FOREACH file GENERATE colA, colB, (command) AS colC ;

The result of the shell_command execution would be available in command which is later substituted in the generate step.

like image 119
Prasoon Joshi Avatar answered Jul 15 '26 04:07

Prasoon Joshi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!