dev_newbie
dev_newbie

Reputation: 33

Executing local shell script commands in pig

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

Upvotes: 3

Views: 2049

Answers (1)

Prasoon Joshi
Prasoon Joshi

Reputation: 799

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.

Upvotes: 4

Related Questions