You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Patcharee Thongtra <Pa...@uni.no> on 2014/05/30 12:02:16 UTC

java.lang.String cannot be cast to java.lang.Integer

Hi,

I got very strange exception.

80693 [main] ERROR org.apache.pig.tools.grunt.Grunt  - ERROR 1066: 
Unable to open iterator for alias ordered. Backend error : 
java.lang.String cannot be cast to java.lang.Integer
14/05/30 11:53:22 ERROR grunt.Grunt: ERROR 1066: Unable to open iterator 
for alias ordered. Backend error : java.lang.String cannot be cast to 
java.lang.Integer


In my pig script below, z is integer but pig complains as it is String.

query = load 'fino32' USING org.apache.hcatalog.pig.HCatLoader() as (
date: chararray,
u: float,
v: float,
t: float,
zone: int,
z: int);

ordered = ORDER query BY z;

dump ordered;


Any suggestion is appreciated.

Patcharee



Re: java.lang.String cannot be cast to java.lang.Integer

Posted by Patcharee Thongtra <Pa...@uni.no>.
Hi,

column z is integer and not null, so I do not understand why I got cast 
exception.

Patcharee

On 05/30/2014 01:23 PM, Piotr Dendek wrote:
> Hi,
>
> Handle null values,
> check if the content of column z is definitely integer values,
> ensure that no whitecharacters are included (e.g. "11 ").
>
> Ultimately, you can read the z column as chararray and process it with udf.
> This will give you chance to log the faulty record.
>
> Tell if any of this removed the problem.
>
> Piotr
> 30 maj 2014 12:02 "Patcharee Thongtra" <Pa...@uni.no>
> napisał(a):
>
>> Hi,
>>
>> I got very strange exception.
>>
>> 80693 [main] ERROR org.apache.pig.tools.grunt.Grunt  - ERROR 1066: Unable
>> to open iterator for alias ordered. Backend error : java.lang.String cannot
>> be cast to java.lang.Integer
>> 14/05/30 11:53:22 ERROR grunt.Grunt: ERROR 1066: Unable to open iterator
>> for alias ordered. Backend error : java.lang.String cannot be cast to
>> java.lang.Integer
>>
>>
>> In my pig script below, z is integer but pig complains as it is String.
>>
>> query = load 'fino32' USING org.apache.hcatalog.pig.HCatLoader() as (
>> date: chararray,
>> u: float,
>> v: float,
>> t: float,
>> zone: int,
>> z: int);
>>
>> ordered = ORDER query BY z;
>>
>> dump ordered;
>>
>>
>> Any suggestion is appreciated.
>>
>> Patcharee
>>
>>
>>


Re: java.lang.String cannot be cast to java.lang.Integer

Posted by Piotr Dendek <pi...@gmail.com>.
Hi,

Handle null values,
check if the content of column z is definitely integer values,
ensure that no whitecharacters are included (e.g. "11 ").

Ultimately, you can read the z column as chararray and process it with udf.
This will give you chance to log the faulty record.

Tell if any of this removed the problem.

Piotr
30 maj 2014 12:02 "Patcharee Thongtra" <Pa...@uni.no>
napisał(a):

> Hi,
>
> I got very strange exception.
>
> 80693 [main] ERROR org.apache.pig.tools.grunt.Grunt  - ERROR 1066: Unable
> to open iterator for alias ordered. Backend error : java.lang.String cannot
> be cast to java.lang.Integer
> 14/05/30 11:53:22 ERROR grunt.Grunt: ERROR 1066: Unable to open iterator
> for alias ordered. Backend error : java.lang.String cannot be cast to
> java.lang.Integer
>
>
> In my pig script below, z is integer but pig complains as it is String.
>
> query = load 'fino32' USING org.apache.hcatalog.pig.HCatLoader() as (
> date: chararray,
> u: float,
> v: float,
> t: float,
> zone: int,
> z: int);
>
> ordered = ORDER query BY z;
>
> dump ordered;
>
>
> Any suggestion is appreciated.
>
> Patcharee
>
>
>

Re:java.lang.String cannot be cast to java.lang.Integer

Posted by James <al...@gmail.com>.
How about using the explicit cast like 


  ordered = ORDER query BY (int)z;

Alcaid

------------------ Original ------------------
From:  "Patcharee Thongtra";<Pa...@uni.no>;
Date:  Fri, May 30, 2014 06:02 PM
To:  "user"<us...@pig.apache.org>; 

Subject:  java.lang.String cannot be cast to java.lang.Integer



Hi,

I got very strange exception.

80693 [main] ERROR org.apache.pig.tools.grunt.Grunt  - ERROR 1066: 
Unable to open iterator for alias ordered. Backend error : 
java.lang.String cannot be cast to java.lang.Integer
14/05/30 11:53:22 ERROR grunt.Grunt: ERROR 1066: Unable to open iterator 
for alias ordered. Backend error : java.lang.String cannot be cast to 
java.lang.Integer


In my pig script below, z is integer but pig complains as it is String.

query = load 'fino32' USING org.apache.hcatalog.pig.HCatLoader() as (
date: chararray,
u: float,
v: float,
t: float,
zone: int,
z: int);

ordered = ORDER query BY z;

dump ordered;


Any suggestion is appreciated.

Patcharee