Looks like you miss a comma- ASSERT a BY source_id > 9, 'source_id should be greater than 9';
That's another bug in 0.12 documentation which is fixed now. On Wed, Feb 26, 2014 at 8:27 AM, Ronald Green <green.ron...@gmail.com>wrote: > Hi Cheolsoo, > > I tried to apply the patch and rebuild pig but it's still not working. > > When I try to use assert just like in pig docs I get an exception if I add > a message: > > a = LOAD '/data' USING PigStorage() AS (source_id:int, > source_name:chararray); > ASSERT a BY source_id > 9 'source_id should be greater than 9'; > > > Pig Stack Trace > --------------- > ERROR 1200: <line 87, column 31> mismatched input ''source_id should be > greater than 9'' expecting SEMI_COLON > > Failed to parse: <line 87, column 31> mismatched input ''source_id should > be greater than 9'' expecting SEMI_COLON > at org.apache.pig.parser.QueryParserDriver.parse( > QueryParserDriver.java:241) > at org.apache.pig.parser.QueryParserDriver.parse( > QueryParserDriver.java:179) > at org.apache.pig.PigServer$Graph.validateQuery(PigServer.java:1648) > at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:1621) > at org.apache.pig.PigServer.registerQuery(PigServer.java:575) > at org.apache.pig.tools.grunt.GruntParser.processPig( > GruntParser.java:1093) > at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse( > PigScriptParser.java:501) > at org.apache.pig.tools.grunt.GruntParser.parseStopOnError( > GruntParser.java:198) > at org.apache.pig.tools.grunt.GruntParser.parseStopOnError( > GruntParser.java:173) > at org.apache.pig.tools.grunt.Grunt.run(Grunt.java:69) > at org.apache.pig.Main.run(Main.java:541) > at org.apache.pig.Main.main(Main.java:156) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke( > NativeMethodAccessorImpl.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke( > DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at org.apache.hadoop.util.RunJar.main(RunJar.java:160) > > > If I remove the message I'm able to execute the script but get a NPE: > > org.apache.pig.backend.executionengine.ExecException: ERROR 0: Error > while executing ForEach at [Select_Source[82,16]] > at > org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POForEach.getNextTuple(POForEach.java:306) > at > org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigGenericMapBase.runPipeline(PigGenericMapBase.java:282) > at > org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigGenericMapBase.map(PigGenericMapBase.java:277) > at > org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigGenericMapBase.map(PigGenericMapBase.java:64) > at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145) > at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:763) > at org.apache.hadoop.mapred.MapTask.run(MapTask.java:363) > at org.apache.hadoop.mapred.Child$4.run(Child.java:255) > at java.security.AccessController.doPrivileged(Native Method) > at javax.security.auth.Subject.doAs(Subject.java:396) > at > org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1232) > at org.apache.hadoop.mapred.Child.main(Child.java:249) > Caused by: java.lang.NullPointerException > at org.apache.pig.builtin.Assert.exec(Assert.java:38) > at org.apache.pig.builtin.Assert.exec(Assert.java:30) > at > org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POUserFunc.getNext(POUserFunc.java:330) > at > org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POUserFunc.getNextBoolean(POUserFunc.java:385) > at > org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POAnd.getNextBoolean(POAnd.java:67) > at > org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POFilter.getNextTuple(POFilter.java:148) > at > org.apache.pig.backend.hadoop.executionengine.physicalLayer.PhysicalOperator.processInput(PhysicalOperator.java:281) > at > org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POForEach.getNextTuple(POForEach.java:242) > ... 11 more > > > Any idea? > > Thanks, > Ron > > On Mon, Feb 24, 2014 at 7:12 PM, Cheolsoo Park <piaozhe...@gmail.com> > wrote: > > > Hi Ron, > > > > You're right that assert is broken in 0.12.0. Here is the jira- > > https://issues.apache.org/jira/browse/PIG-3670 > > > > The fix will be included in 0.12.1 and onwards. In the meantime, can you > > apply the patch and rebuild Pig? > > > > Thanks, > > Cheolsoo > > > > > > On Mon, Feb 24, 2014 at 4:11 AM, Ronald Green <green.ron...@gmail.com > > >wrote: > > > > > Hi, > > > > > > It seems like ASSERT doesn't really work in Pig 0.12. I get the > following > > > message when I try to use ASSERT: > > > > > > [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1000: Error > during > > > parsing. Encountered " <IDENTIFIER> "assert "" at line 1, column 1. > > > Was expecting one of: ... > > > > > > I also tried without the ASSERT keyword (simply A by a1>0 'message') > but > > it > > > doesn't work as well. > > > > > > The versions I tested were 0.12.0 (r1529718) and Pig > > 0.12.0.2.0.6.1-101. > > > > > > Any idea? > > > > > > Thanks, > > > Ron > > > > > >