|
|
-
RE: Pig / Map data type for keys / String cannot be cast to integerSanthosh Srinivasan 2009-03-18, 22:27
The value 35 for key01 on the second row is being interpreted as an
integer. The issue is captured in PIG-724 (https://issues.apache.org/jira/browse/PIG-724). The only workaround I can think of right now, is to ensure consistency in the values for the keys, i.e., knock of numeric values for key key01 in your data. Thanks, Santhosh -----Original Message----- From: Mathias Fryde [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 18, 2009 5:47 AM To: [EMAIL PROTECTED] Subject: Re: Pig / Map data type for keys / String cannot be cast to integer Hello here is a simple example. regards, [key01#Location,key02#value01] [key01#35,key02#value01] [key01#Location,key02#value01] [key01#Zone,key02#value01] [key01#toto,key02#value01] [key01#0,key02#value01] [key02#value01] [key01#Location,key02#value01] 2009/3/18 Mridul Muralidharan <[EMAIL PROTECTED]> > > I am not sure what the problem is, but my guess would be that the map is > getting loaded as (chararray, int) - and the comparison is failing cos of it > ? > Someone from pig team can confirm if this is a known bug/issue (iirc it is > not). > > If possible, can you post a snippet of the input file ? > > Thanks, > Mridul > > > > Mathias Fryde wrote: > >> Hello, >> I have a map whit a key that have diffrent values like *: Location, Zone, >> 35, Place .... >> *When I execute my script with a filter on this key I a have a Cast >> error.* >> >> source = LOAD 'thesource' USING PigStorage('|') AS ( themap: map []); >> A = FILTER source BY themap#'key01' == 'Location' ; >> DUMP **A**;* >> >> I also tried : >> *A = FILTER source BY (chararray)themap#'key01' == 'Location' ;* >> *A = FILTER source BY (chararray)themap#'key01' == 'Location' ; >> **A = FILTER source BY **themap#'data:Resource:id' matches '.***Location** >> .*'; >> *but still have the same error ... * >> >> * >> >> - *anyone as a solution How do do it? * >> - *Why Pig down't use default string? * >> - *Do Pig define datatypes alone ?* >> >> >> >> org.apache.pig.tools.grunt.Grunt - >> org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1066: Unable to >> open iterator for alias A >> at org.apache.pig.PigServer.openIterator(PigServer.java:438) >> at >> org.apache.pig.tools.grunt.GruntParser.processDump(GruntParser.java:359) >> at >> >> org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptPar ser.java:193) >> at >> >> org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java :99) >> at org.apache.pig.tools.grunt.Grunt.exec(Grunt.java:82) >> at org.apache.pig.Main.main(Main.java:354) >> Caused by: org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1002: >> Unable to store alias A >> at org.apache.pig.PigServer.store(PigServer.java:469) >> at org.apache.pig.PigServer.openIterator(PigServer.java:426) >> ... 5 more >> Caused by: org.apache.pig.impl.logicalLayer.FrontendException: ERROR 1002: >> Unable to store alias A >> at org.apache.pig.PigServer.store(PigServer.java:502) >> at org.apache.pig.PigServer.store(PigServer.java:465) >> ... 6 more >> Caused by: org.apache.pig.backend.executionengine.ExecException: ERROR 0: >> java.lang.String cannot be cast to java.lang.Integer >> at >> >> org.apache.pig.backend.local.executionengine.LocalExecutionEngine.execut e(LocalExecutionEngine.java:178) >> at >> org.apache.pig.PigServer.executeCompiledLogicalPlan(PigServer.java:695) >> at org.apache.pig.PigServer.store(PigServer.java:498) >> ... 7 more >> Caused by: *java.lang.ClassCastException: java.lang.String cannot be cast >> to >> java.lang.Integer* >> at java.lang.Integer.compareTo(Integer.java:35) >> at >> >> org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOp erators.EqualToExpr.doComparison(EqualToExpr.java:127) >> at >> >> org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOp erators.EqualToExpr.getNext(EqualToExpr.java:100) org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOp erators.POAnd.getNext(POAnd.java:78) org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOp erators.POFilter.getNext(POFilter.java:148) org.apache.pig.backend.hadoop.executionengine.physicalLayer.PhysicalOper ator.processInput(PhysicalOperator.java:231) org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOp erators.POStore.store(POStore.java:138) org.apache.pig.backend.local.executionengine.LocalPigLauncher.launchPig( LocalPigLauncher.java:68) org.apache.pig.backend.local.executionengine.LocalExecutionEngine.execut e(LocalExecutionEngine.java:166) |