Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

pig if error

Solved Go to solution

pig if error

Super Collaborator

hi:

can do this: i am receiving this error

(chararray) ( (COD_LINEA =='01' and ID_GRP_PD='11') OR (COD_LINEA =='01' and ID_GRP_PD='13') OR (COD_LINEA =='01' and ID_GRP_PD='21') ? 'CM' :
                ( (COD_LINEA =='01' and ID_GRP_PD='31') OR (COD_LINEA =='01' and ID_GRP_PD='32') OR (COD_LINEA =='01' and ID_GRP_PD='33') ? 'INGs' :
                ( (COD_LINEA =='01' and ID_GRP_PD='34') OR (COD_LINEA =='01' and ID_GRP_PD='35') OR (COD_LINEA =='01' and ID_GRP_PD='36') ? 'AXT' : ''))) as PROD;







2016-06-11 10:28:40,658 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1000: Error during parsing. Lexical error at line 79, column 9.  Encountered: "(" (40), after : ""

2016-06-11 10:28:40,658 [main] ERROR org.apache.pig.tools.grunt.Grunt - org.apache.pig.tools.pigscript.parser.TokenMgrError: Lexical error at line 79, column 9.  Encountered: "(" (40), after : ""

	at org.apache.pig.tools.pigscript.parser.PigScriptParserTokenManager.getNextToken(PigScriptParserTokenManager.java:3370)

	at org.apache.pig.tools.pigscript.parser.PigScriptParser.jj_ntk(PigScriptParser.java:1449)

	at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:110)

	at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:230)

	at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:205)

	at org.apache.pig.tools.grunt.Grunt.exec(Grunt.java:81)

	at org.apache.pig.Main.run(Main.java:631)

	at org.apache.pig.Main.main(Main.java:177)

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

	at java.lang.reflect.Method.invoke(Method.java:497)

	at org.apache.hadoop.util.RunJar.run(RunJar.java:221)

	at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: pig if error

Super Collaborator

Hi:

I fixed it like this:

B = FOREACH A GENERATE (chararray) (($3 =='01' AND $4=='11') OR ($3 =='01' AND $4=='13') OR ($3 =='01' AND $4=='21') ? 'CM' : '' ) 


2 REPLIES 2

Re: pig if error

Super Guru

Hmm, what are you trying to do, I get the same parsing error

Highlighted

Re: pig if error

Super Collaborator

Hi:

I fixed it like this:

B = FOREACH A GENERATE (chararray) (($3 =='01' AND $4=='11') OR ($3 =='01' AND $4=='13') OR ($3 =='01' AND $4=='21') ? 'CM' : '' ) 


Don't have an account?
Coming from Hortonworks? Activate your account here