Author: daijy
Date: Fri Dec 11 23:31:51 2009
New Revision: 889858

URL: http://svn.apache.org/viewvc?rev=889858&view=rev
Log:
PIG-1086: Nested sort by * throw exception

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

Modified: hadoop/pig/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/CHANGES.txt?rev=889858&r1=889857&r2=889858&view=diff
==============================================================================
--- hadoop/pig/trunk/CHANGES.txt (original)
+++ hadoop/pig/trunk/CHANGES.txt Fri Dec 11 23:31:51 2009
@@ -85,6 +85,8 @@
 PIG-1064: Behaviour of COGROUP with and without schema when using "*" operator
 (pradeepkth)
 
+PIG-1086: Nested sort by * throw exception (rding via daijy)
+
 Release 0.6.0 - Unreleased
 
 INCOMPATIBLE CHANGES

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=889858&r1=889857&r2=889858&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 
Fri Dec 11 23:31:51 2009
@@ -2732,6 +2732,10 @@
                
                        lp.connect(eOp, sort);
                        log.debug("Connected alias " + eOp.getAlias() + " 
operator " + eOp.getClass().getName() + " to operator " + 
sort.getClass().getName() + " the logical plan");
+                       
+                       // set the correct schema for sort and eOp so that the 
ProjectStarTranslator
+                       // can work the magic.
+                       sort.getSchema();
                } catch (PlanException planException) {
                        ParseException pe = new 
ParseException(planException.getMessage());
                        pe.initCause(planException); 

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=889858&r1=889857&r2=889858&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestForEachNestedPlan.java 
(original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestForEachNestedPlan.java Fri 
Dec 11 23:31:51 2009
@@ -65,6 +65,23 @@
         }
     }
 
+    @Test
+    public void testInnerOrderByStarWithSchema() throws Exception {        
+        File tmpFile = genDataSetFile1(false);
+        pig.registerQuery("a = load '" + Util.generateURI(tmpFile.toString()) 
+ "' as (a0, a1);");
+        pig.registerQuery("b = group a by a0; ");
+        pig.registerQuery("c = foreach b { d = order a by *; "
+                + "  generate group, d; };");
+        Iterator<Tuple> it = pig.openIterator("c");
+        Tuple t = null;
+        int count = 0;
+        while (it.hasNext()) {
+            t = it.next();
+            System.out.println(count + ":" + t);
+            count++;
+        }
+        Assert.assertEquals(count, 10);
+    }
 
     /*
     @Test

Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestLogicalPlanBuilder.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestLogicalPlanBuilder.java?rev=889858&r1=889857&r2=889858&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestLogicalPlanBuilder.java 
(original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestLogicalPlanBuilder.java Fri 
Dec 11 23:31:51 2009
@@ -1741,8 +1741,10 @@
 
         sort = 
(LOSort)foreachPlan.getPredecessors(foreachPlan.getLeaves().get(0)).get(0);
 
+        // project (*) operator here is translated to a list of projection
+        // operators
         for(LogicalPlan sortPlan: sort.getSortColPlans()) {
-            assertTrue(checkPlanForProjectStar(sortPlan) == true);
+            assertTrue(checkPlanForProjectStar(sortPlan) == false);
         }
 
     }


Reply via email to