<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question *Closed*: Pig SPLIT Syntax error, unexpected symbol in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Closed-Pig-SPLIT-Syntax-error-unexpected-symbol/m-p/216454#M77133</link>
    <description>&lt;P&gt;I am using PIG to read a file and want to pass those data and using `SPLIT` I want to split data and below is my input file;&lt;/P&gt;&lt;PRE&gt;1,aaa,123456,annotation
2,bbb,234567,barber
4,ddd,456789,federal
3,ccc,345678,code
4,ddd,456789,definition
5,asd,545645,AcsToGlRestServices
6,date,58314,filterlevel
7,kssa,22334,timefield
8,Bhi,2236,context&lt;/PRE&gt;&lt;P&gt;I executed following pig script. Below is my PIG script.&lt;/P&gt;&lt;PRE&gt;grunt&amp;gt; rawlvl = load '~/file' using PigStorage(',') as (no:int,name:chararray,phno:int,add:chararray);
grunt&amp;gt; splitlvl = SPLIT rawlvl into one if (no&amp;gt;2 and no&amp;lt;5),two if (no&amp;gt;5); &lt;/PRE&gt;&lt;P&gt;But I am getting an exception, kindly help me why I am getting this exception. Below is the exception;&lt;/P&gt;&lt;PRE&gt;2018-04-12 06:02:19,718 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: &amp;lt;line 3, column 0&amp;gt; Syntax error, unexpected symbol at or near 'splitlvl' Details at logfile: /root/pig_1523510819542.log &lt;/PRE&gt;&lt;P&gt;And following below I have pasted `pig_1523510819542.log` file.&lt;/P&gt;&lt;PRE&gt;================================================================================
Pig Stack Trace
---------------
ERROR 1200: &amp;lt;line 4, column 0&amp;gt;  Syntax error, unexpected symbol at or near 'splitlvl'
Failed to parse: &amp;lt;line 4, column 0&amp;gt;  Syntax error, unexpected symbol at or near 'splitlvl'
        at org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:244)
        at org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:182)
        at org.apache.pig.PigServer$Graph.validateQuery(PigServer.java:1791)
        at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:1764)
        at org.apache.pig.PigServer.registerQuery(PigServer.java:707)
        at org.apache.pig.tools.grunt.GruntParser.processPig(GruntParser.java:1075)
        at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:505)
        at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:231)
        at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:206)
        at org.apache.pig.tools.grunt.Grunt.run(Grunt.java:66)
        at org.apache.pig.Main.run(Main.java:566)
        at org.apache.pig.Main.main(Main.java:178)
        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:498)
        at org.apache.hadoop.util.RunJar.run(RunJar.java:233)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:148)
================================================================================&lt;/PRE&gt;&lt;P&gt;Kindly help me out here, as I am new to HADOOP and PIG.&lt;/P&gt;</description>
    <pubDate>Thu, 12 Apr 2018 13:27:30 GMT</pubDate>
    <dc:creator>pateljay</dc:creator>
    <dc:date>2018-04-12T13:27:30Z</dc:date>
    <item>
      <title>*Closed*: Pig SPLIT Syntax error, unexpected symbol</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Closed-Pig-SPLIT-Syntax-error-unexpected-symbol/m-p/216454#M77133</link>
      <description>&lt;P&gt;I am using PIG to read a file and want to pass those data and using `SPLIT` I want to split data and below is my input file;&lt;/P&gt;&lt;PRE&gt;1,aaa,123456,annotation
2,bbb,234567,barber
4,ddd,456789,federal
3,ccc,345678,code
4,ddd,456789,definition
5,asd,545645,AcsToGlRestServices
6,date,58314,filterlevel
7,kssa,22334,timefield
8,Bhi,2236,context&lt;/PRE&gt;&lt;P&gt;I executed following pig script. Below is my PIG script.&lt;/P&gt;&lt;PRE&gt;grunt&amp;gt; rawlvl = load '~/file' using PigStorage(',') as (no:int,name:chararray,phno:int,add:chararray);
grunt&amp;gt; splitlvl = SPLIT rawlvl into one if (no&amp;gt;2 and no&amp;lt;5),two if (no&amp;gt;5); &lt;/PRE&gt;&lt;P&gt;But I am getting an exception, kindly help me why I am getting this exception. Below is the exception;&lt;/P&gt;&lt;PRE&gt;2018-04-12 06:02:19,718 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: &amp;lt;line 3, column 0&amp;gt; Syntax error, unexpected symbol at or near 'splitlvl' Details at logfile: /root/pig_1523510819542.log &lt;/PRE&gt;&lt;P&gt;And following below I have pasted `pig_1523510819542.log` file.&lt;/P&gt;&lt;PRE&gt;================================================================================
Pig Stack Trace
---------------
ERROR 1200: &amp;lt;line 4, column 0&amp;gt;  Syntax error, unexpected symbol at or near 'splitlvl'
Failed to parse: &amp;lt;line 4, column 0&amp;gt;  Syntax error, unexpected symbol at or near 'splitlvl'
        at org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:244)
        at org.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:182)
        at org.apache.pig.PigServer$Graph.validateQuery(PigServer.java:1791)
        at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:1764)
        at org.apache.pig.PigServer.registerQuery(PigServer.java:707)
        at org.apache.pig.tools.grunt.GruntParser.processPig(GruntParser.java:1075)
        at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:505)
        at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:231)
        at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:206)
        at org.apache.pig.tools.grunt.Grunt.run(Grunt.java:66)
        at org.apache.pig.Main.run(Main.java:566)
        at org.apache.pig.Main.main(Main.java:178)
        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:498)
        at org.apache.hadoop.util.RunJar.run(RunJar.java:233)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:148)
