Author: gates
Date: Thu Aug 28 15:59:06 2008
New Revision: 690039

URL: http://svn.apache.org/viewvc?rev=690039&view=rev
Log:
PIG-359 (yet again).  Address an issue Santhosh identified with the earlier 
patch where POUserFunc and POForEach were assuming that project star was a 
tuple,
when in some cases in inner plans it can be a bag.


Modified:
    
incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POUserFunc.java
    
incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POForEach.java
    incubator/pig/branches/types/test/org/apache/pig/test/TestEvalPipeline.java

Modified: 
incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POUserFunc.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POUserFunc.java?rev=690039&r1=690038&r2=690039&view=diff
==============================================================================
--- 
incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POUserFunc.java
 (original)
+++ 
incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POUserFunc.java
 Thu Aug 28 15:59:06 2008
@@ -153,7 +153,8 @@
                 if(temp.returnStatus!=POStatus.STATUS_OK)
                     return temp;
                 
-                if(op instanceof POProject){
+                if(op instanceof POProject &&
+                        op.getResultType() == DataType.TUPLE){
                     POProject projOp = (POProject)op;
                     if(projOp.isStar()){
                         Tuple trslt = (Tuple) temp.result;

Modified: 
incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POForEach.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POForEach.java?rev=690039&r1=690038&r2=690039&view=diff
==============================================================================
--- 
incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POForEach.java
 (original)
+++ 
incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/relationalOperators/POForEach.java
 Thu Aug 28 15:59:06 2008
@@ -337,7 +337,9 @@
                 ++i;
                 PhysicalOperator leaf = 
(PhysicalOperator)p.getLeaves().get(0); 
                 planLeaves.add(leaf);
-                if(leaf instanceof POProject && ((POProject)leaf).isStar())
+                if(leaf instanceof POProject &&
+                        leaf.getResultType() == DataType.TUPLE &&
+                        ((POProject)leaf).isStar())
                     isToBeFlattened.set(i, true);
             }
         }

Modified: 
incubator/pig/branches/types/test/org/apache/pig/test/TestEvalPipeline.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/TestEvalPipeline.java?rev=690039&r1=690038&r2=690039&view=diff
==============================================================================
--- incubator/pig/branches/types/test/org/apache/pig/test/TestEvalPipeline.java 
(original)
+++ incubator/pig/branches/types/test/org/apache/pig/test/TestEvalPipeline.java 
Thu Aug 28 15:59:06 2008
@@ -376,7 +376,7 @@
         + "C1 = filter A by $0 > -1;"
         + "C2 = distinct C1;"
         + "C3 = distinct A;"
-        + "generate (int)group," + Identity.class.getName() +"(*), COUNT(C2), 
SUM(C2.$1)," +  TitleNGrams.class.getName() + "(C3), MAX(C3.$1);"
+        + "generate (int)group," + Identity.class.getName() +"(*), COUNT(C2), 
SUM(C2.$1)," +  TitleNGrams.class.getName() + "(C3), MAX(C3.$1), C2;"
         + "};";
 
         pigServer.registerQuery(query);
@@ -389,7 +389,8 @@
             assertEquals((Long)5L, (Long)t.get(2));
             assertEquals(LOOP_COUNT*2.0, (Double)t.get(3), 0.01);
             assertEquals(8.0, (Double)t.get(5), 0.01);
-            assertEquals(6, t.size());
+            assertEquals(5L, ((DataBag)t.get(6)).size());
+            assertEquals(7, t.size());
             ++numIdentity;
         }
         assertEquals(LOOP_COUNT, numIdentity);


Reply via email to