title: Parse Error- NoViableAltException found when running apache hive
body: <pre><code>NoViableAltException(26@[])
          at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1074)
          at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:202)
          at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166)
          at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:396)
          at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:308)
          at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1122)
          at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1170)
          at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1059)
          at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1049)
          at `enter code here`org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:213)
          at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:165)
          at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:376)
          at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:311)
          at org.apache.hadoop.hive.cli.CliDriver.processReader(CliDriver.java:409)
          at org.apache.hadoop.hive.cli.CliDriver.processFile(CliDriver.java:425)
          at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:714)
          at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681)
          at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
          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)
  FAILED: ParseException line 3:0 cannot recognize input near 'MERGE' 'INTO' 'scrap_data'
  
  Getting the above exception. in order to resolve the same issue, i have fallowed 
  https://stackoverflow.com/questions/18640760/hive-parseexception-cannot-recognize-input-near-end-string
  
  As per this blog. i made the changes but did not work for me.
  Help me with this issue. `enter code here`
  CREATE TABLE IF NOT EXISTS tbALPartNr(
  pn_id int,
  category int,
  pn varchar(30),
  price decimal(18, 8),
  pn_desc varchar(500),
  scrap_limit smallint,
  scrap_percent decimal(18, 0),
  price_limit decimal(18, 8),
  plant_name varchar(250)
  )
  MERGE INTO scrap_data.tbALPartNr t
  USING(SELECT distinct[scrap_data.tbALPartNr.pn],
  count([scrap_data.tbALPartNr.plant_name])as plants
  FROM scrap_data.tbALPartNr group by [scrap_data.tbALPartNr.pn]) s
  ON (t.scrap_data.tbALPartNr.pn=s.scrap_data.tbALPartNr.pn)
  WHEN MATCHED THEN
  UPDATE SET t.category=s.plants;
  </code></pre>
  
  <p>Above is the code i have in my .hql script. when i am running the script getting above error could you please help me with this.
  found the same kind issue in the below blog but did not help to resolve my issue.
  <a href="https://stackoverflow.com/questions/18640760/hive-parseexception-cannot-recognize-input-near-end-string">Hive ParseException - cannot recognize input near &#39;end&#39; &#39;string&#39;</a></p>
  
  <p>without this logic the script is working fine. </p>
  
  <pre><code>MERGE INTO scrap_data.tbALPartNr t
      USING(SELECT distinct[scrap_data.tbALPartNr.pn],
      count([scrap_data.tbALPartNr.plant_name])as plants
      FROM scrap_data.tbALPartNr group by [scrap_data.tbALPartNr.pn]) s
      ON (t.scrap_data.tbALPartNr.pn=s.scrap_data.tbALPartNr.pn)
      WHEN MATCHED THEN
      UPDATE SET t.category=s.plants;
  </code></pre>
  
  <p>Any one help with this. </p>