Author: daijy
Date: Wed May 13 23:31:37 2015
New Revision: 1679296

URL: http://svn.apache.org/r1679296
Log:
PIG-4452: Embedded SQL using "SQL" instead of "sql" fails with string index out 
of range: -1 error

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java
    pig/trunk/test/e2e/pig/tests/hcat.conf

Modified: pig/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1679296&r1=1679295&r2=1679296&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Wed May 13 23:31:37 2015
@@ -76,6 +76,8 @@ PIG-4333: Split BigData tests into multi
  
 BUG FIXES
 
+PIG-4452: Embedded SQL using "SQL" instead of "sql" fails with string index 
out of range: -1 error (daijy)
+
 PIG-4543: TestEvalPipelineLocal.testRankWithEmptyReduce fail on Hadoop 1 
(daijy)
 
 PIG-4544: Upgrade Hbase to 0.98.12 (daijy)

Modified: pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java
URL: 
http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java?rev=1679296&r1=1679295&r2=1679296&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java (original)
+++ pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java Wed May 13 
23:31:37 2015
@@ -1227,8 +1227,14 @@ public class GruntParser extends PigScri
                } else {
                        tokensList.add(hcatBin);
                }
+               cmd = cmd.trim();
+               if (!cmd.substring(0, 3).toLowerCase().equals("sql")) {
+                   // Should never happen
+                   throw new IOException("sql command not start with sql 
keyword");
+               }
+               cmd = cmd.substring(3).trim();
                tokensList.add("-e");
-               
tokensList.add(cmd.substring(cmd.indexOf("sql")).substring(4).replaceAll("\n", 
" "));
+               tokensList.add(cmd.replaceAll("\n", " "));
                String[] tokens = tokensList.toArray(new String[]{});
 
         // create new environment = environment - HADOOP_CLASSPATH

Modified: pig/trunk/test/e2e/pig/tests/hcat.conf
URL: 
http://svn.apache.org/viewvc/pig/trunk/test/e2e/pig/tests/hcat.conf?rev=1679296&r1=1679295&r2=1679296&view=diff
==============================================================================
--- pig/trunk/test/e2e/pig/tests/hcat.conf (original)
+++ pig/trunk/test/e2e/pig/tests/hcat.conf Wed May 13 23:31:37 2015
@@ -44,7 +44,7 @@ stored as textfile;\,
                        'num' => 2,
                        'java_params' => ['-Dhcat.bin=:HCATBIN:'],
                        'pig' => q\a = load ':INPATH:/singlefile/studenttab10k' 
as (name, age, gpa);
-sql drop table if exists pig_hcat_ddl_1;
+SQL drop table if exists pig_hcat_ddl_1;
 sql create table pig_hcat_ddl_1(name string,
 age int,
 gpa double)


Reply via email to