Author: olga
Date: Mon Oct 20 16:36:09 2008
New Revision: 706460

URL: http://svn.apache.org/viewvc?rev=706460&view=rev
Log:
PIG-499: parser issue with as

Modified:
    incubator/pig/branches/types/CHANGES.txt
    
incubator/pig/branches/types/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj
    incubator/pig/branches/types/test/org/apache/pig/test/TestGrunt.java

Modified: incubator/pig/branches/types/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/CHANGES.txt?rev=706460&r1=706459&r2=706460&view=diff
==============================================================================
--- incubator/pig/branches/types/CHANGES.txt (original)
+++ incubator/pig/branches/types/CHANGES.txt Mon Oct 20 16:36:09 2008
@@ -291,3 +291,5 @@
 
     PIG-500: Load Func for POCast is not being set in some cases (sms via
     olgan)
+
+    PIG-499: parser issue with as (sms via olgan)

Modified: 
incubator/pig/branches/types/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj?rev=706460&r1=706459&r2=706460&view=diff
==============================================================================
--- 
incubator/pig/branches/types/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj
 (original)
+++ 
incubator/pig/branches/types/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj
 Mon Oct 20 16:36:09 2008
@@ -192,8 +192,8 @@
 {
        <"'"> {prevState = PIG_START;} : IN_STRING
 |      <"`"> {prevState = PIG_START;} : IN_COMMAND
-|      <(" " | "\t")*["A","a"]["S","s"](" " | "\t")* > {prevState = 
PIG_START;} : SCHEMA_DEFINITION
-|   <(" " | 
"\t")*["G","g"]["E","e"]["N","n"]["E","e"]["R","r"]["A","a"]["T","t"]["E","e"]("
 " | "\t")* > {prevState = PIG_START;} : GENERATE
+|      <(" " | "\t")+["A","a"]["S","s"](" " | "\t")+ > {prevState = 
PIG_START;} : SCHEMA_DEFINITION
+|   <(" " | 
"\t")+["G","g"]["E","e"]["N","n"]["E","e"]["R","r"]["A","a"]["T","t"]["E","e"]("
 " | "\t")+ > {prevState = PIG_START;} : GENERATE
 |       <"{"> {pigBlockLevel = 1;} : IN_BLOCK
 |       <"}"> {if (true) throw new TokenMgrError("Unmatched '}'", 
TokenMgrError.LEXICAL_ERROR);}
 |       <";"> : PIG_END
@@ -289,8 +289,8 @@
 <IN_BLOCK> MORE :
 {
        <"\""> {prevState = IN_BLOCK;} : IN_STRING
-|      <(" " | "\t")*["A","a"]["S","s"](" " | "\t")* > {prevState = IN_BLOCK;} 
: SCHEMA_DEFINITION
-|   <(" " | 
"\t")*["G","g"]["E","e"]["N","n"]["E","e"]["R","r"]["A","a"]["T","t"]["E","e"]("
 " | "\t")*> {prevState = IN_BLOCK;} : GENERATE
+|      <(" " | "\t")+["A","a"]["S","s"](" " | "\t")+ > {prevState = IN_BLOCK;} 
: SCHEMA_DEFINITION
+|   <(" " | 
"\t")+["G","g"]["E","e"]["N","n"]["E","e"]["R","r"]["A","a"]["T","t"]["E","e"]("
 " | "\t")+> {prevState = IN_BLOCK;} : GENERATE
 |      <"{"> {pigBlockLevel++;}
 |       <"}"(";")?> {pigBlockLevel--; if (pigBlockLevel == 0) 
SwitchTo(PIG_END);}
 |      <"'"> {prevState = IN_BLOCK;} : IN_STRING

Modified: incubator/pig/branches/types/test/org/apache/pig/test/TestGrunt.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/TestGrunt.java?rev=706460&r1=706459&r2=706460&view=diff
==============================================================================
--- incubator/pig/branches/types/test/org/apache/pig/test/TestGrunt.java 
(original)
+++ incubator/pig/branches/types/test/org/apache/pig/test/TestGrunt.java Mon 
Oct 20 16:36:09 2008
@@ -77,7 +77,7 @@
         PigServer server = new PigServer("MAPREDUCE");
         PigContext context = server.getPigContext();
         
-        String strCmd = "a = load 'input1'as (b: bag{t(i: int, c:chararray, f: 
float)});\n";
+        String strCmd = "a = load 'input1' as (b: bag{t(i: int, c:chararray, 
f: float)});\n";
         
         ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
         InputStreamReader reader = new InputStreamReader(cmd);
@@ -88,6 +88,25 @@
     }
 
     @Test 
+    public void testBagSchemaFail() throws Throwable {
+        PigServer server = new PigServer("MAPREDUCE");
+        PigContext context = server.getPigContext();
+        
+        String strCmd = "a = load 'input1'as (b: bag{t(i: int, c:chararray, f: 
float)});\n";
+        
+        ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
+        InputStreamReader reader = new InputStreamReader(cmd);
+        
+        Grunt grunt = new Grunt(new BufferedReader(reader), context);
+    
+        try {
+            grunt.exec();
+        } catch (Exception e) {
+            assertTrue(e.getMessage().contains("Encountered \";\""));
+        }
+    }
+
+    @Test 
     public void testBagConstant() throws Throwable {
         PigServer server = new PigServer("MAPREDUCE");
         PigContext context = server.getPigContext();
@@ -207,6 +226,21 @@
         grunt.exec();
     }
 
+    @Test 
+    public void testParsingWordWithAsInForeachWithOutBlock2() throws Throwable 
{
+        PigServer server = new PigServer("MAPREDUCE");
+        PigContext context = server.getPigContext();
+        
+        String strCmd = "cash = load 'foo' as (foo, fast); b = foreach cash 
generate fast * 2.0;\n";
+        
+        ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
+        InputStreamReader reader = new InputStreamReader(cmd);
+        
+        Grunt grunt = new Grunt(new BufferedReader(reader), context);
+    
+        grunt.exec();
+    }
+
 
     @Test 
     public void testParsingGenerateInForeachBlock() throws Throwable {


Reply via email to