You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Tamir Kamara <ta...@gmail.com> on 2009/03/03 16:06:00 UTC

Filter with long field type

Hi,

I'm having trouble when trying to filter by a field that is defined as long
and my desired value is also long.

For example:
traffic = load 'traffic.txt' as (domain:chararray, subnet:long);
r = filter traffic by subnet == 3521878016;

Will result in:
ERROR 2999: Unexpected internal error. For input string: "3521878016"
java.lang.NumberFormatException: For input string: "3521878016"
    at
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    at java.lang.Integer.parseInt(Integer.java:459)
    at java.lang.Integer.parseInt(Integer.java:497)
    at
org.apache.pig.impl.logicalLayer.parser.QueryParser.AtomDatum(QueryParser.java:5713)
    at
org.apache.pig.impl.logicalLayer.parser.QueryParser.Const(QueryParser.java:5827)
    at
org.apache.pig.impl.logicalLayer.parser.QueryParser.BaseEvalSpec(QueryParser.java:4058)
    at
org.apache.pig.impl.logicalLayer.parser.QueryParser.UnaryExpr(QueryParser.java:3964)
    at
org.apache.pig.impl.logicalLayer.parser.QueryParser.CastExpr(QueryParser.java:3918)
    at
org.apache.pig.impl.logicalLayer.parser.QueryParser.MultiplicativeExpr(QueryParser.java:3827)
    at
org.apache.pig.impl.logicalLayer.parser.QueryParser.AdditiveExpr(QueryParser.java:3753)
    at
org.apache.pig.impl.logicalLayer.parser.QueryParser.InfixExpr(QueryParser.java:3719)
    at
org.apache.pig.impl.logicalLayer.parser.QueryParser.PUnaryCond(QueryParser.java:1506)
    at
org.apache.pig.impl.logicalLayer.parser.QueryParser.PAndCond(QueryParser.java:1440)
    at
org.apache.pig.impl.logicalLayer.parser.QueryParser.POrCond(QueryParser.java:1384)
    at
org.apache.pig.impl.logicalLayer.parser.QueryParser.PCond(QueryParser.java:1350)
    at
org.apache.pig.impl.logicalLayer.parser.QueryParser.FilterClause(QueryParser.java:1260)
    at
org.apache.pig.impl.logicalLayer.parser.QueryParser.BaseExpr(QueryParser.java:992)
    at
org.apache.pig.impl.logicalLayer.parser.QueryParser.Expr(QueryParser.java:802)
    at
org.apache.pig.impl.logicalLayer.parser.QueryParser.Parse(QueryParser.java:595)
    at
org.apache.pig.impl.logicalLayer.LogicalPlanBuilder.parse(LogicalPlanBuilder.java:60)
    at org.apache.pig.PigServer.parseQuery(PigServer.java:310)
    at org.apache.pig.PigServer.registerQuery(PigServer.java:276)
    at
org.apache.pig.tools.grunt.GruntParser.processPig(GruntParser.java:520)
    at
org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:264)
    at
org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:98)
    at org.apache.pig.tools.grunt.Grunt.run(Grunt.java:69)
    at org.apache.pig.Main.main(Main.java:311)

I understand that pig tries to parse the number to int and fails because
it's too big (and hence the long definition). In order to avoid this I can
cast the long field to chararray and do a string comparison, but I think pig
should be able to figure this out from the field type, or at least do
parseLong instead of pasrsInt (it doesn't heart - I think ...).

What do you think ?

Re: Filter with long field type

Posted by Thejas Nair <te...@yahoo-inc.com>.
Replacing 3521878016 with 3521878016L to indicate that it is long should
work. By default it assumes that this number constant is a integer.

traffic = load 'traffic.txt' as (domain:chararray, subnet:long);
r = filter traffic by subnet == 3521878016L;

-Thejas


On 3/3/09 7:06 AM, "Tamir Kamara" <ta...@gmail.com> wrote:

> Hi,
> 
> I'm having trouble when trying to filter by a field that is defined as long
> and my desired value is also long.
> 
> For example:
> traffic = load 'traffic.txt' as (domain:chararray, subnet:long);
> r = filter traffic by subnet == 3521878016;
> 
> Will result in:
> ERROR 2999: Unexpected internal error. For input string: "3521878016"
> java.lang.NumberFormatException: For input string: "3521878016"
>     at
>