================================================================================&lt;/PRE&gt;&lt;P&gt;Kindly help me out here, as I am new to HADOOP and PIG.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 13:27:30 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Closed-Pig-SPLIT-Syntax-error-unexpected-symbol/m-p/216454#M77133</guid>
      <dc:creator>pateljay</dc:creator>
      <dc:date>2018-04-12T13:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: *Closed*: Pig SPLIT Syntax error, unexpected symbol</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Closed-Pig-SPLIT-Syntax-error-unexpected-symbol/m-p/216455#M77134</link>
      <description>&lt;P&gt;@JAy PaTel&lt;/P&gt;&lt;P&gt;The issue is with you are storing the split results into &lt;STRONG&gt;splitlvl relation,&lt;/STRONG&gt; However by using &lt;STRONG&gt;split function&lt;/STRONG&gt; we are splitting out &lt;STRONG&gt;rawlvl&lt;/STRONG&gt; relation into &lt;STRONG&gt;one,two&lt;/STRONG&gt; relations and then you are keeping the results into splitvl relation.&lt;/P&gt;&lt;PRE&gt;grunt&amp;gt; splitlvl = SPLIT rawlvl into one if(no&amp;gt;2andno&amp;lt;5),two if(no&amp;gt;5);&lt;/PRE&gt;&lt;P&gt;Storing split function results into another relation(splitvl), is not a valid syntax for split function in pig&lt;/P&gt;&lt;P&gt;Change your script to&lt;/P&gt;&lt;PRE&gt;grunt&amp;gt; rawlvl = load '~/file'usingPigStorage(',')as(no:int,name:chararray,phno:int,add:chararray);&lt;BR /&gt;grunt&amp;gt; SPLIT rawlvl into one if(no&amp;gt;2andno&amp;lt;5),two if(no&amp;gt;5);
grunt&amp;gt; dump one;&lt;BR /&gt;grunt&amp;gt; dump two;&lt;/PRE&gt;&lt;P&gt;For more details about split function please refer to below link.&lt;BR /&gt;&lt;A href="http://pig.apache.org/docs/r0.7.0/piglatin_ref2.html#SPLIT" target="_blank"&gt;http://pig.apache.org/docs/r0.7.0/piglatin_ref2.html#SPLIT&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Example:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step1:- &lt;BR /&gt;&lt;/STRONG&gt;Loaded input file into pig&lt;/P&gt;&lt;PRE&gt;grunt&amp;gt; rawlvl = load '/t.txt' using PigStorage(',') as (no:int,name:chararray,phno:int,add:chararray);&lt;BR /&gt;grunt&amp;gt; dump rawlvl&lt;BR /&gt;(1,aaa,123456,annotation)
(2,bbb,234567,barber)
(4,ddd,456789,federal)
(3,ccc,345678,code)
(4,ddd,456789,definition)
(5,asd,545645,AcsToGlRestServices)
(6,date,58314,filterlevel)
(7,kssa,22334,timefield)
(8,Bhi,2236,context)&lt;/PRE&gt;&lt;P&gt;data is loaded into rawlvl relation.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step2:-&lt;/STRONG&gt;&lt;BR /&gt;Now &lt;STRONG&gt;split rawlvl relation into two relations i.e one,two&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;grunt&amp;gt; SPLIT rawlvl into one if (no&amp;gt;2 and no&amp;lt;5),two if (no&amp;gt;5);&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Dump one relation&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;grunt&amp;gt; dump one;
(4,ddd,456789,federal)
(3,ccc,345678,code)
(4,ddd,456789,definition)&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Dump two relation&lt;/STRONG&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;grunt&amp;gt; dump two;
(6,date,58314,filterlevel)
(7,kssa,22334,timefield)
(8,Bhi,2236,context)&lt;/PRE&gt;&lt;P&gt;As you can view the output of one,two relations matching with your conditions specified.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;If the Answer helped to resolve your issue, &lt;STRONG&gt;Click on Accept button below to accept the answer,&lt;/STRONG&gt; That would be great help to Community users to find solution quickly for these kind of issues.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 18:27:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Closed-Pig-SPLIT-Syntax-error-unexpected-symbol/m-p/216455#M77134</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2018-04-12T18:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: *Closed*: Pig SPLIT Syntax error, unexpected symbol</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Closed-Pig-SPLIT-Syntax-error-unexpected-symbol/m-p/216456#M77135</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/18929/yaswanthmuppireddy.html" nodeid="18929"&gt;@Shu&lt;/A&gt; Oh! I see. Thak you so much. Those minor mistakes I didn't notice.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 19:03:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Closed-Pig-SPLIT-Syntax-error-unexpected-symbol/m-p/216456#M77135</guid>
      <dc:creator>pateljay</dc:creator>
      <dc:date>2018-04-12T19:03:17Z</dc:date>
    </item>
  </channel>
</rss>

