Author: rding
Date: Mon Aug 16 17:35:52 2010
New Revision: 986068

URL: http://svn.apache.org/viewvc?rev=986068&view=rev
Log:
PIG-1392: Parser fails to recognize valid field

Modified:
    hadoop/pig/trunk/CHANGES.txt
    
hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/MapReduceLauncher.java
    hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt
    hadoop/pig/trunk/test/org/apache/pig/test/TestForEachNestedPlan.java

Modified: hadoop/pig/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/CHANGES.txt?rev=986068&r1=986067&r2=986068&view=diff
==============================================================================
--- hadoop/pig/trunk/CHANGES.txt (original)
+++ hadoop/pig/trunk/CHANGES.txt Mon Aug 16 17:35:52 2010
@@ -129,6 +129,8 @@ PIG-1309: Map-side Cogroup (ashutoshc)
 
 BUG FIXES
 
+PIG-1392: Parser fails to recognize valid field (niraj via rding)
+
 PIG-1541: FR Join shouldn't match null values (rding)
 
 PIG-1525: Incorrect data generated by diff of SUM (rding)

Modified: 
hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/MapReduceLauncher.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/MapReduceLauncher.java?rev=986068&r1=986067&r2=986068&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/MapReduceLauncher.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/MapReduceLauncher.java
 Mon Aug 16 17:35:52 2010
@@ -422,7 +422,7 @@ public class MapReduceLauncher extends L
         so.visit();
         
         // Optimize to use secondary sort key if possible
-        prop = System.getProperty("pig.exec.nosecondarykey");
+        prop = pc.getProperties().getProperty("pig.exec.nosecondarykey");
         if (!("true".equals(prop)))  {
             SecondaryKeyOptimizer skOptimizer = new 
SecondaryKeyOptimizer(plan);
             skOptimizer.visit();

Modified: 
hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt?rev=986068&r1=986067&r2=986068&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt 
(original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt 
Mon Aug 16 17:35:52 2010
@@ -2875,7 +2875,7 @@ LogicalOperator NestedProject(Schema ove
     "." 
     (
     i = ColNameOrNum(subSchema) {colList.add(i);}
-|   "(" i = ColNameOrNum(subSchema) {colList.add(i);} ("," i = 
ColNameOrNum(over) {colList.add(i);})* ")"
+|   "(" i = ColNameOrNum(subSchema) {colList.add(i);} ("," i = 
ColNameOrNum(subSchema) {colList.add(i);})* ")"
     )
     {
         ArrayList<LogicalPlan> foreachPlans = new ArrayList<LogicalPlan>();

Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestForEachNestedPlan.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestForEachNestedPlan.java?rev=986068&r1=986067&r2=986068&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestForEachNestedPlan.java 
(original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestForEachNestedPlan.java Mon 
Aug 16 17:35:52 2010
@@ -33,6 +33,8 @@ import junit.framework.Assert;
 
 import org.apache.pig.ExecType;
 import org.apache.pig.PigServer;
+import org.apache.pig.data.BagFactory;
+import org.apache.pig.data.DataBag;
 import org.apache.pig.data.Tuple;
 import org.apache.pig.impl.logicalLayer.parser.ParseException;
 import org.apache.pig.test.utils.TestHelper;
@@ -97,7 +99,52 @@ public class TestForEachNestedPlan {
         }
         Assert.assertEquals(count, 10);
     }
-    
+   
+    @Test
+    public void testMultiColInAlias() throws Exception {    
+       
pig.getPigContext().getProperties().setProperty("pig.exec.nosecondarykey", 
"true");
+       String INPUT_FILE = "test-multi-alias.txt";
+        PrintWriter w = new PrintWriter(new FileWriter(INPUT_FILE));
+        w.println("10\tnrai01\t01");
+        w.println("20\tnrai02\t02");
+        w.close();
+        
+        try {
+          
+            Util.copyFromLocalToCluster(cluster, INPUT_FILE, INPUT_FILE);
+            pig.registerQuery("A = load '" + INPUT_FILE + "' "
+                    + "as (a:int, b:chararray, c:int);");
+            pig.registerQuery("B = GROUP A BY (a, b);") ;
+           
+            DataBag dbfrj = BagFactory.getInstance().newDefaultBag(), dbshj = 
BagFactory.getInstance().newDefaultBag();
+            {
+                pig.registerQuery("C = FOREACH B { bg = A.($1,$2); GENERATE 
group, bg; } ;") ;
+                Iterator<Tuple> iter1 = pig.openIterator("C");
+                while(iter1.hasNext()) {
+                    dbfrj.add(iter1.next());
+                }
+            }
+            {
+                pig.registerQuery("D = FOREACH B { GENERATE group, 
A.($1,$2);};") ;
+                Iterator<Tuple> iter2 = pig.openIterator("D");
+                while(iter2.hasNext()) {
+                    dbshj.add(iter2.next());
+                }
+            }
+            Assert.assertEquals(dbfrj.size(), dbshj.size());
+            Assert.assertEquals(true, TestHelper.compareBags(dbfrj, dbshj)); 
+
+        } finally{
+            new File(INPUT_FILE).delete();
+            try {
+                Util.deleteFile(cluster, INPUT_FILE);
+            } catch (IOException e) {
+                e.printStackTrace();
+                Assert.fail();
+            }
+        }
+    }
+   
     @Test
     public void testAlgebricFuncWithoutGroupBy() 
     throws IOException, ParseException {


Reply via email to