You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Paul O'Leary <po...@quantivo.com> on 2008/09/23 22:20:26 UTC

Hello + Type Massage Question

Hi All,

Finally have the opportunity to use Pig in my day job.  Things are going
well; doing some pretty real stuff!

Quick type massage question, a minor issue really.

I have an expression that looks like this:

(TOTAL_PYMT_POSI_AMT EQ '' ? 0 : TOTAL_PYMT_POSI_AMT) -
(TOTAL_PYMT_NEG_AMT EQ '' ? 0 : TOTAL_PYMT_NEG_AMT) as TOTAL_PYMT_AMT

Pig seems to implicitly cast the types to float/double so the resulting
data field - when dumped - has a decimal, which I don't want.

Is there a way for me to cast the result of the calculation to an
integer, which is what I *do* want?

I noticed the syntax TOTAL_PYMT_AMT:int somewhere but that doesn't seem
to work...

Thanks in advance,
PaulO.


RE: Hello + Type Massage Question

Posted by Olga Natkovich <ol...@yahoo-inc.com>.
Try the types branch it has full support for types and explicit type
casting.

Olga 

> -----Original Message-----
> From: Paul O'Leary [mailto:poleary@quantivo.com] 
> Sent: Tuesday, September 23, 2008 1:20 PM
> To: pig-user@incubator.apache.org
> Subject: Hello + Type Massage Question
> 
> Hi All,
> 
> Finally have the opportunity to use Pig in my day job.  
> Things are going well; doing some pretty real stuff!
> 
> Quick type massage question, a minor issue really.
> 
> I have an expression that looks like this:
> 
> (TOTAL_PYMT_POSI_AMT EQ '' ? 0 : TOTAL_PYMT_POSI_AMT) - 
> (TOTAL_PYMT_NEG_AMT EQ '' ? 0 : TOTAL_PYMT_NEG_AMT) as TOTAL_PYMT_AMT
> 
> Pig seems to implicitly cast the types to float/double so the 
> resulting data field - when dumped - has a decimal, which I 
> don't want.
> 
> Is there a way for me to cast the result of the calculation 
> to an integer, which is what I *do* want?
> 
> I noticed the syntax TOTAL_PYMT_AMT:int somewhere but that 
> doesn't seem to work...
> 
> Thanks in advance,
> PaulO.
> 
>