You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Arun A K <ar...@gmail.com> on 2011/02/13 07:59:31 UTC

Parameter to Pig Script contains forward slash - Script treats it as a Division operator. Escape not working

Hi

I am passing a parameter to my Pig script. Its value is a date string in the
form of MM/DD/YYYY. I am trying to have this parameter's value as an
additional column to the final output of the script. The script throws an
error as it treats the forward slash as division operator. I tried escaping
the forward slash with a back slash but the error persists.

An example to illustrate my case:

The dateString parameter's value is escaped using back slashes.
dateString=10\/24\/2010

Call to my Pig script from a Shell wrapper:
pig -Dmapred.job.queue.name=${QUEUE} -f ./test.pig -param
dateString="${dateString}"

Error message:
Pig Stack Trace
---------------
ERROR 1039: In alias outputValue, incompatible types in Division Operator
left hand side:chararray right hand side:int

Any thoughts on how to get it right? Thanks a bunch.

Regards
Arun

Re: Parameter to Pig Script contains forward slash - Script treats it as a Division operator. Escape not working

Posted by Alan Gates <ga...@yahoo-inc.com>.
If you pass '10/24/2010' instead of 10/24/2010 (that is, with single  
quotes), I think it will work.  You'll have to be careful to actually  
get the single quotes through your shell, which will try to eat them.

Alan.

On Feb 13, 2011, at 12:29 PM, Arun A K wrote:

> Hi
>
> I am passing a parameter to my Pig script. Its value is a date  
> string in the
> form of MM/DD/YYYY. I am trying to have this parameter's value as an
> additional column to the final output of the script. The script  
> throws an
> error as it treats the forward slash as division operator. I tried  
> escaping
> the forward slash with a back slash but the error persists.
>
> An example to illustrate my case:
>
> The dateString parameter's value is escaped using back slashes.
> dateString=10\/24\/2010
>
> Call to my Pig script from a Shell wrapper:
> pig -Dmapred.job.queue.name=${QUEUE} -f ./test.pig -param
> dateString="${dateString}"
>
> Error message:
> Pig Stack Trace
> ---------------
> ERROR 1039: In alias outputValue, incompatible types in Division  
> Operator
> left hand side:chararray right hand side:int
>
> Any thoughts on how to get it right? Thanks a bunch.
>
> Regards
> Arun