Error in using Stream command in PIG


1 Answer(s)


Hi Sakshi,

If you are using the command, it should be inside the backticks ( ` ). Here are some information about STREAM.

STREAM

Sends data to an external script or program.

Syntax

alias = STREAM alias [, alias …] THROUGH {'command' | cmd_alias } [AS schema] ;

Terms

alias

The name of a relation.

THROUGH

Keyword.

'command'

A command, including the arguments, enclosed in back tics (where a command is anything that can be executed).

cmd_alias

The name of a command created using the DEFINE operator (see the DEFINE operator for additional streaming examples).

AS

Keyword.

Usage

Use the STREAM operator to send data through an external script or program. Multiple stream operators can appear in the same Pig script. The stream operators can be adjacent to each other or have other operations in between.

When used with a command, a stream statement could look like this:

A = LOAD 'data';

B = STREAM A THROUGH 'stream.pl -n 5';

When used with a cmd_alias, a stream statement could look like this, where mycmd is the defined alias.

A = LOAD 'data';

DEFINE mycmd 'stream.pl –n 5';

B = STREAM A THROUGH mycmd;

If you are referring to some other script, please share the script with me.

Please refer the below link for more information and examples:

https://pig.apache.org/docs/r0.7.0/piglatin_ref2.html#STREAM

 

Hope this helps.

Thanks.