Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Pig >> mail # user >> Can I check if the field is integer or not


Copy link to this message
-
RE: Can I check if the field is integer or not
...for a one digit integer, or '[0-9]+' an integer of one or more digits.
________________________________________
From: Jagat Singh [[EMAIL PROTECTED]]
Sent: Thursday, June 07, 2012 7:08 PM
To: [EMAIL PROTECTED]
Subject: Re: Can I check if the field is integer or not

You can use regular expression

Field matches '[0-9]'

-----------
Sent from Mobile , short and crisp.
On 08-Jun-2012 3:49 AM, "sonia gehlot" <[EMAIL PROTECTED]> wrote:

> Hi Guys,
>
> Is there is any way in Pig to check either the field is integer or not.
>
> I have a pig script with a field coming as string and I am expecting it to
> have always integer value, but due to some data nuisance field might
> contain string and in such cases when I cast it to integer it throughs an
> error (can't convert string into integer). Is there is any way where I can
> use case statement say if the field integer then cast it to integer else
> put '-1'.
>
> Thanks for any help,
> Sonia
>